Skip to content

Commit

Permalink
impl(generator): add Start and Await overloads to clients (#14370)
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthart authored Jun 26, 2024
1 parent 1532677 commit 42336db
Show file tree
Hide file tree
Showing 524 changed files with 63,754 additions and 20 deletions.
98 changes: 98 additions & 0 deletions generator/integration_tests/golden/v1/golden_thing_admin_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,33 @@ GoldenThingAdminClient::CreateDatabase(std::string const& parent, std::string co
return connection_->CreateDatabase(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::CreateDatabase(ExperimentalTag, NoAwaitTag, std::string const& parent, std::string const& create_statement, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::test::admin::database::v1::CreateDatabaseRequest request;
request.set_parent(parent);
request.set_create_statement(create_statement);
return connection_->CreateDatabase(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::Database>>
GoldenThingAdminClient::CreateDatabase(google::test::admin::database::v1::CreateDatabaseRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->CreateDatabase(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::CreateDatabase(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::CreateDatabaseRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->CreateDatabase(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::Database>>
GoldenThingAdminClient::CreateDatabase(ExperimentalTag, google::longrunning::Operation const& operation, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->CreateDatabase(ExperimentalTag{}, operation);
}

StatusOr<google::test::admin::database::v1::Database>
GoldenThingAdminClient::GetDatabase(std::string const& name, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
Expand All @@ -86,12 +107,33 @@ GoldenThingAdminClient::UpdateDatabaseDdl(std::string const& database, std::vect
return connection_->UpdateDatabaseDdl(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::UpdateDatabaseDdl(ExperimentalTag, NoAwaitTag, std::string const& database, std::vector<std::string> const& statements, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::test::admin::database::v1::UpdateDatabaseDdlRequest request;
request.set_database(database);
*request.mutable_statements() = {statements.begin(), statements.end()};
return connection_->UpdateDatabaseDdl(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::UpdateDatabaseDdlMetadata>>
GoldenThingAdminClient::UpdateDatabaseDdl(google::test::admin::database::v1::UpdateDatabaseDdlRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->UpdateDatabaseDdl(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::UpdateDatabaseDdl(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::UpdateDatabaseDdlRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->UpdateDatabaseDdl(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::UpdateDatabaseDdlMetadata>>
GoldenThingAdminClient::UpdateDatabaseDdl(ExperimentalTag, google::longrunning::Operation const& operation, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->UpdateDatabaseDdl(ExperimentalTag{}, operation);
}

Status
GoldenThingAdminClient::DropDatabase(std::string const& database, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
Expand Down Expand Up @@ -208,12 +250,34 @@ GoldenThingAdminClient::CreateBackup(std::string const& parent, google::test::ad
return connection_->CreateBackup(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::CreateBackup(ExperimentalTag, NoAwaitTag, std::string const& parent, google::test::admin::database::v1::Backup const& backup, std::string const& backup_id, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::test::admin::database::v1::CreateBackupRequest request;
request.set_parent(parent);
*request.mutable_backup() = backup;
request.set_backup_id(backup_id);
return connection_->CreateBackup(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::Backup>>
GoldenThingAdminClient::CreateBackup(google::test::admin::database::v1::CreateBackupRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->CreateBackup(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::CreateBackup(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::CreateBackupRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->CreateBackup(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::Backup>>
GoldenThingAdminClient::CreateBackup(ExperimentalTag, google::longrunning::Operation const& operation, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->CreateBackup(ExperimentalTag{}, operation);
}

StatusOr<google::test::admin::database::v1::Backup>
GoldenThingAdminClient::GetBackup(std::string const& name, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
Expand Down Expand Up @@ -281,12 +345,34 @@ GoldenThingAdminClient::RestoreDatabase(std::string const& parent, std::string c
return connection_->RestoreDatabase(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::RestoreDatabase(ExperimentalTag, NoAwaitTag, std::string const& parent, std::string const& database_id, std::string const& backup, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::test::admin::database::v1::RestoreDatabaseRequest request;
request.set_parent(parent);
request.set_database_id(database_id);
request.set_backup(backup);
return connection_->RestoreDatabase(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::Database>>
GoldenThingAdminClient::RestoreDatabase(google::test::admin::database::v1::RestoreDatabaseRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->RestoreDatabase(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::RestoreDatabase(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::RestoreDatabaseRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->RestoreDatabase(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::Database>>
GoldenThingAdminClient::RestoreDatabase(ExperimentalTag, google::longrunning::Operation const& operation, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->RestoreDatabase(ExperimentalTag{}, operation);
}

StreamRange<google::longrunning::Operation>
GoldenThingAdminClient::ListDatabaseOperations(std::string const& parent, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
Expand Down Expand Up @@ -321,6 +407,18 @@ GoldenThingAdminClient::LongRunningWithoutRouting(google::test::admin::database:
return connection_->LongRunningWithoutRouting(request);
}

StatusOr<google::longrunning::Operation>
GoldenThingAdminClient::LongRunningWithoutRouting(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::RestoreDatabaseRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->LongRunningWithoutRouting(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::admin::database::v1::Database>>
GoldenThingAdminClient::LongRunningWithoutRouting(ExperimentalTag, google::longrunning::Operation const& operation, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->LongRunningWithoutRouting(ExperimentalTag{}, operation);
}

future<StatusOr<google::test::admin::database::v1::Database>>
GoldenThingAdminClient::AsyncGetDatabase(std::string const& name, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
Expand Down
44 changes: 44 additions & 0 deletions generator/integration_tests/golden/v1/golden_thing_admin_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_V1_GOLDEN_THING_ADMIN_CLIENT_H

#include "generator/integration_tests/golden/v1/golden_thing_admin_connection.h"
#include "google/cloud/experimental_tag.h"
#include "google/cloud/future.h"
#include "google/cloud/internal/make_status.h"
#include "google/cloud/no_await_tag.h"
#include "google/cloud/options.h"
#include "google/cloud/polling_policy.h"
#include "google/cloud/status_or.h"
Expand Down Expand Up @@ -213,6 +215,9 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::Database>>
CreateDatabase(std::string const& parent, std::string const& create_statement, Options opts = {});

StatusOr<google::longrunning::Operation>
CreateDatabase(ExperimentalTag, NoAwaitTag, std::string const& parent, std::string const& create_statement, Options opts = {});

// clang-format off
///
/// Creates a new Cloud Test database and starts to prepare it for serving.
Expand Down Expand Up @@ -261,6 +266,12 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::Database>>
CreateDatabase(google::test::admin::database::v1::CreateDatabaseRequest const& request, Options opts = {});

StatusOr<google::longrunning::Operation>
CreateDatabase(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::CreateDatabaseRequest const& request, Options opts = {});

future<StatusOr<google::test::admin::database::v1::Database>>
CreateDatabase(ExperimentalTag, google::longrunning::Operation const& operation, Options opts = {});

// clang-format off
///
/// Gets the state of a Cloud Test database.
Expand Down Expand Up @@ -359,6 +370,9 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::UpdateDatabaseDdlMetadata>>
UpdateDatabaseDdl(std::string const& database, std::vector<std::string> const& statements, Options opts = {});

StatusOr<google::longrunning::Operation>
UpdateDatabaseDdl(ExperimentalTag, NoAwaitTag, std::string const& database, std::vector<std::string> const& statements, Options opts = {});

// clang-format off
///
/// Updates the schema of a Cloud Test database by
Expand Down Expand Up @@ -405,6 +419,12 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::UpdateDatabaseDdlMetadata>>
UpdateDatabaseDdl(google::test::admin::database::v1::UpdateDatabaseDdlRequest const& request, Options opts = {});

StatusOr<google::longrunning::Operation>
UpdateDatabaseDdl(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::UpdateDatabaseDdlRequest const& request, Options opts = {});

future<StatusOr<google::test::admin::database::v1::UpdateDatabaseDdlMetadata>>
UpdateDatabaseDdl(ExperimentalTag, google::longrunning::Operation const& operation, Options opts = {});

// clang-format off
///
/// Drops (aka deletes) a Cloud Test database.
Expand Down Expand Up @@ -822,6 +842,9 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::Backup>>
CreateBackup(std::string const& parent, google::test::admin::database::v1::Backup const& backup, std::string const& backup_id, Options opts = {});

StatusOr<google::longrunning::Operation>
CreateBackup(ExperimentalTag, NoAwaitTag, std::string const& parent, google::test::admin::database::v1::Backup const& backup, std::string const& backup_id, Options opts = {});

// clang-format off
///
/// Starts creating a new Cloud Test Backup.
Expand Down Expand Up @@ -874,6 +897,12 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::Backup>>
CreateBackup(google::test::admin::database::v1::CreateBackupRequest const& request, Options opts = {});

StatusOr<google::longrunning::Operation>
CreateBackup(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::CreateBackupRequest const& request, Options opts = {});

future<StatusOr<google::test::admin::database::v1::Backup>>
CreateBackup(ExperimentalTag, google::longrunning::Operation const& operation, Options opts = {});

// clang-format off
///
/// Gets metadata on a pending or completed
Expand Down Expand Up @@ -1193,6 +1222,9 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::Database>>
RestoreDatabase(std::string const& parent, std::string const& database_id, std::string const& backup, Options opts = {});

StatusOr<google::longrunning::Operation>
RestoreDatabase(ExperimentalTag, NoAwaitTag, std::string const& parent, std::string const& database_id, std::string const& backup, Options opts = {});

// clang-format off
///
/// Create a new database by restoring from a completed backup. The new
Expand Down Expand Up @@ -1250,6 +1282,12 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::Database>>
RestoreDatabase(google::test::admin::database::v1::RestoreDatabaseRequest const& request, Options opts = {});

StatusOr<google::longrunning::Operation>
RestoreDatabase(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::RestoreDatabaseRequest const& request, Options opts = {});

future<StatusOr<google::test::admin::database::v1::Database>>
RestoreDatabase(ExperimentalTag, google::longrunning::Operation const& operation, Options opts = {});

// clang-format off
///
/// Lists database [longrunning-operations][google.longrunning.Operation].
Expand Down Expand Up @@ -1471,6 +1509,12 @@ class GoldenThingAdminClient {
future<StatusOr<google::test::admin::database::v1::Database>>
LongRunningWithoutRouting(google::test::admin::database::v1::RestoreDatabaseRequest const& request, Options opts = {});

StatusOr<google::longrunning::Operation>
LongRunningWithoutRouting(ExperimentalTag, NoAwaitTag, google::test::admin::database::v1::RestoreDatabaseRequest const& request, Options opts = {});

future<StatusOr<google::test::admin::database::v1::Database>>
LongRunningWithoutRouting(ExperimentalTag, google::longrunning::Operation const& operation, Options opts = {});

// clang-format off
///
/// Gets the state of a Cloud Test database.
Expand Down
21 changes: 21 additions & 0 deletions generator/integration_tests/golden/v1/request_id_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,33 @@ RequestIdServiceClient::RenameFoo(std::string const& name, std::string const& de
return connection_->RenameFoo(request);
}

StatusOr<google::longrunning::Operation>
RequestIdServiceClient::RenameFoo(ExperimentalTag, NoAwaitTag, std::string const& name, std::string const& destination_foo_id, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
google::test::requestid::v1::RenameFooRequest request;
request.set_name(name);
request.set_destination_foo_id(destination_foo_id);
return connection_->RenameFoo(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::requestid::v1::Foo>>
RequestIdServiceClient::RenameFoo(google::test::requestid::v1::RenameFooRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->RenameFoo(request);
}

StatusOr<google::longrunning::Operation>
RequestIdServiceClient::RenameFoo(ExperimentalTag, NoAwaitTag, google::test::requestid::v1::RenameFooRequest const& request, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->RenameFoo(ExperimentalTag{}, NoAwaitTag{}, request);
}

future<StatusOr<google::test::requestid::v1::Foo>>
RequestIdServiceClient::RenameFoo(ExperimentalTag, google::longrunning::Operation const& operation, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
return connection_->RenameFoo(ExperimentalTag{}, operation);
}

StreamRange<google::test::requestid::v1::Foo>
RequestIdServiceClient::ListFoos(std::string const& parent, Options opts) {
internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_));
Expand Down
11 changes: 11 additions & 0 deletions generator/integration_tests/golden/v1/request_id_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#define GOOGLE_CLOUD_CPP_GENERATOR_INTEGRATION_TESTS_GOLDEN_V1_REQUEST_ID_CLIENT_H

#include "generator/integration_tests/golden/v1/request_id_connection.h"
#include "google/cloud/experimental_tag.h"
#include "google/cloud/future.h"
#include "google/cloud/no_await_tag.h"
#include "google/cloud/options.h"
#include "google/cloud/polling_policy.h"
#include "google/cloud/status_or.h"
Expand Down Expand Up @@ -173,6 +175,9 @@ class RequestIdServiceClient {
future<StatusOr<google::test::requestid::v1::Foo>>
RenameFoo(std::string const& name, std::string const& destination_foo_id, Options opts = {});

StatusOr<google::longrunning::Operation>
RenameFoo(ExperimentalTag, NoAwaitTag, std::string const& name, std::string const& destination_foo_id, Options opts = {});

// clang-format off
///
/// Renames a `Foo`.
Expand Down Expand Up @@ -210,6 +215,12 @@ class RequestIdServiceClient {
future<StatusOr<google::test::requestid::v1::Foo>>
RenameFoo(google::test::requestid::v1::RenameFooRequest const& request, Options opts = {});

StatusOr<google::longrunning::Operation>
RenameFoo(ExperimentalTag, NoAwaitTag, google::test::requestid::v1::RenameFooRequest const& request, Options opts = {});

future<StatusOr<google::test::requestid::v1::Foo>>
RenameFoo(ExperimentalTag, google::longrunning::Operation const& operation, Options opts = {});

// clang-format off
///
/// Retrieves a list of foos for a given parent.
Expand Down
Loading

0 comments on commit 42336db

Please sign in to comment.