Skip to content

Commit

Permalink
feat(discoveryengine): generate library (googleapis#12505)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 534896621
  • Loading branch information
devbww authored Aug 31, 2023
1 parent db48d1a commit 178d658
Show file tree
Hide file tree
Showing 168 changed files with 14,629 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ 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.

- [Datastore](/google/cloud/datastore/README.md)
- [Discovery Engine API](/google/cloud/discoveryengine/README.md)

### Cloud IoT

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ See each library's `README.md` file for more information about:
- [Dialogflow ES API](google/cloud/dialogflow_es/README.md)
[\[quickstart\]](google/cloud/dialogflow_es/quickstart/README.md)
[\[reference\]](https://cloud.google.com/cpp/docs/reference/dialogflow_es/latest)
- [Discovery Engine API](google/cloud/discoveryengine/README.md)
[\[quickstart\]](google/cloud/discoveryengine/quickstart/README.md)
[\[reference\]](https://cloud.google.com/cpp/docs/reference/discoveryengine/latest)
- [Cloud Data Loss Prevention (DLP) API](google/cloud/dlp/README.md)
[\[quickstart\]](google/cloud/dlp/quickstart/README.md)
[\[reference\]](https://cloud.google.com/cpp/docs/reference/dlp/latest)
Expand Down
Binary file not shown.
5 changes: 5 additions & 0 deletions ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,10 @@
./include/google/cloud/dialogflow_es
./include/google/cloud/dialogflow_es/internal
./include/google/cloud/dialogflow_es/mocks
./include/google/cloud/discoveryengine
./include/google/cloud/discoveryengine/v1
./include/google/cloud/discoveryengine/v1/internal
./include/google/cloud/discoveryengine/v1/mocks
./include/google/cloud/dlp
./include/google/cloud/dlp/mocks
./include/google/cloud/dlp/v2
Expand Down Expand Up @@ -1176,6 +1180,7 @@
./lib64/cmake/google_cloud_cpp_deploy
./lib64/cmake/google_cloud_cpp_dialogflow_cx
./lib64/cmake/google_cloud_cpp_dialogflow_es
./lib64/cmake/google_cloud_cpp_discoveryengine
./lib64/cmake/google_cloud_cpp_dlp
./lib64/cmake/google_cloud_cpp_documentai
./lib64/cmake/google_cloud_cpp_domains
Expand Down
1 change: 1 addition & 0 deletions ci/etc/full_feature_list
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ datastream
deploy
dialogflow_cx
dialogflow_es
discoveryengine
dlp
documentai
domains
Expand Down
1 change: 1 addition & 0 deletions cmake/GoogleCloudCppFeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ set(GOOGLE_CLOUD_CPP_GA_LIBRARIES
"deploy"
"dialogflow_cx"
"dialogflow_es"
"discoveryengine"
"dlp"
"documentai"
"domains"
Expand Down
10 changes: 10 additions & 0 deletions external/googleapis/protodeps/discoveryengine.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@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:httpbody_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
@com_google_googleapis//google/type:date_proto
11 changes: 11 additions & 0 deletions external/googleapis/protolists/discoveryengine.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@com_google_googleapis//google/cloud/discoveryengine/v1:common.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:completion_service.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:document.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:document_service.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:import_config.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:purge_config.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:schema.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:schema_service.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:search_service.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:user_event.proto
@com_google_googleapis//google/cloud/discoveryengine/v1:user_event_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 @@ -120,6 +120,7 @@ declare -A -r LIBRARIES=(
["deploy"]="@com_google_googleapis//google/cloud/deploy/v1:deploy_cc_grpc"
["dialogflow_es"]="@com_google_googleapis//google/cloud/dialogflow/v2:dialogflow_cc_grpc"
["dialogflow_cx"]="@com_google_googleapis//google/cloud/dialogflow/cx/v3:cx_cc_grpc"
["discoveryengine"]="@com_google_googleapis//google/cloud/discoveryengine/v1:discoveryengine_cc_grpc"
["dlp"]="@com_google_googleapis//google/privacy/dlp/v2:dlp_cc_grpc"
["documentai"]="@com_google_googleapis//google/cloud/documentai/v1:documentai_cc_grpc"
["domains"]="@com_google_googleapis//google/cloud/domains/v1:domains_cc_grpc"
Expand Down
36 changes: 36 additions & 0 deletions generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -2039,6 +2039,42 @@ service {
endpoint_location_style: LOCATION_DEPENDENT_COMPAT
}
# Discovery Engine
service {
service_proto_path: "google/cloud/discoveryengine/v1/completion_service.proto"
product_path: "google/cloud/discoveryengine/v1"
initial_copyright_year: "2023"
retryable_status_codes: ["kUnavailable"]
}
service {
service_proto_path: "google/cloud/discoveryengine/v1/document_service.proto"
product_path: "google/cloud/discoveryengine/v1"
initial_copyright_year: "2023"
retryable_status_codes: ["kUnavailable"]
}
service {
service_proto_path: "google/cloud/discoveryengine/v1/schema_service.proto"
product_path: "google/cloud/discoveryengine/v1"
initial_copyright_year: "2023"
retryable_status_codes: ["kUnavailable"]
}
service {
service_proto_path: "google/cloud/discoveryengine/v1/search_service.proto"
product_path: "google/cloud/discoveryengine/v1"
initial_copyright_year: "2023"
retryable_status_codes: ["kUnavailable"]
}
service {
service_proto_path: "google/cloud/discoveryengine/v1/user_event_service.proto"
product_path: "google/cloud/discoveryengine/v1"
initial_copyright_year: "2023"
retryable_status_codes: ["kUnavailable"]
}
# Document AI
service {
service_proto_path: "google/cloud/documentai/v1/document_processor_service.proto"
Expand Down
68 changes: 68 additions & 0 deletions google/cloud/discoveryengine/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 = ["v1/"]

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_discoveryengine",
srcs = [":srcs"],
hdrs = [":hdrs"],
visibility = ["//:__pkg__"],
deps = [
"//:common",
"//:grpc_utils",
"@com_google_googleapis//google/cloud/discoveryengine/v1:discoveryengine_cc_grpc",
],
)

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

[cc_test(
name = sample.replace("/", "_").replace(".cc", ""),
srcs = [sample],
tags = ["integration-test"],
deps = [
"//:discoveryengine",
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
],
) for sample in glob([d + "samples/*.cc" for d in service_dirs])]
34 changes: 34 additions & 0 deletions google/cloud/discoveryengine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ~~~
# 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(GoogleCloudCppLibrary)

set(GOOGLE_CLOUD_CPP_SERVICE_DIRS "v1/")

google_cloud_cpp_add_ga_grpc_library(discoveryengine "Discovery Engine API")

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

This directory contains an idiomatic C++ client library for the
[Discovery Engine API][cloud-service-docs], a service that powers high-quality
content recommendations on your digital properties.

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/discoveryengine/v1/document_client.h"
#include <iostream>

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

namespace discoveryengine = ::google::cloud::discoveryengine_v1;
auto client = discoveryengine::DocumentServiceClient(
discoveryengine::MakeDocumentServiceConnection());

auto const parent = std::string{"projects/"} + argv[1] + "/locations/global" +
"/dataStores/default_data_store/branches/default_branch";
for (auto d : client.ListDocuments(parent)) {
if (!d) throw std::move(d).status();
std::cout << d->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 [Discovery Engine 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/discovery-engine
[doxygen-link]: https://cloud.google.com/cpp/docs/reference/discoveryengine/latest/
[source-link]: /~https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/discoveryengine
66 changes: 66 additions & 0 deletions google/cloud/discoveryengine/doc/environment-variables.dox
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*!

@page discoveryengine-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 discoveryengine-env-endpoint Endpoint Overrides

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

- `GOOGLE_CLOUD_CPP_COMPLETION_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "discoveryengine.googleapis.com")
used by `MakeCompletionServiceConnection()`.

- `GOOGLE_CLOUD_CPP_DOCUMENT_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "discoveryengine.googleapis.com")
used by `MakeDocumentServiceConnection()`.

- `GOOGLE_CLOUD_CPP_SCHEMA_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "discoveryengine.googleapis.com")
used by `MakeSchemaServiceConnection()`.

- `GOOGLE_CLOUD_CPP_SEARCH_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "discoveryengine.googleapis.com")
used by `MakeSearchServiceConnection()`.

- `GOOGLE_CLOUD_CPP_USER_EVENT_SERVICE_ENDPOINT=...` overrides the
`EndpointOption` (which defaults to "discoveryengine.googleapis.com")
used by `MakeUserEventServiceConnection()`.

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

@see google::cloud::EndpointOption

@section discoveryengine-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::TracingComponentsOption

`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 discoveryengine-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.

*/
Loading

0 comments on commit 178d658

Please sign in to comment.