Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(asset): versioned clients #10863

Merged
merged 7 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ extend-exclude = [
# Autogenerated
"google/cloud/bigtable/internal/readrowsparser_acceptance_tests.inc",
# The source proto files have one or more typos in their comments
"google/cloud/asset/asset_client.h",
"google/cloud/asset/v1/asset_client.h",
"google/cloud/channel/cloud_channel_client.h",
"google/cloud/gameservices/game_server_deployments_client.h",
"google/cloud/managedidentities/managed_identities_client.h",
Expand Down
Binary file modified ci/abi-dumps/google_cloud_cpp_asset.expected.abi.dump.gz
Binary file not shown.
3 changes: 2 additions & 1 deletion ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
./include/google/cloud/artifactregistry/internal
./include/google/cloud/artifactregistry/mocks
./include/google/cloud/asset
./include/google/cloud/asset/internal
./include/google/cloud/asset/mocks
./include/google/cloud/asset/v1
./include/google/cloud/asset/v1/internal
./include/google/cloud/asset/v1/mocks
./include/google/cloud/assuredworkloads
./include/google/cloud/assuredworkloads/internal
./include/google/cloud/assuredworkloads/mocks
Expand Down
3 changes: 2 additions & 1 deletion generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ service {
# Cloud Asset
service {
service_proto_path: "google/cloud/asset/v1/asset_service.proto"
product_path: "google/cloud/asset"
product_path: "google/cloud/asset/v1"
forwarding_product_path: "google/cloud/asset"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}
Expand Down
29 changes: 20 additions & 9 deletions google/cloud/asset/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

service_dirs = [
"",
"v1/",
]

src_dirs = service_dirs + [d + "internal/" for d in service_dirs]

filegroup(
name = "srcs",
srcs = glob([
"*.cc",
"internal/*.cc",
]),
srcs = glob([d + "*.cc" for d in src_dirs]),
)

filegroup(
name = "hdrs",
srcs = glob([
"*.h",
"internal/*.h",
]),
srcs = glob([d + "*.h" for d in src_dirs]),
)

filegroup(
name = "mocks",
srcs = glob(["mocks/*.h"]),
srcs = glob([d + "mocks/*.h" for d in service_dirs]),
)

cc_library(
Expand Down Expand Up @@ -63,3 +64,13 @@ cc_library(
"@com_google_googletest//:gtest",
],
)

[cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
tags = ["integration-test"],
deps = [
"//:asset",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
],
) for sample in glob([d + "samples/*.cc" for d in service_dirs])]
31 changes: 25 additions & 6 deletions google/cloud/asset/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,22 @@ include(GoogleapisConfig)
set(DOXYGEN_PROJECT_NAME "Cloud Asset API C++ Client")
set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the Cloud Asset API")
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}")
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "asset_internal" "asset_testing"
"examples")
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/samples
${CMAKE_CURRENT_SOURCE_DIR}/quickstart)
set(DOXYGEN_EXCLUDE_SYMBOLS "internal")
set(DOXYGEN_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/quickstart")

unset(mocks_globs)
unset(source_globs)
set(service_dirs "" "v1/")
foreach (dir IN LISTS service_dirs)
string(REPLACE "/" "_" ns "${dir}")
list(APPEND source_globs "${dir}*.h" "${dir}*.cc" "${dir}internal/*")
list(APPEND mocks_globs "${dir}mocks/*.h")
list(APPEND DOXYGEN_EXCLUDE_SYMBOLS "asset_${ns}internal")
if (NOT dir STREQUAL "")
list(APPEND DOXYGEN_EXAMPLE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/${dir}samples")
endif ()
endforeach ()

include(GoogleCloudCppDoxygen)
set(GOOGLE_CLOUD_CPP_DOXYGEN_EXTRA_INCLUDES
Expand Down Expand Up @@ -54,7 +66,7 @@ target_link_libraries(google_cloud_cpp_asset_protos PUBLIC ${proto_deps})
file(
GLOB source_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
${source_globs})
list(SORT source_files)
add_library(google_cloud_cpp_asset ${source_files})
target_include_directories(
Expand Down Expand Up @@ -84,7 +96,7 @@ add_library(google-cloud-cpp::asset ALIAS google_cloud_cpp_asset)
file(
GLOB relative_mock_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"mocks/*.h")
${mocks_globs})
list(SORT relative_mock_files)
set(mock_files)
foreach (file IN LISTS relative_mock_files)
Expand Down Expand Up @@ -182,3 +194,10 @@ install(
COMPONENT google_cloud_cpp_development)

external_googleapis_install_pc("google_cloud_cpp_asset_protos")

# google-cloud-cpp::asset must be defined before we can add the samples.
foreach (dir IN LISTS service_dirs)
if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS)
google_cloud_cpp_add_samples_relative("asset" "${dir}samples/")
endif ()
endforeach ()
Loading