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(apihub): generate library #14620

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ breaking changes in the upcoming 3.x release. This release is scheduled for

## v2.28.0 - TBD

### New Libraries

We are happy to announce the following GA libraries. Unless specifically noted,
the APIs in these libraries are stable, and are ready for production use.

- [ApiHub API](/google/cloud/apihub/README.md)

## v2.27.0 - 2024-08

- We now link our mocking libraries against GoogleTest in CMake.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ See each library's `README.md` file for more information about:
- [Apigee Connect API](google/cloud/apigeeconnect/README.md)
[\[quickstart\]](google/cloud/apigeeconnect/quickstart/README.md)
[\[reference\]](https://cloud.google.com/cpp/docs/reference/apigeeconnect/latest)
- [API hub API](google/cloud/apihub/README.md)
[\[quickstart\]](google/cloud/apihub/quickstart/README.md)
[\[reference\]](https://cloud.google.com/cpp/docs/reference/apihub/latest)
- [API Keys API](google/cloud/apikeys/README.md)
[\[quickstart\]](google/cloud/apikeys/quickstart/README.md)
[\[reference\]](https://cloud.google.com/cpp/docs/reference/apikeys/latest)
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
./include/google/cloud/apigeeconnect/v1
./include/google/cloud/apigeeconnect/v1/internal
./include/google/cloud/apigeeconnect/v1/mocks
./include/google/cloud/apihub
./include/google/cloud/apihub/v1
./include/google/cloud/apihub/v1/internal
./include/google/cloud/apihub/v1/mocks
./include/google/cloud/apikeys
./include/google/cloud/apikeys/mocks
./include/google/cloud/apikeys/v2
Expand Down Expand Up @@ -1261,6 +1265,8 @@
./lib64/cmake/google_cloud_cpp_apigateway_mocks
./lib64/cmake/google_cloud_cpp_apigeeconnect
./lib64/cmake/google_cloud_cpp_apigeeconnect_mocks
./lib64/cmake/google_cloud_cpp_apihub
./lib64/cmake/google_cloud_cpp_apihub_mocks
./lib64/cmake/google_cloud_cpp_apikeys
./lib64/cmake/google_cloud_cpp_apikeys_mocks
./lib64/cmake/google_cloud_cpp_appengine
Expand Down
1 change: 1 addition & 0 deletions cmake/GoogleCloudCppFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set(GOOGLE_CLOUD_CPP_GA_LIBRARIES
"alloydb"
"apigateway"
"apigeeconnect"
"apihub"
"apikeys"
"appengine"
"apphub"
Expand Down
8 changes: 8 additions & 0 deletions external/googleapis/protodeps/apihub.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@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
@com_google_googleapis//google/longrunning:operations_proto
@com_google_googleapis//google/rpc:status_proto
7 changes: 7 additions & 0 deletions external/googleapis/protolists/apihub.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@com_google_googleapis//google/cloud/apihub/v1:apihub_service.proto
@com_google_googleapis//google/cloud/apihub/v1:common_fields.proto
@com_google_googleapis//google/cloud/apihub/v1:host_project_registration_service.proto
@com_google_googleapis//google/cloud/apihub/v1:linting_service.proto
@com_google_googleapis//google/cloud/apihub/v1:plugin_service.proto
@com_google_googleapis//google/cloud/apihub/v1:provisioning_service.proto
@com_google_googleapis//google/cloud/apihub/v1:runtime_project_attachment_service.proto
1 change: 1 addition & 0 deletions external/googleapis/update_libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ declare -A -r LIBRARIES=(
["alloydb"]="@com_google_googleapis//google/cloud/alloydb/v1:alloydb_cc_grpc"
["apigateway"]="@com_google_googleapis//google/cloud/apigateway/v1:apigateway_cc_grpc"
["apigeeconnect"]="@com_google_googleapis//google/cloud/apigeeconnect/v1:apigeeconnect_cc_grpc"
["apihub"]="@com_google_googleapis//google/cloud/apihub/v1:apihub_cc_grpc"
["apikeys"]="@com_google_googleapis//google/api/apikeys/v2:apikeys_cc_grpc"
["appengine"]="$(
printf ",%s" \
Expand Down
43 changes: 43 additions & 0 deletions generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,49 @@ service {
retryable_status_codes: ["kUnavailable", "kUnknown"]
}

# API Hub
service {
service_proto_path: "google/cloud/apihub/v1/apihub_service.proto"
product_path: "google/cloud/apihub/v1"
initial_copyright_year: "2024"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/apihub/v1/host_project_registration_service.proto"
product_path: "google/cloud/apihub/v1"
initial_copyright_year: "2024"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/apihub/v1/linting_service.proto"
product_path: "google/cloud/apihub/v1"
initial_copyright_year: "2024"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/apihub/v1/plugin_service.proto"
product_path: "google/cloud/apihub/v1"
initial_copyright_year: "2024"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/apihub/v1/provisioning_service.proto"
product_path: "google/cloud/apihub/v1"
initial_copyright_year: "2024"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/apihub/v1/runtime_project_attachment_service.proto"
product_path: "google/cloud/apihub/v1"
initial_copyright_year: "2024"
retryable_status_codes: ["kUnavailable"]
}

# API Keys
service {
service_proto_path: "google/api/apikeys/v2/apikeys.proto"
Expand Down
31 changes: 31 additions & 0 deletions google/cloud/apihub/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2024 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.

load("//bazel:gapic.bzl", "cc_gapic_library")

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

licenses(["notice"]) # Apache 2.0

service_dirs = ["v1/"]

googleapis_deps = [
"@com_google_googleapis//google/cloud/apihub/v1:apihub_cc_grpc",
]

cc_gapic_library(
name = "apihub",
googleapis_deps = googleapis_deps,
service_dirs = service_dirs,
)
33 changes: 33 additions & 0 deletions google/cloud/apihub/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ~~~
# Copyright 2024 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(GoogleCloudCppLibrary)

google_cloud_cpp_add_gapic_library(apihub "API hub API" SERVICE_DIRS "v1/")

if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS)
add_executable(apihub_quickstart "quickstart/quickstart.cc")
target_link_libraries(apihub_quickstart PRIVATE google-cloud-cpp::apihub)
google_cloud_cpp_add_common_options(apihub_quickstart)
add_test(
NAME apihub_quickstart
COMMAND
cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake"
$<TARGET_FILE:apihub_quickstart> GOOGLE_CLOUD_PROJECT
GOOGLE_CLOUD_CPP_TEST_REGION)
set_tests_properties(apihub_quickstart
PROPERTIES LABELS "integration-test;quickstart")
endif ()
57 changes: 57 additions & 0 deletions google/cloud/apihub/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# API hub API C++ Client Library

This directory contains an idiomatic C++ client library for the
[API hub API][cloud-service-docs].

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/apihub/v1/api_hub_client.h"
#include "google/cloud/location.h"
#include <iostream>

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

auto const location = google::cloud::Location(argv[1], argv[2]);

namespace apihub = ::google::cloud::apihub_v1;
auto client = apihub::ApiHubClient(apihub::MakeApiHubConnection());

for (auto r : client.ListApis(location.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 [API hub 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/apigee/docs/apihub/what-is-api-hub
[doxygen-link]: https://cloud.google.com/cpp/docs/reference/apihub/latest/
[source-link]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/apihub
74 changes: 74 additions & 0 deletions google/cloud/apihub/doc/environment-variables.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*!

@page apihub-env Environment Variables

A number of environment variables can be used to configure the behavior of
the library. There are also functions to configure this behavior in code. The
environment variables are convenient when troubleshooting problems.

@section apihub-env-endpoint Endpoint Overrides

<!-- inject-endpoint-env-vars-start -->

- `GOOGLE_CLOUD_CPP_API_HUB_DEPENDENCIES_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "apihub.googleapis.com")
used by `MakeApiHubDependenciesConnection()`.

- `GOOGLE_CLOUD_CPP_API_HUB_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "apihub.googleapis.com")
used by `MakeApiHubConnection()`.

- `GOOGLE_CLOUD_CPP_API_HUB_PLUGIN_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "apihub.googleapis.com")
used by `MakeApiHubPluginConnection()`.

- `GOOGLE_CLOUD_CPP_HOST_PROJECT_REGISTRATION_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "apihub.googleapis.com")
used by `MakeHostProjectRegistrationServiceConnection()`.

- `GOOGLE_CLOUD_CPP_LINTING_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "apihub.googleapis.com")
used by `MakeLintingServiceConnection()`.

- `GOOGLE_CLOUD_CPP_PROVISIONING_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "apihub.googleapis.com")
used by `MakeProvisioningConnection()`.

- `GOOGLE_CLOUD_CPP_RUNTIME_PROJECT_ATTACHMENT_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "apihub.googleapis.com")
used by `MakeRuntimeProjectAttachmentServiceConnection()`.

<!-- inject-endpoint-env-vars-end -->

@see google::cloud::EndpointOption

@section apihub-env-logging Logging

`GOOGLE_CLOUD_CPP_ENABLE_TRACING=rpc`: turns on tracing for most gRPC
calls. The library injects an additional Stub decorator that prints each gRPC
request and response. Unless you have configured your own logging backend,
you should also set `GOOGLE_CLOUD_CPP_ENABLE_CLOG` to produce any output on
the program's console.

@see google::cloud::LoggingComponentsOption

`GOOGLE_CLOUD_CPP_TRACING_OPTIONS=...`: modifies the behavior of gRPC tracing,
including whether messages will be output on multiple lines, or whether
string/bytes fields will be truncated.

@see google::cloud::GrpcTracingOptionsOption

`GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes`: turns on logging in the library, basically
the library always "logs" but the logging infrastructure has no backend to
actually print anything until the application sets a backend or they set this
environment variable.

@see google::cloud::LogBackend
@see google::cloud::LogSink

@section apihub-env-project Setting the Default Project

`GOOGLE_CLOUD_PROJECT=...`: is used in examples and integration tests to
configure the GCP project. This has no effect in the library.

*/
56 changes: 56 additions & 0 deletions google/cloud/apihub/doc/main.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*!

@mainpage API hub API C++ Client Library

An idiomatic C++ client library for the [API hub API][cloud-service-docs].

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

@tableofcontents{HTML:2}

## Quickstart

The following shows the code that you'll run in the
`google/cloud/apihub/quickstart/` directory,
which should give you a taste of the API hub API C++ client library API.

@snippet quickstart.cc all

## Main classes

<!-- inject-client-list-start -->
This library offers multiple `*Client` classes, which are listed below. Each one
of these classes exposes all the RPCs for a service as member functions of the
class. This library groups multiple services because they are part of the same
product or are often used together. A typical example may be the administrative
and data plane operations for a single product.

The library also has other classes that provide helpers, configuration
parameters, and infrastructure to mock the `*Client` classes when testing your
application.

- [\c apihub_v1::ApiHubClient](@ref google::cloud::apihub_v1::ApiHubClient)
- [\c apihub_v1::ApiHubDependenciesClient](@ref google::cloud::apihub_v1::ApiHubDependenciesClient)
- [\c apihub_v1::ApiHubPluginClient](@ref google::cloud::apihub_v1::ApiHubPluginClient)
- [\c apihub_v1::HostProjectRegistrationServiceClient](@ref google::cloud::apihub_v1::HostProjectRegistrationServiceClient)
- [\c apihub_v1::LintingServiceClient](@ref google::cloud::apihub_v1::LintingServiceClient)
- [\c apihub_v1::ProvisioningClient](@ref google::cloud::apihub_v1::ProvisioningClient)
- [\c apihub_v1::RuntimeProjectAttachmentServiceClient](@ref google::cloud::apihub_v1::RuntimeProjectAttachmentServiceClient)
<!-- inject-client-list-end -->

## More Information

- @ref common-error-handling - describes how the library reports errors.
- @ref apihub-override-endpoint - describes how to override the default
endpoint.
- @ref apihub-override-authentication - describes how to change the
authentication credentials used by the library.
- @ref apihub-override-retry - describes how to change the default retry
policies.
- @ref apihub-env - describes environment variables that can configure the
behavior of the library.

[cloud-service-docs]: https://cloud.google.com/apigee/docs/apihub/what-is-api-hub

*/
10 changes: 10 additions & 0 deletions google/cloud/apihub/doc/options.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*!
@defgroup google-cloud-apihub-options API hub API Configuration Options

This library uses the same mechanism (`google::cloud::Options`) and the common
[options](@ref options) as all other C++ client libraries for its configuration.
Some `*Option` classes, which are only used in this library, are documented in
this page.

@see @ref options - for an overview of client library configuration.
*/
Loading
Loading