[go: nahoru, domu]

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

feat(advisorynotifications): generate library #10814

Merged
merged 10 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Run generators and format their outputs
  • Loading branch information
scotthart committed Feb 13, 2023
commit 5b224ba32c3da67c88efd07784805a016d4baa2b
5 changes: 5 additions & 0 deletions ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
./include/google/cloud/accesscontextmanager
./include/google/cloud/accesscontextmanager/internal
./include/google/cloud/accesscontextmanager/mocks
./include/google/cloud/advisorynotifications
./include/google/cloud/advisorynotifications/internal
./include/google/cloud/advisorynotifications/mocks
./include/google/cloud/advisorynotifications/v1
./include/google/cloud/apigateway
./include/google/cloud/apigateway/internal
./include/google/cloud/apigateway/mocks
Expand Down Expand Up @@ -497,6 +501,7 @@
./lib64/cmake
./lib64/cmake/google_cloud_cpp_accessapproval
./lib64/cmake/google_cloud_cpp_accesscontextmanager
./lib64/cmake/google_cloud_cpp_advisorynotifications
./lib64/cmake/google_cloud_cpp_apigateway
./lib64/cmake/google_cloud_cpp_apigeeconnect
./lib64/cmake/google_cloud_cpp_apikeys
Expand Down
1 change: 1 addition & 0 deletions ci/etc/full_feature_list
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
accessapproval
accesscontextmanager
advisorynotifications
apigateway
apigeeconnect
apikeys
Expand Down
6 changes: 6 additions & 0 deletions external/googleapis/protodeps/advisorynotifications.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@com_google_googleapis//google/api:annotations_proto
@com_google_googleapis//google/api:client_proto
@com_google_googleapis//google/api:field_behavior_proto
@com_google_googleapis//google/api:http_proto
@com_google_googleapis//google/api:launch_stage_proto
@com_google_googleapis//google/api:resource_proto
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@com_google_googleapis//google/cloud/advisorynotifications/v1:service.proto
68 changes: 68 additions & 0 deletions google/cloud/advisorynotifications/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

service_dirs = [""]

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

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

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

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

cc_library(
name = "google_cloud_cpp_advisorynotifications",
srcs = [":srcs"],
hdrs = [":hdrs"],
visibility = ["//:__pkg__"],
deps = [
"//:common",
"//:grpc_utils",
"@com_google_googleapis//google/cloud/advisorynotifications/v1:advisorynotifications_cc_grpc",
],
)

cc_library(
name = "google_cloud_cpp_advisorynotifications_mocks",
hdrs = [":mocks"],
visibility = ["//:__pkg__"],
deps = [
":google_cloud_cpp_advisorynotifications",
"@com_google_googletest//:gtest",
],
)

[cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
tags = ["integration-test"],
deps = [
"//:advisorynotifications",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
],
) for sample in glob([d + "samples/*.cc" for d in service_dirs])]
215 changes: 215 additions & 0 deletions google/cloud/advisorynotifications/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
# ~~~
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~

include(GoogleapisConfig)
set(DOXYGEN_PROJECT_NAME "Advisory Notifications API C++ Client")
set(DOXYGEN_PROJECT_BRIEF
"A C++ Client Library for the Advisory Notifications API")
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}")
set(DOXYGEN_EXCLUDE_SYMBOLS "internal")
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quickstart)

unset(mocks_globs)
unset(source_globs)
set(service_dirs "")
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_EXAMPLE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/${dir}samples")
list(APPEND DOXYGEN_EXCLUDE_SYMBOLS "advisorynotifications_${ns}internal")
endforeach ()

include(GoogleCloudCppDoxygen)
google_cloud_cpp_doxygen_targets("advisorynotifications" DEPENDS
google-cloud-cpp::advisorynotifications_protos)
coryan marked this conversation as resolved.
Show resolved Hide resolved

include(GoogleCloudCppCommon)

include(CompileProtos)
google_cloud_cpp_find_proto_include_dir(PROTO_INCLUDE_DIR)
google_cloud_cpp_load_protolist(
proto_list
"${PROJECT_SOURCE_DIR}/external/googleapis/protolists/advisorynotifications.list"
)
google_cloud_cpp_load_protodeps(
proto_deps
"${PROJECT_SOURCE_DIR}/external/googleapis/protodeps/advisorynotifications.deps"
)
google_cloud_cpp_grpcpp_library(
google_cloud_cpp_advisorynotifications_protos # cmake-format: sort
${proto_list} PROTO_PATH_DIRECTORIES "${EXTERNAL_GOOGLEAPIS_SOURCE}"
"${PROTO_INCLUDE_DIR}")
external_googleapis_set_version_and_alias(advisorynotifications_protos)
target_link_libraries(google_cloud_cpp_advisorynotifications_protos
PUBLIC ${proto_deps})

file(
GLOB source_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
${source_globs})
list(SORT source_files)
add_library(google_cloud_cpp_advisorynotifications ${source_files})
target_include_directories(
google_cloud_cpp_advisorynotifications
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)
target_link_libraries(
google_cloud_cpp_advisorynotifications
PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
google-cloud-cpp::advisorynotifications_protos)
google_cloud_cpp_add_common_options(google_cloud_cpp_advisorynotifications)
set_target_properties(
google_cloud_cpp_advisorynotifications
PROPERTIES EXPORT_NAME google-cloud-cpp::advisorynotifications
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}")
target_compile_options(google_cloud_cpp_advisorynotifications
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})

add_library(google-cloud-cpp::advisorynotifications ALIAS
google_cloud_cpp_advisorynotifications)

# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
# for these, a regular library would not work on macOS (where the library needs
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
# that they need absolute paths for their sources.
file(
GLOB relative_mock_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
${mocks_globs})
list(SORT relative_mock_files)
set(mock_files)
foreach (file IN LISTS relative_mock_files)
list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
endforeach ()
add_library(google_cloud_cpp_advisorynotifications_mocks INTERFACE)
target_sources(google_cloud_cpp_advisorynotifications_mocks
INTERFACE ${mock_files})
target_link_libraries(
google_cloud_cpp_advisorynotifications_mocks
INTERFACE google-cloud-cpp::advisorynotifications GTest::gmock_main
GTest::gmock GTest::gtest)
set_target_properties(
google_cloud_cpp_advisorynotifications_mocks
PROPERTIES EXPORT_NAME google-cloud-cpp::advisorynotifications_mocks)
target_include_directories(
google_cloud_cpp_advisorynotifications_mocks
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)
target_compile_options(google_cloud_cpp_advisorynotifications_mocks
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})

include(CTest)
if (BUILD_TESTING)
add_executable(advisorynotifications_quickstart "quickstart/quickstart.cc")
target_link_libraries(advisorynotifications_quickstart
PRIVATE google-cloud-cpp::advisorynotifications)
google_cloud_cpp_add_common_options(advisorynotifications_quickstart)
add_test(
NAME advisorynotifications_quickstart
COMMAND
cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake"
$<TARGET_FILE:advisorynotifications_quickstart>
GOOGLE_CLOUD_PROJECT
# EDIT HERE
)
set_tests_properties(advisorynotifications_quickstart
PROPERTIES LABELS "integration-test;quickstart")
endif ()

# Get the destination directories based on the GNU recommendations.
include(GNUInstallDirs)

# Export the CMake targets to make it easy to create configuration files.
install(
EXPORT google_cloud_cpp_advisorynotifications-targets
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_advisorynotifications"
COMPONENT google_cloud_cpp_development)

# Install the libraries and headers in the locations determined by
# GNUInstallDirs
install(
TARGETS google_cloud_cpp_advisorynotifications
google_cloud_cpp_advisorynotifications_protos
EXPORT google_cloud_cpp_advisorynotifications-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT google_cloud_cpp_runtime
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_runtime
NAMELINK_SKIP
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_development)
# With CMake-3.12 and higher we could avoid this separate command (and the
# duplication).
install(
TARGETS google_cloud_cpp_advisorynotifications
google_cloud_cpp_advisorynotifications_protos
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_development
NAMELINK_ONLY
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_development)

google_cloud_cpp_install_proto_library_protos(
"google_cloud_cpp_advisorynotifications_protos"
"${EXTERNAL_GOOGLEAPIS_SOURCE}")
google_cloud_cpp_install_proto_library_headers(
"google_cloud_cpp_advisorynotifications_protos")
google_cloud_cpp_install_headers("google_cloud_cpp_advisorynotifications"
"include/google/cloud/advisorynotifications")
google_cloud_cpp_install_headers("google_cloud_cpp_advisorynotifications_mocks"
"include/google/cloud/advisorynotifications")

google_cloud_cpp_add_pkgconfig(
advisorynotifications
"The Advisory Notifications API C++ Client Library"
"Provides C++ APIs to use the Advisory Notifications API."
"google_cloud_cpp_grpc_utils"
" google_cloud_cpp_common"
" google_cloud_cpp_advisorynotifications_protos")

# Create and install the CMake configuration files.
include(CMakePackageConfigHelpers)
configure_file("config.cmake.in"
"google_cloud_cpp_advisorynotifications-config.cmake" @ONLY)
write_basic_package_version_file(
"google_cloud_cpp_advisorynotifications-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_advisorynotifications-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_advisorynotifications-config-version.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_advisorynotifications"
COMPONENT google_cloud_cpp_development)

external_googleapis_install_pc("google_cloud_cpp_advisorynotifications_protos")

# google-cloud-cpp::advisorynotifications 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("advisorynotifications"
"${dir}samples/")
endif ()
endforeach ()
57 changes: 57 additions & 0 deletions google/cloud/advisorynotifications/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Advisory Notifications API C++ Client Library

This directory contains an idiomatic C++ client library for the
[Advisory Notifications API][cloud-service-docs], a service to \<UNKNOWN - NO SERVICE CONFIG DOCUMENTATION SUMMARY>

While this library is **GA**, please note that the Google Cloud C++ client
libraries do **not** follow [Semantic Versioning](https://semver.org/).

## Quickstart

The [quickstart/](quickstart/README.md) directory contains a minimal environment
to get started using this client library in a larger project. The following
"Hello World" program is used in this quickstart, and should give you a taste of
this library.

<!-- inject-quickstart-start -->

```cc
#include "google/cloud/advisorynotifications/ EDIT HERE .h"
#include "google/cloud/project.h"
#include <iostream>

int main(int argc, char* argv[]) try {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " project-id\n";
return 1;
}

namespace advisorynotifications = ::google::cloud::advisorynotifications;
auto client =
advisorynotifications::Client(advisorynotifications::MakeConnection());

auto const project = google::cloud::Project(argv[1]);
for (auto r : client.List /*EDIT HERE*/ (project.FullName())) {
if (!r) throw std::move(r).status();
std::cout << r->DebugString() << "\n";
}

return 0;
} catch (google::cloud::Status const& status) {
std::cerr << "google::cloud::Status thrown: " << status << "\n";
return 1;
}
```

<!-- inject-quickstart-end -->

## More Information

- Official documentation about the [Advisory Notifications API][cloud-service-docs] service
- [Reference doxygen documentation][doxygen-link] for each release of this
client library
- Detailed header comments in our [public `.h`][source-link] files

[cloud-service-docs]: https://cloud.google.com/advisorynotifications
[doxygen-link]: https://googleapis.dev/cpp/google-cloud-advisorynotifications/latest/
[source-link]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/advisorynotifications
Loading