Skip to content

Commit a4130df

Browse files
authored
impl(generator): refactor generated rest stub to use EndpointOption (#10273)
1 parent d46656c commit a4130df

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

generator/integration_tests/golden/internal/golden_kitchen_sink_rest_stub.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// source: generator/integration_tests/test.proto
1818

1919
#include "generator/integration_tests/golden/internal/golden_kitchen_sink_rest_stub.h"
20+
#include "google/cloud/common_options.h"
2021
#include "google/cloud/internal/absl_str_cat_quiet.h"
2122
#include "google/cloud/internal/rest_stub_helpers.h"
2223
#include "google/cloud/status_or.h"
@@ -30,7 +31,7 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3031

3132
DefaultGoldenKitchenSinkRestStub::DefaultGoldenKitchenSinkRestStub(Options options)
3233
: rest_client_(rest_internal::MakePooledRestClient(
33-
"https://goldenkitchensink.googleapis.com", options)),
34+
options.get<EndpointOption>(), options)),
3435
options_(std::move(options)) {}
3536

3637
DefaultGoldenKitchenSinkRestStub::DefaultGoldenKitchenSinkRestStub(

generator/integration_tests/golden/internal/golden_thing_admin_rest_stub.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// source: generator/integration_tests/test.proto
1818

1919
#include "generator/integration_tests/golden/internal/golden_thing_admin_rest_stub.h"
20+
#include "google/cloud/common_options.h"
2021
#include "google/cloud/internal/absl_str_cat_quiet.h"
2122
#include "google/cloud/internal/rest_stub_helpers.h"
2223
#include "google/cloud/status_or.h"
@@ -31,7 +32,7 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3132

3233
DefaultGoldenThingAdminRestStub::DefaultGoldenThingAdminRestStub(Options options)
3334
: rest_client_(rest_internal::MakePooledRestClient(
34-
"https://test.googleapis.com", options)),
35+
options.get<EndpointOption>(), options)),
3536
options_(std::move(options)) {}
3637

3738
DefaultGoldenThingAdminRestStub::DefaultGoldenThingAdminRestStub(

generator/internal/stub_rest_generator.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ Status StubRestGenerator::GenerateCc() {
141141

142142
CcPrint("\n");
143143
CcLocalIncludes({vars("stub_rest_header_path"),
144+
"google/cloud/common_options.h",
144145
"google/cloud/internal/absl_str_cat_quiet.h",
145146
"google/cloud/internal/rest_stub_helpers.h",
146147
"google/cloud/status_or.h"});
@@ -152,11 +153,10 @@ Status StubRestGenerator::GenerateCc() {
152153
auto result = CcOpenNamespaces(NamespaceType::kInternal);
153154
if (!result.ok()) return result;
154155

155-
// TODO(#10214): Emit code to check options for a potential endpoint override.
156156
CcPrint(R"""(
157157
Default$stub_rest_class_name$::Default$stub_rest_class_name$(Options options)
158158
: rest_client_(rest_internal::MakePooledRestClient(
159-
"https://$service_endpoint$", options)),
159+
options.get<EndpointOption>(), options)),
160160
options_(std::move(options)) {}
161161
162162
Default$stub_rest_class_name$::Default$stub_rest_class_name$(

0 commit comments

Comments
 (0)