Skip to content

Commit 438de63

Browse files
authored
refactor(generator): prepare for dynamic query params (#14596)
1 parent 10453de commit 438de63

File tree

123 files changed

+7299
-3524
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+7299
-3524
lines changed

generator/integration_tests/golden/v1/internal/golden_kitchen_sink_rest_stub.cc

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,78 +46,87 @@ DefaultGoldenKitchenSinkRestStub::GenerateAccessToken(
4646
google::cloud::rest_internal::RestContext& rest_context,
4747
Options const& options,
4848
google::test::admin::database::v1::GenerateAccessTokenRequest const& request) {
49+
std::vector<std::pair<std::string, std::string>> query_params;
4950
return rest_internal::Post<google::test::admin::database::v1::GenerateAccessTokenResponse>(
5051
*service_, rest_context, request, false,
51-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.name(), ":generateAccessToken"));
52+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.name(), ":generateAccessToken"), std::move(query_params));
5253
}
5354

5455
StatusOr<google::test::admin::database::v1::GenerateIdTokenResponse>
5556
DefaultGoldenKitchenSinkRestStub::GenerateIdToken(
5657
google::cloud::rest_internal::RestContext& rest_context,
5758
Options const& options,
5859
google::test::admin::database::v1::GenerateIdTokenRequest const& request) {
60+
std::vector<std::pair<std::string, std::string>> query_params;
5961
return rest_internal::Post<google::test::admin::database::v1::GenerateIdTokenResponse>(
6062
*service_, rest_context, request, false,
61-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "token", ":generate"));
63+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "token", ":generate"), std::move(query_params));
6264
}
6365

6466
StatusOr<google::test::admin::database::v1::WriteLogEntriesResponse>
6567
DefaultGoldenKitchenSinkRestStub::WriteLogEntries(
6668
google::cloud::rest_internal::RestContext& rest_context,
6769
Options const& options,
6870
google::test::admin::database::v1::WriteLogEntriesRequest const& request) {
71+
std::vector<std::pair<std::string, std::string>> query_params;
6972
return rest_internal::Post<google::test::admin::database::v1::WriteLogEntriesResponse>(
7073
*service_, rest_context, request, false,
71-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "entries", ":write"));
74+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "entries", ":write"), std::move(query_params));
7275
}
7376

7477
StatusOr<google::test::admin::database::v1::ListLogsResponse>
7578
DefaultGoldenKitchenSinkRestStub::ListLogs(
7679
google::cloud::rest_internal::RestContext& rest_context,
7780
Options const& options,
7881
google::test::admin::database::v1::ListLogsRequest const& request) {
82+
std::vector<std::pair<std::string, std::string>> query_params;
83+
query_params.push_back({"page_size", std::to_string(request.page_size())});
84+
query_params.push_back({"page_token", request.page_token()});
85+
query_params = rest_internal::TrimEmptyQueryParameters(std::move(query_params));
7986
return rest_internal::Get<google::test::admin::database::v1::ListLogsResponse>(
8087
*service_, rest_context, request, false,
81-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.parent(), "/", "logs"),
82-
rest_internal::TrimEmptyQueryParameters({std::make_pair("page_size", std::to_string(request.page_size())),
83-
std::make_pair("page_token", request.page_token())}));
88+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.parent(), "/", "logs"), std::move(query_params));
8489
}
8590

8691
StatusOr<google::test::admin::database::v1::ListServiceAccountKeysResponse>
8792
DefaultGoldenKitchenSinkRestStub::ListServiceAccountKeys(
8893
google::cloud::rest_internal::RestContext& rest_context,
8994
Options const& options,
9095
google::test::admin::database::v1::ListServiceAccountKeysRequest const& request) {
96+
std::vector<std::pair<std::string, std::string>> query_params;
9197
return rest_internal::Get<google::test::admin::database::v1::ListServiceAccountKeysResponse>(
9298
*service_, rest_context, request, false,
93-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.name(), "/", "keys"));
99+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.name(), "/", "keys"), std::move(query_params));
94100
}
95101

96102
Status DefaultGoldenKitchenSinkRestStub::DoNothing(
97103
google::cloud::rest_internal::RestContext& rest_context,
98104
Options const& options,
99105
google::protobuf::Empty const& request) {
106+
std::vector<std::pair<std::string, std::string>> query_params;
100107
return rest_internal::Post<google::cloud::rest_internal::EmptyResponseType>(
101108
*service_, rest_context, request, false,
102-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "doNothing"));
109+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "doNothing"), std::move(query_params));
103110
}
104111

105112
Status DefaultGoldenKitchenSinkRestStub::ExplicitRouting1(
106113
google::cloud::rest_internal::RestContext& rest_context,
107114
Options const& options,
108115
google::test::admin::database::v1::ExplicitRoutingRequest const& request) {
116+
std::vector<std::pair<std::string, std::string>> query_params;
109117
return rest_internal::Post<google::cloud::rest_internal::EmptyResponseType>(
110118
*service_, rest_context, request, false,
111-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.table_name(), ":explicitRouting1"));
119+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.table_name(), ":explicitRouting1"), std::move(query_params));
112120
}
113121

114122
Status DefaultGoldenKitchenSinkRestStub::ExplicitRouting2(
115123
google::cloud::rest_internal::RestContext& rest_context,
116124
Options const& options,
117125
google::test::admin::database::v1::ExplicitRoutingRequest const& request) {
126+
std::vector<std::pair<std::string, std::string>> query_params;
118127
return rest_internal::Post<google::cloud::rest_internal::EmptyResponseType>(
119128
*service_, rest_context, request, false,
120-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.table_name(), ":explicitRouting2"));
129+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", request.table_name(), ":explicitRouting2"), std::move(query_params));
121130
}
122131

123132
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

generator/integration_tests/golden/v1/internal/golden_rest_only_rest_stub.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,10 @@ Status DefaultGoldenRestOnlyRestStub::Noop(
4545
google::cloud::rest_internal::RestContext& rest_context,
4646
Options const& options,
4747
google::protobuf::Empty const& request) {
48+
std::vector<std::pair<std::string, std::string>> query_params;
4849
return rest_internal::Post<google::cloud::rest_internal::EmptyResponseType>(
4950
*service_, rest_context, request, false,
50-
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "noop"));
51+
absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", "noop"), std::move(query_params));
5152
}
5253

5354
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

0 commit comments

Comments
 (0)