Skip to content

Commit

Permalink
fix(generator): handle explicit routing params for nested fields (#9408)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolduc committed Jul 1, 2022
1 parent 36396e4 commit 548f0f1
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 90 deletions.
84 changes: 42 additions & 42 deletions generator/integration_tests/golden/golden_kitchen_sink_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,24 @@ class GoldenKitchenSinkClient {
/// hour.
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::GenerateAccessTokenResponse,generator/integration_tests/test.proto#L992}
/// @return @googleapis_link{google::test::admin::database::v1::GenerateAccessTokenResponse,generator/integration_tests/test.proto#L996}
///
/// [google.test.admin.database.v1.GenerateAccessTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L952}
/// [google.test.admin.database.v1.GenerateAccessTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L992}
/// [google.test.admin.database.v1.GenerateAccessTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L956}
/// [google.test.admin.database.v1.GenerateAccessTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L996}
///
StatusOr<google::test::admin::database::v1::GenerateAccessTokenResponse>
GenerateAccessToken(std::string const& name, std::vector<std::string> const& delegates, std::vector<std::string> const& scope, google::protobuf::Duration const& lifetime, Options opts = {});

///
/// Generates an OAuth 2.0 access token for a service account.
///
/// @param request @googleapis_link{google::test::admin::database::v1::GenerateAccessTokenRequest,generator/integration_tests/test.proto#L952}
/// @param request @googleapis_link{google::test::admin::database::v1::GenerateAccessTokenRequest,generator/integration_tests/test.proto#L956}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::GenerateAccessTokenResponse,generator/integration_tests/test.proto#L992}
/// @return @googleapis_link{google::test::admin::database::v1::GenerateAccessTokenResponse,generator/integration_tests/test.proto#L996}
///
/// [google.test.admin.database.v1.GenerateAccessTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L952}
/// [google.test.admin.database.v1.GenerateAccessTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L992}
/// [google.test.admin.database.v1.GenerateAccessTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L956}
/// [google.test.admin.database.v1.GenerateAccessTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L996}
///
StatusOr<google::test::admin::database::v1::GenerateAccessTokenResponse>
GenerateAccessToken(google::test::admin::database::v1::GenerateAccessTokenRequest const& request, Options opts = {});
Expand All @@ -154,24 +154,24 @@ class GoldenKitchenSinkClient {
/// token will contain `email` and `email_verified` claims.
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::GenerateIdTokenResponse,generator/integration_tests/test.proto#L1034}
/// @return @googleapis_link{google::test::admin::database::v1::GenerateIdTokenResponse,generator/integration_tests/test.proto#L1038}
///
/// [google.test.admin.database.v1.GenerateIdTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1001}
/// [google.test.admin.database.v1.GenerateIdTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1034}
/// [google.test.admin.database.v1.GenerateIdTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1005}
/// [google.test.admin.database.v1.GenerateIdTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1038}
///
StatusOr<google::test::admin::database::v1::GenerateIdTokenResponse>
GenerateIdToken(std::string const& name, std::vector<std::string> const& delegates, std::string const& audience, bool include_email, Options opts = {});

///
/// Generates an OpenID Connect ID token for a service account.
///
/// @param request @googleapis_link{google::test::admin::database::v1::GenerateIdTokenRequest,generator/integration_tests/test.proto#L1001}
/// @param request @googleapis_link{google::test::admin::database::v1::GenerateIdTokenRequest,generator/integration_tests/test.proto#L1005}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::GenerateIdTokenResponse,generator/integration_tests/test.proto#L1034}
/// @return @googleapis_link{google::test::admin::database::v1::GenerateIdTokenResponse,generator/integration_tests/test.proto#L1038}
///
/// [google.test.admin.database.v1.GenerateIdTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1001}
/// [google.test.admin.database.v1.GenerateIdTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1034}
/// [google.test.admin.database.v1.GenerateIdTokenRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1005}
/// [google.test.admin.database.v1.GenerateIdTokenResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1038}
///
StatusOr<google::test::admin::database::v1::GenerateIdTokenResponse>
GenerateIdToken(google::test::admin::database::v1::GenerateIdTokenRequest const& request, Options opts = {});
Expand Down Expand Up @@ -204,10 +204,10 @@ class GoldenKitchenSinkClient {
/// See [LogEntry][google.logging.v2.LogEntry]. Test delimiter$
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::WriteLogEntriesResponse,generator/integration_tests/test.proto#L1073}
/// @return @googleapis_link{google::test::admin::database::v1::WriteLogEntriesResponse,generator/integration_tests/test.proto#L1077}
///
/// [google.test.admin.database.v1.WriteLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1040}
/// [google.test.admin.database.v1.WriteLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1073}
/// [google.test.admin.database.v1.WriteLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1044}
/// [google.test.admin.database.v1.WriteLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1077}
///
StatusOr<google::test::admin::database::v1::WriteLogEntriesResponse>
WriteLogEntries(std::string const& log_name, std::map<std::string, std::string> const& labels, Options opts = {});
Expand All @@ -221,13 +221,13 @@ class GoldenKitchenSinkClient {
/// different resources (projects, organizations, billing accounts or
/// folders)
///
/// @param request @googleapis_link{google::test::admin::database::v1::WriteLogEntriesRequest,generator/integration_tests/test.proto#L1040}
/// @param request @googleapis_link{google::test::admin::database::v1::WriteLogEntriesRequest,generator/integration_tests/test.proto#L1044}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::WriteLogEntriesResponse,generator/integration_tests/test.proto#L1073}
/// @return @googleapis_link{google::test::admin::database::v1::WriteLogEntriesResponse,generator/integration_tests/test.proto#L1077}
///
/// [google.test.admin.database.v1.WriteLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1040}
/// [google.test.admin.database.v1.WriteLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1073}
/// [google.test.admin.database.v1.WriteLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1044}
/// [google.test.admin.database.v1.WriteLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1077}
///
StatusOr<google::test::admin::database::v1::WriteLogEntriesResponse>
WriteLogEntries(google::test::admin::database::v1::WriteLogEntriesRequest const& request, Options opts = {});
Expand All @@ -245,7 +245,7 @@ class GoldenKitchenSinkClient {
/// backoff policies.
/// @return std::string
///
/// [google.test.admin.database.v1.ListLogsRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1076}
/// [google.test.admin.database.v1.ListLogsRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1080}
///
StreamRange<std::string>
ListLogs(std::string const& parent, Options opts = {});
Expand All @@ -254,12 +254,12 @@ class GoldenKitchenSinkClient {
/// Lists the logs in projects, organizations, folders, or billing accounts.
/// Only logs that have entries are listed.
///
/// @param request @googleapis_link{google::test::admin::database::v1::ListLogsRequest,generator/integration_tests/test.proto#L1076}
/// @param request @googleapis_link{google::test::admin::database::v1::ListLogsRequest,generator/integration_tests/test.proto#L1080}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return std::string
///
/// [google.test.admin.database.v1.ListLogsRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1076}
/// [google.test.admin.database.v1.ListLogsRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1080}
///
StreamRange<std::string>
ListLogs(google::test::admin::database::v1::ListLogsRequest request, Options opts = {});
Expand All @@ -280,10 +280,10 @@ class GoldenKitchenSinkClient {
/// "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]"
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::TailLogEntriesResponse,generator/integration_tests/test.proto#L1334}
/// @return @googleapis_link{google::test::admin::database::v1::TailLogEntriesResponse,generator/integration_tests/test.proto#L1338}
///
/// [google.test.admin.database.v1.TailLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1302}
/// [google.test.admin.database.v1.TailLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1334}
/// [google.test.admin.database.v1.TailLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1306}
/// [google.test.admin.database.v1.TailLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1338}
///
StreamRange<google::test::admin::database::v1::TailLogEntriesResponse>
TailLogEntries(std::vector<std::string> const& resource_names, Options opts = {});
Expand All @@ -292,13 +292,13 @@ class GoldenKitchenSinkClient {
/// Streaming read of log entries as they are ingested. Until the stream is
/// terminated, it will continue reading logs.
///
/// @param request @googleapis_link{google::test::admin::database::v1::TailLogEntriesRequest,generator/integration_tests/test.proto#L1302}
/// @param request @googleapis_link{google::test::admin::database::v1::TailLogEntriesRequest,generator/integration_tests/test.proto#L1306}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::TailLogEntriesResponse,generator/integration_tests/test.proto#L1334}
/// @return @googleapis_link{google::test::admin::database::v1::TailLogEntriesResponse,generator/integration_tests/test.proto#L1338}
///
/// [google.test.admin.database.v1.TailLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1302}
/// [google.test.admin.database.v1.TailLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1334}
/// [google.test.admin.database.v1.TailLogEntriesRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1306}
/// [google.test.admin.database.v1.TailLogEntriesResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1338}
///
StreamRange<google::test::admin::database::v1::TailLogEntriesResponse>
TailLogEntries(google::test::admin::database::v1::TailLogEntriesRequest const& request, Options opts = {});
Expand All @@ -316,24 +316,24 @@ class GoldenKitchenSinkClient {
/// is provided, all keys are returned.
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::ListServiceAccountKeysResponse,generator/integration_tests/test.proto#L1406}
/// @return @googleapis_link{google::test::admin::database::v1::ListServiceAccountKeysResponse,generator/integration_tests/test.proto#L1410}
///
/// [google.test.admin.database.v1.ListServiceAccountKeysRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1374}
/// [google.test.admin.database.v1.ListServiceAccountKeysResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1406}
/// [google.test.admin.database.v1.ListServiceAccountKeysRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1378}
/// [google.test.admin.database.v1.ListServiceAccountKeysResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1410}
///
StatusOr<google::test::admin::database::v1::ListServiceAccountKeysResponse>
ListServiceAccountKeys(std::string const& name, std::vector<google::test::admin::database::v1::ListServiceAccountKeysRequest::KeyType> const& key_types, Options opts = {});

///
/// Lists every [ServiceAccountKey][google.iam.admin.v1.ServiceAccountKey] for a service account.
///
/// @param request @googleapis_link{google::test::admin::database::v1::ListServiceAccountKeysRequest,generator/integration_tests/test.proto#L1374}
/// @param request @googleapis_link{google::test::admin::database::v1::ListServiceAccountKeysRequest,generator/integration_tests/test.proto#L1378}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
/// @return @googleapis_link{google::test::admin::database::v1::ListServiceAccountKeysResponse,generator/integration_tests/test.proto#L1406}
/// @return @googleapis_link{google::test::admin::database::v1::ListServiceAccountKeysResponse,generator/integration_tests/test.proto#L1410}
///
/// [google.test.admin.database.v1.ListServiceAccountKeysRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1374}
/// [google.test.admin.database.v1.ListServiceAccountKeysResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1406}
/// [google.test.admin.database.v1.ListServiceAccountKeysRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1378}
/// [google.test.admin.database.v1.ListServiceAccountKeysResponse]: @googleapis_reference_link{generator/integration_tests/test.proto#L1410}
///
StatusOr<google::test::admin::database::v1::ListServiceAccountKeysResponse>
ListServiceAccountKeys(google::test::admin::database::v1::ListServiceAccountKeysRequest const& request, Options opts = {});
Expand Down Expand Up @@ -384,11 +384,11 @@ class GoldenKitchenSinkClient {
/// x-goog-request-params:
/// table_location=instances/instance_bar&routing_id=prof_qux
///
/// @param request @googleapis_link{google::test::admin::database::v1::ExplicitRoutingRequest,generator/integration_tests/test.proto#L1413}
/// @param request @googleapis_link{google::test::admin::database::v1::ExplicitRoutingRequest,generator/integration_tests/test.proto#L1417}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
///
/// [google.test.admin.database.v1.ExplicitRoutingRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1413}
/// [google.test.admin.database.v1.ExplicitRoutingRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1417}
///
Status
ExplicitRouting1(google::test::admin::database::v1::ExplicitRoutingRequest const& request, Options opts = {});
Expand All @@ -397,11 +397,11 @@ class GoldenKitchenSinkClient {
/// We use this RPC to verify the special case where a routing parameter key
/// does not require a regex in order to match the correct value.
///
/// @param request @googleapis_link{google::test::admin::database::v1::ExplicitRoutingRequest,generator/integration_tests/test.proto#L1413}
/// @param request @googleapis_link{google::test::admin::database::v1::ExplicitRoutingRequest,generator/integration_tests/test.proto#L1417}
/// @param opts Optional. Override the class-level options, such as retry and
/// backoff policies.
///
/// [google.test.admin.database.v1.ExplicitRoutingRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1413}
/// [google.test.admin.database.v1.ExplicitRoutingRequest]: @googleapis_reference_link{generator/integration_tests/test.proto#L1417}
///
Status
ExplicitRouting2(google::test::admin::database::v1::ExplicitRoutingRequest const& request, Options opts = {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ GoldenKitchenSinkMetadata::ExplicitRouting2(
grpc::ClientContext& context,
google::test::admin::database::v1::ExplicitRoutingRequest const& request) {
std::vector<std::string> params;
params.reserve(1);
params.reserve(2);

if (!request.app_profile_id().empty()) {
params.push_back("no_regex_needed=" + request.app_profile_id());
Expand All @@ -185,6 +185,10 @@ GoldenKitchenSinkMetadata::ExplicitRouting2(
params.push_back("no_regex_needed=" + request.no_regex_needed());
}

if (!request.nested1().nested2().value().empty()) {
params.push_back("routing_id=" + request.nested1().nested2().value());
}

if (params.empty()) {
SetMetadata(context);
} else {
Expand Down
Loading

0 comments on commit 548f0f1

Please sign in to comment.