Skip to content

Commit 3a1e6ee

Browse files
authored
refactor(language): versioned clients (#10916)
1 parent 364ae3b commit 3a1e6ee

41 files changed

Lines changed: 1074 additions & 866 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
295 Bytes
Binary file not shown.

ci/etc/expected_install_directories

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,10 @@
294294
./include/google/cloud/kms/v1/internal
295295
./include/google/cloud/kms/v1/mocks
296296
./include/google/cloud/language
297-
./include/google/cloud/language/internal
298297
./include/google/cloud/language/mocks
299298
./include/google/cloud/language/v1
299+
./include/google/cloud/language/v1/internal
300+
./include/google/cloud/language/v1/mocks
300301
./include/google/cloud/logging
301302
./include/google/cloud/logging/internal
302303
./include/google/cloud/logging/mocks

generator/generator_config.textproto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,8 @@ service {
10761076
# Language
10771077
service {
10781078
service_proto_path: "google/cloud/language/v1/language_service.proto"
1079-
product_path: "google/cloud/language"
1079+
product_path: "google/cloud/language/v1"
1080+
forwarding_product_path: "google/cloud/language"
10801081
initial_copyright_year: "2022"
10811082
retryable_status_codes: ["kUnavailable"]
10821083
}

google/cloud/language/BUILD.bazel

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,26 @@ package(default_visibility = ["//visibility:private"])
1616

1717
licenses(["notice"]) # Apache 2.0
1818

19+
service_dirs = [
20+
"",
21+
"v1/",
22+
]
23+
24+
src_dirs = service_dirs + [d + "internal/" for d in service_dirs]
25+
1926
filegroup(
2027
name = "srcs",
21-
srcs = glob([
22-
"*.cc",
23-
"internal/*.cc",
24-
]),
28+
srcs = glob([d + "*.cc" for d in src_dirs]),
2529
)
2630

2731
filegroup(
2832
name = "hdrs",
29-
srcs = glob([
30-
"*.h",
31-
"internal/*.h",
32-
]),
33+
srcs = glob([d + "*.h" for d in src_dirs]),
3334
)
3435

3536
filegroup(
3637
name = "mocks",
37-
srcs = glob(["mocks/*.h"]),
38+
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
3839
)
3940

4041
cc_library(
@@ -58,3 +59,13 @@ cc_library(
5859
"@com_google_googletest//:gtest",
5960
],
6061
)
62+
63+
[cc_test(
64+
name = sample.replace("/", "_").replace(".cc", ""),
65+
srcs = [sample],
66+
tags = ["integration-test"],
67+
deps = [
68+
"//:language",
69+
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
70+
],
71+
) for sample in glob([d + "samples/*.cc" for d in service_dirs])]

google/cloud/language/CMakeLists.txt

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,22 @@ set(DOXYGEN_PROJECT_NAME "Cloud Natural Language API C++ Client")
1919
set(DOXYGEN_PROJECT_BRIEF
2020
"A C++ Client Library for the Cloud Natural Language API")
2121
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}")
22-
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "language_internal" "language_testing"
23-
"examples")
24-
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/samples
25-
${CMAKE_CURRENT_SOURCE_DIR}/quickstart)
22+
set(DOXYGEN_EXCLUDE_SYMBOLS "internal")
23+
set(DOXYGEN_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/quickstart")
24+
25+
unset(mocks_globs)
26+
unset(source_globs)
27+
set(service_dirs "" "v1/")
28+
foreach (dir IN LISTS service_dirs)
29+
string(REPLACE "/" "_" ns "${dir}")
30+
list(APPEND source_globs "${dir}*.h" "${dir}*.cc" "${dir}internal/*")
31+
list(APPEND mocks_globs "${dir}mocks/*.h")
32+
list(APPEND DOXYGEN_EXCLUDE_SYMBOLS "language_${ns}internal")
33+
if (NOT dir STREQUAL "")
34+
list(APPEND DOXYGEN_EXAMPLE_PATH
35+
"${CMAKE_CURRENT_SOURCE_DIR}/${dir}samples")
36+
endif ()
37+
endforeach ()
2638

2739
include(GoogleCloudCppDoxygen)
2840
google_cloud_cpp_doxygen_targets("language" DEPENDS cloud-docs
@@ -48,7 +60,7 @@ target_link_libraries(google_cloud_cpp_language_protos PUBLIC ${proto_deps})
4860
file(
4961
GLOB source_files
5062
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
51-
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
63+
${source_globs})
5264
list(SORT source_files)
5365
add_library(google_cloud_cpp_language ${source_files})
5466
target_include_directories(
@@ -78,7 +90,7 @@ add_library(google-cloud-cpp::language ALIAS google_cloud_cpp_language)
7890
file(
7991
GLOB relative_mock_files
8092
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
81-
"mocks/*.h")
93+
${mocks_globs})
8294
list(SORT relative_mock_files)
8395
set(mock_files)
8496
foreach (file IN LISTS relative_mock_files)
@@ -180,3 +192,10 @@ install(
180192
COMPONENT google_cloud_cpp_development)
181193

182194
external_googleapis_install_pc("google_cloud_cpp_language_protos")
195+
196+
# google-cloud-cpp::language must be defined before we can add the samples.
197+
foreach (dir IN LISTS service_dirs)
198+
if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS)
199+
google_cloud_cpp_add_samples_relative("language" "${dir}samples/")
200+
endif ()
201+
endforeach ()

google/cloud/language/doc/main.dox

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ library. Use the `google::cloud::EndpointOption` when initializing the client
9494
library to change this default.
9595

9696
<!-- inject-endpoint-snippet-start -->
97-
For example, this will override the default endpoint for `language::LanguageServiceClient`:
97+
For example, this will override the default endpoint for `language_v1::LanguageServiceClient`:
9898

9999
@snippet language_client_samples.cc set-client-endpoint
100100

@@ -139,15 +139,15 @@ can override the default policies.
139139

140140
// <!-- inject-endpoint-pages-start -->
141141

142-
/*! @page language::LanguageServiceClient-endpoint-snippet Override language::LanguageServiceClient Endpoint Configuration
142+
/*! @page language_v1::LanguageServiceClient-endpoint-snippet Override language_v1::LanguageServiceClient Endpoint Configuration
143143

144-
@snippet google/cloud/language/samples/language_client_samples.cc set-client-endpoint
144+
@snippet google/cloud/language/v1/samples/language_client_samples.cc set-client-endpoint
145145

146146
*/
147147

148-
/*! @page language::LanguageServiceClient-service-account-snippet Override language::LanguageServiceClient Authentication Defaults
148+
/*! @page language_v1::LanguageServiceClient-service-account-snippet Override language_v1::LanguageServiceClient Authentication Defaults
149149

150-
@snippet google/cloud/language/samples/language_client_samples.cc with-service-account
150+
@snippet google/cloud/language/v1/samples/language_client_samples.cc with-service-account
151151

152152
*/
153153
// <!-- inject-endpoint-pages-end -->

0 commit comments

Comments
 (0)