Skip to content

Commit ebc8f09

Browse files
authored
feat(networkmanagement): generate library (#8047)
1 parent db1ef0e commit ebc8f09

40 files changed

+3601
-0
lines changed

BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,20 @@ cc_library(
348348
],
349349
)
350350

351+
cc_library(
352+
name = "experimental-networkmanagement",
353+
deps = [
354+
"//google/cloud/networkmanagement:google_cloud_cpp_networkmanagement",
355+
],
356+
)
357+
358+
cc_library(
359+
name = "experimental-networkmanagement_mocks",
360+
deps = [
361+
"//google/cloud/networkmanagement:google_cloud_cpp_networkmanagement_mocks",
362+
],
363+
)
364+
351365
cc_library(
352366
name = "experimental-notebooks",
353367
deps = [

ci/etc/expected_install_directories

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
./include/google/cloud/logging
9797
./include/google/cloud/logging/internal
9898
./include/google/cloud/logging/mocks
99+
./include/google/cloud/networkmanagement
100+
./include/google/cloud/networkmanagement/internal
101+
./include/google/cloud/networkmanagement/mocks
102+
./include/google/cloud/networkmanagement/v1
99103
./include/google/cloud/notebooks
100104
./include/google/cloud/notebooks/internal
101105
./include/google/cloud/notebooks/mocks
@@ -262,6 +266,7 @@
262266
./lib64/cmake/google_cloud_cpp_iot
263267
./lib64/cmake/google_cloud_cpp_kms
264268
./lib64/cmake/google_cloud_cpp_logging
269+
./lib64/cmake/google_cloud_cpp_networkmanagement
265270
./lib64/cmake/google_cloud_cpp_notebooks
266271
./lib64/cmake/google_cloud_cpp_orgpolicy
267272
./lib64/cmake/google_cloud_cpp_oslogin

ci/etc/full_feature_list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ids
1919
iot
2020
kms
2121
logging
22+
networkmanagement
2223
notebooks
2324
orgpolicy
2425
oslogin
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@com_google_googleapis//google/api:annotations_proto
2+
@com_google_googleapis//google/api:client_proto
3+
@com_google_googleapis//google/api:field_behavior_proto
4+
@com_google_googleapis//google/api:http_proto
5+
@com_google_googleapis//google/api:resource_proto
6+
@com_google_googleapis//google/longrunning:operations_proto
7+
@com_google_googleapis//google/rpc:status_proto
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@com_google_googleapis//google/cloud/networkmanagement/v1:connectivity_test.proto
2+
@com_google_googleapis//google/cloud/networkmanagement/v1:reachability.proto
3+
@com_google_googleapis//google/cloud/networkmanagement/v1:trace.proto

external/googleapis/update_libraries.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ declare -A -r LIBRARIES=(
8383
["logging_type"]="@com_google_googleapis//google/logging/type:type_cc_grpc"
8484
["logging"]="@com_google_googleapis//google/logging/v2:logging_cc_grpc"
8585
["monitoring"]="@com_google_googleapis//google/monitoring/v3:monitoring_cc_grpc"
86+
["networkmanagement"]="@com_google_googleapis//google/cloud/networkmanagement/v1:networkmanagement_cc_grpc"
8687
["notebooks"]="@com_google_googleapis//google/cloud/notebooks/v1:notebooks_cc_grpc"
8788
["orgpolicy"]="@com_google_googleapis//google/cloud/orgpolicy/v2:orgpolicy_cc_grpc"
8889
["oslogin"]="$(

generator/generator_config.textproto

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ service {
289289
retryable_status_codes: ["kInternal", "kDeadlineExceeded", "kUnavailable"]
290290
}
291291

292+
# Network Management
293+
service {
294+
service_proto_path: "google/cloud/networkmanagement/v1/reachability.proto"
295+
product_path: "google/cloud/networkmanagement"
296+
initial_copyright_year: "2022"
297+
retryable_status_codes: ["kUnavailable"]
298+
}
299+
292300
# Notebooks
293301
service {
294302
service_proto_path: "google/cloud/notebooks/v1/managed_service.proto"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
package(default_visibility = ["//visibility:private"])
16+
17+
licenses(["notice"]) # Apache 2.0
18+
19+
SOURCE_GLOB = "**/*.cc"
20+
21+
MOCK_SOURCE_GLOB = "mocks/*.cc"
22+
23+
HEADER_GLOB = "**/*.h"
24+
25+
MOCK_HEADER_GLOB = "mocks/*.h"
26+
27+
cc_library(
28+
name = "google_cloud_cpp_networkmanagement",
29+
srcs = glob(
30+
include = [SOURCE_GLOB],
31+
exclude = [MOCK_SOURCE_GLOB],
32+
),
33+
hdrs = glob(
34+
include = [HEADER_GLOB],
35+
exclude = [MOCK_HEADER_GLOB],
36+
),
37+
visibility = ["//:__pkg__"],
38+
deps = [
39+
"//google/cloud:google_cloud_cpp_common",
40+
"//google/cloud:google_cloud_cpp_grpc_utils",
41+
"@com_google_googleapis//google/cloud/networkmanagement/v1:networkmanagement_cc_grpc",
42+
],
43+
)
44+
45+
cc_library(
46+
name = "google_cloud_cpp_networkmanagement_mocks",
47+
srcs = glob(
48+
include = [MOCK_SOURCE_GLOB],
49+
),
50+
hdrs = glob(
51+
include = [MOCK_HEADER_GLOB],
52+
),
53+
visibility = ["//:__pkg__"],
54+
deps = [
55+
":google_cloud_cpp_networkmanagement",
56+
"//google/cloud:google_cloud_cpp_common",
57+
"//google/cloud:google_cloud_cpp_grpc_utils",
58+
],
59+
)
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# ~~~
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ~~~
16+
17+
include(GoogleapisConfig)
18+
set(DOXYGEN_PROJECT_NAME "Network Management API C++ Client")
19+
set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the Network Management API")
20+
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
21+
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "networkmanagement_internal"
22+
"networkmanagement_testing" "examples")
23+
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quickstart)
24+
25+
# Creates the proto headers needed by doxygen.
26+
set(GOOGLE_CLOUD_CPP_DOXYGEN_DEPS google-cloud-cpp::networkmanagement_protos)
27+
28+
find_package(gRPC REQUIRED)
29+
find_package(ProtobufWithTargets REQUIRED)
30+
find_package(absl CONFIG REQUIRED)
31+
32+
include(GoogleCloudCppCommon)
33+
34+
set(EXTERNAL_GOOGLEAPIS_SOURCE
35+
"${PROJECT_BINARY_DIR}/external/googleapis/src/googleapis_download")
36+
find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto)
37+
if (PROTO_INCLUDE_DIR)
38+
list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}")
39+
endif ()
40+
41+
include(CompileProtos)
42+
google_cloud_cpp_grpcpp_library(
43+
google_cloud_cpp_networkmanagement_protos
44+
# cmake-format: sort
45+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/networkmanagement/v1/connectivity_test.proto
46+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/networkmanagement/v1/reachability.proto
47+
${EXTERNAL_GOOGLEAPIS_SOURCE}/google/cloud/networkmanagement/v1/trace.proto
48+
PROTO_PATH_DIRECTORIES
49+
"${EXTERNAL_GOOGLEAPIS_SOURCE}"
50+
"${PROTO_INCLUDE_DIR}")
51+
external_googleapis_set_version_and_alias(networkmanagement_protos)
52+
target_link_libraries(
53+
google_cloud_cpp_networkmanagement_protos
54+
PUBLIC #
55+
google-cloud-cpp::api_annotations_protos
56+
google-cloud-cpp::api_client_protos
57+
google-cloud-cpp::api_field_behavior_protos
58+
google-cloud-cpp::api_http_protos
59+
google-cloud-cpp::api_resource_protos
60+
google-cloud-cpp::longrunning_operations_protos
61+
google-cloud-cpp::rpc_status_protos)
62+
63+
file(
64+
GLOB source_files
65+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
66+
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
67+
list(SORT source_files)
68+
add_library(google_cloud_cpp_networkmanagement ${source_files})
69+
target_include_directories(
70+
google_cloud_cpp_networkmanagement
71+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
72+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
73+
$<INSTALL_INTERFACE:include>)
74+
target_link_libraries(
75+
google_cloud_cpp_networkmanagement
76+
PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
77+
google-cloud-cpp::networkmanagement_protos)
78+
google_cloud_cpp_add_common_options(google_cloud_cpp_networkmanagement)
79+
set_target_properties(
80+
google_cloud_cpp_networkmanagement
81+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-networkmanagement
82+
VERSION "${PROJECT_VERSION}" SOVERSION
83+
"${PROJECT_VERSION_MAJOR}")
84+
target_compile_options(google_cloud_cpp_networkmanagement
85+
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
86+
87+
add_library(google-cloud-cpp::experimental-networkmanagement ALIAS
88+
google_cloud_cpp_networkmanagement)
89+
90+
# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
91+
# for these, a regular library would not work on macOS (where the library needs
92+
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
93+
# that they need absolute paths for their sources.
94+
file(
95+
GLOB relative_mock_files
96+
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
97+
"mocks/*.h")
98+
list(SORT relative_mock_files)
99+
set(mock_files)
100+
foreach (file IN LISTS relative_mock_files)
101+
list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
102+
endforeach ()
103+
add_library(google_cloud_cpp_networkmanagement_mocks INTERFACE)
104+
target_sources(google_cloud_cpp_networkmanagement_mocks INTERFACE ${mock_files})
105+
target_link_libraries(
106+
google_cloud_cpp_networkmanagement_mocks
107+
INTERFACE google-cloud-cpp::experimental-networkmanagement
108+
GTest::gmock_main GTest::gmock GTest::gtest)
109+
set_target_properties(
110+
google_cloud_cpp_networkmanagement_mocks
111+
PROPERTIES EXPORT_NAME
112+
google-cloud-cpp::experimental-networkmanagement_mocks)
113+
target_include_directories(
114+
google_cloud_cpp_networkmanagement_mocks
115+
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
116+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
117+
$<INSTALL_INTERFACE:include>)
118+
target_compile_options(google_cloud_cpp_networkmanagement_mocks
119+
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
120+
121+
# Get the destination directories based on the GNU recommendations.
122+
include(GNUInstallDirs)
123+
124+
# Export the CMake targets to make it easy to create configuration files.
125+
install(
126+
EXPORT google_cloud_cpp_networkmanagement-targets
127+
DESTINATION
128+
"${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_networkmanagement"
129+
COMPONENT google_cloud_cpp_development)
130+
131+
# Install the libraries and headers in the locations determined by
132+
# GNUInstallDirs
133+
install(
134+
TARGETS google_cloud_cpp_networkmanagement
135+
google_cloud_cpp_networkmanagement_protos
136+
EXPORT google_cloud_cpp_networkmanagement-targets
137+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
138+
COMPONENT google_cloud_cpp_runtime
139+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
140+
COMPONENT google_cloud_cpp_runtime
141+
NAMELINK_SKIP
142+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
143+
COMPONENT google_cloud_cpp_development)
144+
# With CMake-3.12 and higher we could avoid this separate command (and the
145+
# duplication).
146+
install(
147+
TARGETS google_cloud_cpp_networkmanagement
148+
google_cloud_cpp_networkmanagement_protos
149+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
150+
COMPONENT google_cloud_cpp_development
151+
NAMELINK_ONLY
152+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
153+
COMPONENT google_cloud_cpp_development)
154+
155+
google_cloud_cpp_install_proto_library_protos(
156+
"google_cloud_cpp_networkmanagement_protos" "${EXTERNAL_GOOGLEAPIS_SOURCE}")
157+
google_cloud_cpp_install_proto_library_headers(
158+
"google_cloud_cpp_networkmanagement_protos")
159+
google_cloud_cpp_install_headers("google_cloud_cpp_networkmanagement"
160+
"include/google/cloud/networkmanagement")
161+
google_cloud_cpp_install_headers("google_cloud_cpp_networkmanagement_mocks"
162+
"include/google/cloud/networkmanagement")
163+
164+
# Setup global variables used in the following *.in files.
165+
set(GOOGLE_CLOUD_CONFIG_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
166+
set(GOOGLE_CLOUD_CONFIG_VERSION_MINOR ${PROJECT_VERSION_MINOR})
167+
set(GOOGLE_CLOUD_CONFIG_VERSION_PATCH ${PROJECT_VERSION_PATCH})
168+
set(GOOGLE_CLOUD_PC_NAME "The Network Management API C++ Client Library")
169+
set(GOOGLE_CLOUD_PC_DESCRIPTION
170+
"Provides C++ APIs to use the Network Management API.")
171+
set(GOOGLE_CLOUD_PC_LIBS "-lgoogle_cloud_cpp_networkmanagement")
172+
string(CONCAT GOOGLE_CLOUD_PC_REQUIRES "google_cloud_cpp_grpc_utils"
173+
" google_cloud_cpp_common"
174+
" google_cloud_cpp_networkmanagement_protos")
175+
176+
# Create and install the pkg-config files.
177+
configure_file(
178+
"${PROJECT_SOURCE_DIR}/google/cloud/networkmanagement/config.pc.in"
179+
"google_cloud_cpp_networkmanagement.pc" @ONLY)
180+
install(
181+
FILES "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_networkmanagement.pc"
182+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
183+
COMPONENT google_cloud_cpp_development)
184+
185+
# Create and install the CMake configuration files.
186+
include(CMakePackageConfigHelpers)
187+
configure_file("config.cmake.in"
188+
"google_cloud_cpp_networkmanagement-config.cmake" @ONLY)
189+
write_basic_package_version_file(
190+
"google_cloud_cpp_networkmanagement-config-version.cmake"
191+
VERSION ${PROJECT_VERSION}
192+
COMPATIBILITY ExactVersion)
193+
194+
install(
195+
FILES
196+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_networkmanagement-config.cmake"
197+
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_networkmanagement-config-version.cmake"
198+
DESTINATION
199+
"${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_networkmanagement"
200+
COMPONENT google_cloud_cpp_development)
201+
202+
external_googleapis_install_pc("google_cloud_cpp_networkmanagement_protos"
203+
"${PROJECT_SOURCE_DIR}/external/googleapis")

0 commit comments

Comments
 (0)