diff --git a/ci/abi-dumps/google_cloud_cpp_logging.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_logging.expected.abi.dump.gz index b394939e7220..f2101d1e3228 100644 Binary files a/ci/abi-dumps/google_cloud_cpp_logging.expected.abi.dump.gz and b/ci/abi-dumps/google_cloud_cpp_logging.expected.abi.dump.gz differ diff --git a/ci/etc/expected_install_directories b/ci/etc/expected_install_directories index a160aa9bb03a..faded6e24e07 100644 --- a/ci/etc/expected_install_directories +++ b/ci/etc/expected_install_directories @@ -304,8 +304,10 @@ ./include/google/cloud/language/v1/internal ./include/google/cloud/language/v1/mocks ./include/google/cloud/logging -./include/google/cloud/logging/internal ./include/google/cloud/logging/mocks +./include/google/cloud/logging/v2 +./include/google/cloud/logging/v2/internal +./include/google/cloud/logging/v2/mocks ./include/google/cloud/managedidentities ./include/google/cloud/managedidentities/internal ./include/google/cloud/managedidentities/mocks diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index 3ec29a973cf8..4f39341f8dcf 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -1089,7 +1089,8 @@ service { # Logging service { service_proto_path: "google/logging/v2/logging.proto" - product_path: "google/cloud/logging" + product_path: "google/cloud/logging/v2" + forwarding_product_path: "google/cloud/logging" initial_copyright_year: "2021" gen_async_rpcs: ["WriteLogEntries"] retryable_status_codes: ["kInternal", "kUnavailable"] diff --git a/google/cloud/logging/BUILD.bazel b/google/cloud/logging/BUILD.bazel index cf7218f9e51c..054f3f08ace4 100644 --- a/google/cloud/logging/BUILD.bazel +++ b/google/cloud/logging/BUILD.bazel @@ -16,12 +16,32 @@ package(default_visibility = ["//visibility:private"]) licenses(["notice"]) # Apache 2.0 -load(":google_cloud_cpp_logging.bzl", "google_cloud_cpp_logging_hdrs", "google_cloud_cpp_logging_srcs") +service_dirs = [ + "", + "v2/", +] + +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_logging", - srcs = google_cloud_cpp_logging_srcs, - hdrs = google_cloud_cpp_logging_hdrs, + srcs = [":srcs"], + hdrs = [":hdrs"], visibility = ["//:__pkg__"], deps = [ "//:common", @@ -30,15 +50,22 @@ cc_library( ], ) -load(":google_cloud_cpp_logging_mocks.bzl", "google_cloud_cpp_logging_mocks_hdrs", "google_cloud_cpp_logging_mocks_srcs") - cc_library( name = "google_cloud_cpp_logging_mocks", - srcs = google_cloud_cpp_logging_mocks_srcs, - hdrs = google_cloud_cpp_logging_mocks_hdrs, + hdrs = [":mocks"], visibility = ["//:__pkg__"], deps = [ ":google_cloud_cpp_logging", "@com_google_googletest//:gtest", ], ) + +[cc_test( + name = sample.replace("/", "_").replace(".cc", ""), + srcs = [sample], + tags = ["integration-test"], + deps = [ + "//:logging", + "//google/cloud/testing_util:google_cloud_cpp_testing_private", + ], +) for sample in glob([d + "samples/*.cc" for d in service_dirs])] diff --git a/google/cloud/logging/CMakeLists.txt b/google/cloud/logging/CMakeLists.txt index cde40ae5869d..7ff3a06ea8b1 100644 --- a/google/cloud/logging/CMakeLists.txt +++ b/google/cloud/logging/CMakeLists.txt @@ -18,10 +18,22 @@ include(GoogleapisConfig) set(DOXYGEN_PROJECT_NAME "Google Cloud Logging C++ Client") set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for Google Cloud Logging") set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}") -set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "logging_internal" "logging_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 "" "v2/") +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 "logging_${ns}internal") + if (NOT dir STREQUAL "") + list(APPEND DOXYGEN_EXAMPLE_PATH + "${CMAKE_CURRENT_SOURCE_DIR}/${dir}samples") + endif () +endforeach () include(GoogleCloudCppDoxygen) google_cloud_cpp_doxygen_targets("logging" DEPENDS cloud-docs @@ -29,36 +41,12 @@ google_cloud_cpp_doxygen_targets("logging" DEPENDS cloud-docs include(GoogleCloudCppCommon) -# configure_file(version_info.h.in ${CMAKE_CURRENT_SOURCE_DIR}/version_info.h) -add_library( - google_cloud_cpp_logging # cmake-format: sort - internal/logging_service_v2_auth_decorator.cc - internal/logging_service_v2_auth_decorator.h - internal/logging_service_v2_connection_impl.cc - internal/logging_service_v2_connection_impl.h - internal/logging_service_v2_logging_decorator.cc - internal/logging_service_v2_logging_decorator.h - internal/logging_service_v2_metadata_decorator.cc - internal/logging_service_v2_metadata_decorator.h - internal/logging_service_v2_option_defaults.cc - internal/logging_service_v2_option_defaults.h - internal/logging_service_v2_retry_traits.h - internal/logging_service_v2_stub.cc - internal/logging_service_v2_stub.h - internal/logging_service_v2_stub_factory.cc - internal/logging_service_v2_stub_factory.h - internal/logging_service_v2_tracing_connection.cc - internal/logging_service_v2_tracing_connection.h - internal/logging_service_v2_tracing_stub.cc - internal/logging_service_v2_tracing_stub.h - internal/streaming.cc - logging_service_v2_client.cc - logging_service_v2_client.h - logging_service_v2_connection.cc - logging_service_v2_connection.h - logging_service_v2_connection_idempotency_policy.cc - logging_service_v2_connection_idempotency_policy.h - logging_service_v2_options.h) +file( + GLOB source_files + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + ${source_globs}) +list(SORT source_files) +add_library(google_cloud_cpp_logging ${source_files}) target_include_directories( google_cloud_cpp_logging PUBLIC $ @@ -79,27 +67,27 @@ target_compile_options(google_cloud_cpp_logging add_library(google-cloud-cpp::logging ALIAS google_cloud_cpp_logging) -# To avoid maintaining the list of files for the library, export them to a .bzl -# file. -include(CreateBazelConfig) -create_bazel_config(google_cloud_cpp_logging YEAR "2021") - # 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_logging_mocks INTERFACE) -target_sources( - google_cloud_cpp_logging_mocks - INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/mocks/mock_logging_service_v2_connection.h) +target_sources(google_cloud_cpp_logging_mocks INTERFACE ${mock_files}) target_link_libraries( google_cloud_cpp_logging_mocks INTERFACE google-cloud-cpp::logging GTest::gmock_main GTest::gmock GTest::gtest) set_target_properties(google_cloud_cpp_logging_mocks PROPERTIES EXPORT_NAME google-cloud-cpp::logging_mocks) -create_bazel_config(google_cloud_cpp_logging_mocks YEAR "2021") target_include_directories( google_cloud_cpp_logging_mocks INTERFACE $ @@ -181,3 +169,10 @@ install( "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_logging-config-version.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_logging" COMPONENT google_cloud_cpp_development) + +# google-cloud-cpp::logging 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("logging" "${dir}samples/") + endif () +endforeach () diff --git a/google/cloud/logging/doc/main.dox b/google/cloud/logging/doc/main.dox index 27853443ba97..65490dc3d123 100644 --- a/google/cloud/logging/doc/main.dox +++ b/google/cloud/logging/doc/main.dox @@ -94,7 +94,7 @@ library. Use the `google::cloud::EndpointOption` when initializing the client library to change this default. -For example, this will override the default endpoint for `logging::LoggingServiceV2Client`: +For example, this will override the default endpoint for `logging_v2::LoggingServiceV2Client`: @snippet logging_service_v2_client_samples.cc set-client-endpoint @@ -138,15 +138,15 @@ can override the default policies. // -/*! @page logging::LoggingServiceV2Client-endpoint-snippet Override logging::LoggingServiceV2Client Endpoint Configuration +/*! @page logging_v2::LoggingServiceV2Client-endpoint-snippet Override logging_v2::LoggingServiceV2Client Endpoint Configuration -@snippet google/cloud/logging/samples/logging_service_v2_client_samples.cc set-client-endpoint +@snippet google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc set-client-endpoint */ -/*! @page logging::LoggingServiceV2Client-service-account-snippet Override logging::LoggingServiceV2Client Authentication Defaults +/*! @page logging_v2::LoggingServiceV2Client-service-account-snippet Override logging_v2::LoggingServiceV2Client Authentication Defaults -@snippet google/cloud/logging/samples/logging_service_v2_client_samples.cc with-service-account +@snippet google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc with-service-account */ // diff --git a/google/cloud/logging/google_cloud_cpp_logging.bzl b/google/cloud/logging/google_cloud_cpp_logging.bzl deleted file mode 100644 index 484a871c57a4..000000000000 --- a/google/cloud/logging/google_cloud_cpp_logging.bzl +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2021 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. -# -# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed - -"""Automatically generated source lists for google_cloud_cpp_logging - DO NOT EDIT.""" - -google_cloud_cpp_logging_hdrs = [ - "internal/logging_service_v2_auth_decorator.h", - "internal/logging_service_v2_connection_impl.h", - "internal/logging_service_v2_logging_decorator.h", - "internal/logging_service_v2_metadata_decorator.h", - "internal/logging_service_v2_option_defaults.h", - "internal/logging_service_v2_retry_traits.h", - "internal/logging_service_v2_stub.h", - "internal/logging_service_v2_stub_factory.h", - "internal/logging_service_v2_tracing_connection.h", - "internal/logging_service_v2_tracing_stub.h", - "logging_service_v2_client.h", - "logging_service_v2_connection.h", - "logging_service_v2_connection_idempotency_policy.h", - "logging_service_v2_options.h", -] - -google_cloud_cpp_logging_srcs = [ - "internal/logging_service_v2_auth_decorator.cc", - "internal/logging_service_v2_connection_impl.cc", - "internal/logging_service_v2_logging_decorator.cc", - "internal/logging_service_v2_metadata_decorator.cc", - "internal/logging_service_v2_option_defaults.cc", - "internal/logging_service_v2_stub.cc", - "internal/logging_service_v2_stub_factory.cc", - "internal/logging_service_v2_tracing_connection.cc", - "internal/logging_service_v2_tracing_stub.cc", - "internal/streaming.cc", - "logging_service_v2_client.cc", - "logging_service_v2_connection.cc", - "logging_service_v2_connection_idempotency_policy.cc", -] diff --git a/google/cloud/logging/google_cloud_cpp_logging_mocks.bzl b/google/cloud/logging/google_cloud_cpp_logging_mocks.bzl deleted file mode 100644 index 72aed6442bd6..000000000000 --- a/google/cloud/logging/google_cloud_cpp_logging_mocks.bzl +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2021 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. -# -# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed - -"""Automatically generated source lists for google_cloud_cpp_logging_mocks - DO NOT EDIT.""" - -google_cloud_cpp_logging_mocks_hdrs = [ - "mocks/mock_logging_service_v2_connection.h", -] - -google_cloud_cpp_logging_mocks_srcs = [ -] diff --git a/google/cloud/logging/integration_tests/logging_integration_test.cc b/google/cloud/logging/integration_tests/logging_integration_test.cc index 66468d0594a4..78263f6e1ba3 100644 --- a/google/cloud/logging/integration_tests/logging_integration_test.cc +++ b/google/cloud/logging/integration_tests/logging_integration_test.cc @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "google/cloud/logging/internal/logging_service_v2_stub_factory.h" -#include "google/cloud/logging/logging_service_v2_client.h" -#include "google/cloud/logging/logging_service_v2_options.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub_factory.h" +#include "google/cloud/logging/v2/logging_service_v2_client.h" +#include "google/cloud/logging/v2/logging_service_v2_options.h" #include "google/cloud/common_options.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/log.h" @@ -25,7 +25,7 @@ namespace google { namespace cloud { -namespace logging { +namespace logging_v2 { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { @@ -117,6 +117,6 @@ TEST_F(LoggingIntegrationTest, ListLogsFailure) { } // namespace GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging +} // namespace logging_v2 } // namespace cloud } // namespace google diff --git a/google/cloud/logging/logging_service_v2_client.h b/google/cloud/logging/logging_service_v2_client.h index 9f6d00521878..f2eb92e4b6b8 100644 --- a/google/cloud/logging/logging_service_v2_client.h +++ b/google/cloud/logging/logging_service_v2_client.h @@ -20,463 +20,15 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_LOGGING_SERVICE_V2_CLIENT_H #include "google/cloud/logging/logging_service_v2_connection.h" -#include "google/cloud/future.h" -#include "google/cloud/options.h" -#include "google/cloud/polling_policy.h" -#include "google/cloud/status_or.h" -#include "google/cloud/version.h" -#include -#include +#include "google/cloud/logging/v2/logging_service_v2_client.h" namespace google { namespace cloud { namespace logging { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -/// -/// Service for ingesting and querying logs. -/// -/// @par Equality -/// -/// Instances of this class created via copy-construction or copy-assignment -/// always compare equal. Instances created with equal -/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare -/// equal share the same underlying resources. -/// -/// @par Performance -/// -/// Creating a new instance of this class is a relatively expensive operation, -/// new objects establish new connections to the service. In contrast, -/// copy-construction, move-construction, and the corresponding assignment -/// operations are relatively efficient as the copies share all underlying -/// resources. -/// -/// @par Thread Safety -/// -/// Concurrent access to different instances of this class, even if they compare -/// equal, is guaranteed to work. Two or more threads operating on the same -/// instance of this class is not guaranteed to work. Since copy-construction -/// and move-construction is a relatively efficient operation, consider using -/// such a copy when using this class from multiple threads. -/// -class LoggingServiceV2Client { - public: - explicit LoggingServiceV2Client( - std::shared_ptr connection, - Options opts = {}); - ~LoggingServiceV2Client(); - - ///@{ - /// @name Copy and move support - LoggingServiceV2Client(LoggingServiceV2Client const&) = default; - LoggingServiceV2Client& operator=(LoggingServiceV2Client const&) = default; - LoggingServiceV2Client(LoggingServiceV2Client&&) = default; - LoggingServiceV2Client& operator=(LoggingServiceV2Client&&) = default; - ///@} - - ///@{ - /// @name Equality - friend bool operator==(LoggingServiceV2Client const& a, - LoggingServiceV2Client const& b) { - return a.connection_ == b.connection_; - } - friend bool operator!=(LoggingServiceV2Client const& a, - LoggingServiceV2Client const& b) { - return !(a == b); - } - ///@} - - /// - /// Deletes all the log entries in a log for the _Default Log Bucket. The log - /// reappears if it receives new entries. Log entries written shortly before - /// the delete operation might not be deleted. Entries received after the - /// delete operation with a timestamp before the operation will be deleted. - /// - /// @param log_name Required. The resource name of the log to delete: - /// * `projects/[PROJECT_ID]/logs/[LOG_ID]` - /// * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` - /// * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` - /// * `folders/[FOLDER_ID]/logs/[LOG_ID]` - /// `[LOG_ID]` must be URL-encoded. For example, - /// `"projects/my-project-id/logs/syslog"`, - /// `"organizations/123/logs/cloudaudit.googleapis.com%2Factivity"`. - /// For more information about log names, see - /// [LogEntry][google.logging.v2.LogEntry]. - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// - /// [google.logging.v2.DeleteLogRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L137} - /// - Status DeleteLog(std::string const& log_name, Options opts = {}); - - /// - /// Deletes all the log entries in a log for the _Default Log Bucket. The log - /// reappears if it receives new entries. Log entries written shortly before - /// the delete operation might not be deleted. Entries received after the - /// delete operation with a timestamp before the operation will be deleted. - /// - /// @param request - /// @googleapis_link{google::logging::v2::DeleteLogRequest,google/logging/v2/logging.proto#L137} - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// - /// [google.logging.v2.DeleteLogRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L137} - /// - Status DeleteLog(google::logging::v2::DeleteLogRequest const& request, - Options opts = {}); - - /// - /// Writes log entries to Logging. This API method is the - /// only way to send log entries to Logging. This method - /// is used, directly or indirectly, by the Logging agent - /// (fluentd) and all logging libraries configured to use Logging. - /// A single request may contain log entries for a maximum of 1000 - /// different resources (projects, organizations, billing accounts or - /// folders) - /// - /// @param log_name Optional. A default log resource name that is assigned to - /// all log entries - /// in `entries` that do not specify a value for `log_name`: - /// * `projects/[PROJECT_ID]/logs/[LOG_ID]` - /// * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` - /// * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` - /// * `folders/[FOLDER_ID]/logs/[LOG_ID]` - /// `[LOG_ID]` must be URL-encoded. For example: - /// "projects/my-project-id/logs/syslog" - /// "organizations/123/logs/cloudaudit.googleapis.com%2Factivity" - /// The permission `logging.logEntries.create` is needed on each project, - /// organization, billing account, or folder that is receiving new log - /// entries, whether the resource is specified in `logName` or in an - /// individual log entry. - /// @param resource Optional. A default monitored resource object that is - /// assigned to all log - /// entries in `entries` that do not specify a value for `resource`. Example: - /// { "type": "gce_instance", - /// "labels": { - /// "zone": "us-central1-a", "instance_id": "00000000000000000000" }} - /// See [LogEntry][google.logging.v2.LogEntry]. - /// @param labels Optional. Default labels that are added to the `labels` - /// field of all log - /// entries in `entries`. If a log entry already has a label with the same - /// key as a label in this parameter, then the log entry's label is not - /// changed. See [LogEntry][google.logging.v2.LogEntry]. - /// @param entries Required. The log entries to send to Logging. The order of - /// log - /// entries in this list does not matter. Values supplied in this method's - /// `log_name`, `resource`, and `labels` fields are copied into those log - /// entries in this list that do not include values for their corresponding - /// fields. For more information, see the - /// [LogEntry][google.logging.v2.LogEntry] type. - /// If the `timestamp` or `insert_id` fields are missing in log entries, then - /// this method supplies the current time or a unique identifier, - /// respectively. The supplied values are chosen so that, among the log - /// entries that did not supply their own values, the entries earlier in the - /// list will sort before the entries later in the list. See the - /// `entries.list` method. Log entries with timestamps that are more than the - /// [logs retention period](https://cloud.google.com/logging/quotas) in - /// the past or more than 24 hours in the future will not be available when - /// calling `entries.list`. However, those log entries can still be [exported - /// with - /// LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). - /// To improve throughput and to avoid exceeding the - /// [quota limit](https://cloud.google.com/logging/quotas) for calls to - /// `entries.write`, you should try to include several log entries in this - /// list, rather than calling this method for each individual log entry. - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return - /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} - /// - /// [google.logging.v2.WriteLogEntriesRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} - /// [google.logging.v2.WriteLogEntriesResponse]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} - /// - StatusOr WriteLogEntries( - std::string const& log_name, - google::api::MonitoredResource const& resource, - std::map const& labels, - std::vector const& entries, - Options opts = {}); - - /// - /// Writes log entries to Logging. This API method is the - /// only way to send log entries to Logging. This method - /// is used, directly or indirectly, by the Logging agent - /// (fluentd) and all logging libraries configured to use Logging. - /// A single request may contain log entries for a maximum of 1000 - /// different resources (projects, organizations, billing accounts or - /// folders) - /// - /// @param request - /// @googleapis_link{google::logging::v2::WriteLogEntriesRequest,google/logging/v2/logging.proto#L160} - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return - /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} - /// - /// [google.logging.v2.WriteLogEntriesRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} - /// [google.logging.v2.WriteLogEntriesResponse]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} - /// - StatusOr WriteLogEntries( - google::logging::v2::WriteLogEntriesRequest const& request, - Options opts = {}); - - /// - /// Lists log entries. Use this method to retrieve log entries that - /// originated from a project/folder/organization/billing account. For ways - /// to export log entries, see [Exporting - /// Logs](https://cloud.google.com/logging/docs/export). - /// - /// @param resource_names Required. Names of one or more parent resources - /// from which to - /// retrieve log entries: - /// * `projects/[PROJECT_ID]` - /// * `organizations/[ORGANIZATION_ID]` - /// * `billingAccounts/[BILLING_ACCOUNT_ID]` - /// * `folders/[FOLDER_ID]` - /// May alternatively be one or more views: - /// * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` - /// * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` - /// * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` - /// * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` - /// Projects listed in the `project_ids` field are added to this list. - /// @param filter Optional. A filter that chooses which log entries to - /// return. See [Advanced - /// Logs - /// Queries](https://cloud.google.com/logging/docs/view/advanced-queries). - /// Only log entries that match the filter are returned. An empty filter - /// matches all log entries in the resources listed in `resource_names`. - /// Referencing a parent resource that is not listed in `resource_names` will - /// cause the filter to return no results. The maximum length of the filter - /// is 20000 characters. - /// @param order_by Optional. How the results should be sorted. Presently, - /// the only permitted - /// values are `"timestamp asc"` (default) and `"timestamp desc"`. The first - /// option returns entries in order of increasing values of - /// `LogEntry.timestamp` (oldest first), and the second option returns - /// entries in order of decreasing timestamps (newest first). Entries with - /// equal timestamps are returned in order of their `insert_id` values. - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return - /// @googleapis_link{google::logging::v2::LogEntry,google/logging/v2/log_entry.proto#L38} - /// - /// [google.logging.v2.ListLogEntriesRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L257} - /// [google.logging.v2.LogEntry]: - /// @googleapis_reference_link{google/logging/v2/log_entry.proto#L38} - /// - StreamRange ListLogEntries( - std::vector const& resource_names, std::string const& filter, - std::string const& order_by, Options opts = {}); - - /// - /// Lists log entries. Use this method to retrieve log entries that - /// originated from a project/folder/organization/billing account. For ways - /// to export log entries, see [Exporting - /// Logs](https://cloud.google.com/logging/docs/export). - /// - /// @param request - /// @googleapis_link{google::logging::v2::ListLogEntriesRequest,google/logging/v2/logging.proto#L257} - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return - /// @googleapis_link{google::logging::v2::LogEntry,google/logging/v2/log_entry.proto#L38} - /// - /// [google.logging.v2.ListLogEntriesRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L257} - /// [google.logging.v2.LogEntry]: - /// @googleapis_reference_link{google/logging/v2/log_entry.proto#L38} - /// - StreamRange ListLogEntries( - google::logging::v2::ListLogEntriesRequest request, Options opts = {}); - - /// - /// Lists the descriptors for monitored resource types used by Logging. - /// - /// @param request - /// @googleapis_link{google::logging::v2::ListMonitoredResourceDescriptorsRequest,google/logging/v2/logging.proto#L332} - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return - /// @googleapis_link{google::api::MonitoredResourceDescriptor,google/api/monitored_resource.proto#L40} - /// - /// [google.api.MonitoredResourceDescriptor]: - /// @googleapis_reference_link{google/api/monitored_resource.proto#L40} - /// [google.logging.v2.ListMonitoredResourceDescriptorsRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L332} - /// - StreamRange - ListMonitoredResourceDescriptors( - google::logging::v2::ListMonitoredResourceDescriptorsRequest request, - Options opts = {}); - - /// - /// Lists the logs in projects, organizations, folders, or billing accounts. - /// Only logs that have entries are listed. - /// - /// @param parent Required. The resource name that owns the logs: - /// * `projects/[PROJECT_ID]` - /// * `organizations/[ORGANIZATION_ID]` - /// * `billingAccounts/[BILLING_ACCOUNT_ID]` - /// * `folders/[FOLDER_ID]` - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return std::string - /// - /// [google.logging.v2.ListLogsRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L357} - /// - StreamRange ListLogs(std::string const& parent, - Options opts = {}); - - /// - /// Lists the logs in projects, organizations, folders, or billing accounts. - /// Only logs that have entries are listed. - /// - /// @param request - /// @googleapis_link{google::logging::v2::ListLogsRequest,google/logging/v2/logging.proto#L357} - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return std::string - /// - /// [google.logging.v2.ListLogsRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L357} - /// - StreamRange ListLogs( - google::logging::v2::ListLogsRequest request, Options opts = {}); - - /// - /// Streaming read of log entries as they are ingested. Until the stream is - /// terminated, it will continue reading logs. - /// - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return A bidirectional streaming interface with request (write) type: - /// @googleapis_link{google::logging::v2::TailLogEntriesRequest,google/logging/v2/logging.proto#L417} - /// and response (read) type: - /// @googleapis_link{google::logging::v2::TailLogEntriesResponse,google/logging/v2/logging.proto#L450} - /// - /// [google.logging.v2.TailLogEntriesRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L417} - /// [google.logging.v2.TailLogEntriesResponse]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L450} - /// - std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< - google::logging::v2::TailLogEntriesRequest, - google::logging::v2::TailLogEntriesResponse>> - AsyncTailLogEntries(Options opts = {}); - - /// - /// Writes log entries to Logging. This API method is the - /// only way to send log entries to Logging. This method - /// is used, directly or indirectly, by the Logging agent - /// (fluentd) and all logging libraries configured to use Logging. - /// A single request may contain log entries for a maximum of 1000 - /// different resources (projects, organizations, billing accounts or - /// folders) - /// - /// @param log_name Optional. A default log resource name that is assigned to - /// all log entries - /// in `entries` that do not specify a value for `log_name`: - /// * `projects/[PROJECT_ID]/logs/[LOG_ID]` - /// * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` - /// * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` - /// * `folders/[FOLDER_ID]/logs/[LOG_ID]` - /// `[LOG_ID]` must be URL-encoded. For example: - /// "projects/my-project-id/logs/syslog" - /// "organizations/123/logs/cloudaudit.googleapis.com%2Factivity" - /// The permission `logging.logEntries.create` is needed on each project, - /// organization, billing account, or folder that is receiving new log - /// entries, whether the resource is specified in `logName` or in an - /// individual log entry. - /// @param resource Optional. A default monitored resource object that is - /// assigned to all log - /// entries in `entries` that do not specify a value for `resource`. Example: - /// { "type": "gce_instance", - /// "labels": { - /// "zone": "us-central1-a", "instance_id": "00000000000000000000" }} - /// See [LogEntry][google.logging.v2.LogEntry]. - /// @param labels Optional. Default labels that are added to the `labels` - /// field of all log - /// entries in `entries`. If a log entry already has a label with the same - /// key as a label in this parameter, then the log entry's label is not - /// changed. See [LogEntry][google.logging.v2.LogEntry]. - /// @param entries Required. The log entries to send to Logging. The order of - /// log - /// entries in this list does not matter. Values supplied in this method's - /// `log_name`, `resource`, and `labels` fields are copied into those log - /// entries in this list that do not include values for their corresponding - /// fields. For more information, see the - /// [LogEntry][google.logging.v2.LogEntry] type. - /// If the `timestamp` or `insert_id` fields are missing in log entries, then - /// this method supplies the current time or a unique identifier, - /// respectively. The supplied values are chosen so that, among the log - /// entries that did not supply their own values, the entries earlier in the - /// list will sort before the entries later in the list. See the - /// `entries.list` method. Log entries with timestamps that are more than the - /// [logs retention period](https://cloud.google.com/logging/quotas) in - /// the past or more than 24 hours in the future will not be available when - /// calling `entries.list`. However, those log entries can still be [exported - /// with - /// LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). - /// To improve throughput and to avoid exceeding the - /// [quota limit](https://cloud.google.com/logging/quotas) for calls to - /// `entries.write`, you should try to include several log entries in this - /// list, rather than calling this method for each individual log entry. - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return - /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} - /// - /// [google.logging.v2.WriteLogEntriesRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} - /// [google.logging.v2.WriteLogEntriesResponse]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} - /// - future> - AsyncWriteLogEntries( - std::string const& log_name, - google::api::MonitoredResource const& resource, - std::map const& labels, - std::vector const& entries, - Options opts = {}); - - /// - /// Writes log entries to Logging. This API method is the - /// only way to send log entries to Logging. This method - /// is used, directly or indirectly, by the Logging agent - /// (fluentd) and all logging libraries configured to use Logging. - /// A single request may contain log entries for a maximum of 1000 - /// different resources (projects, organizations, billing accounts or - /// folders) - /// - /// @param request - /// @googleapis_link{google::logging::v2::WriteLogEntriesRequest,google/logging/v2/logging.proto#L160} - /// @param opts Optional. Override the class-level options, such as retry and - /// backoff policies. - /// @return - /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} - /// - /// [google.logging.v2.WriteLogEntriesRequest]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} - /// [google.logging.v2.WriteLogEntriesResponse]: - /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} - /// - future> - AsyncWriteLogEntries( - google::logging::v2::WriteLogEntriesRequest const& request, - Options opts = {}); - - private: - std::shared_ptr connection_; - Options options_; -}; +/// @deprecated Use logging_v2::LoggingServiceV2Client directly. +using ::google::cloud::logging_v2::LoggingServiceV2Client; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging diff --git a/google/cloud/logging/logging_service_v2_connection.h b/google/cloud/logging/logging_service_v2_connection.h index 642b33d0936b..6e8c6328372f 100644 --- a/google/cloud/logging/logging_service_v2_connection.h +++ b/google/cloud/logging/logging_service_v2_connection.h @@ -19,102 +19,29 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_LOGGING_SERVICE_V2_CONNECTION_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_LOGGING_SERVICE_V2_CONNECTION_H -#include "google/cloud/logging/internal/logging_service_v2_retry_traits.h" -#include "google/cloud/logging/internal/logging_service_v2_stub.h" #include "google/cloud/logging/logging_service_v2_connection_idempotency_policy.h" -#include "google/cloud/backoff_policy.h" -#include "google/cloud/internal/async_read_write_stream_impl.h" -#include "google/cloud/options.h" -#include "google/cloud/status_or.h" -#include "google/cloud/stream_range.h" -#include "google/cloud/version.h" -#include +#include "google/cloud/logging/v2/logging_service_v2_connection.h" namespace google { namespace cloud { namespace logging { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -using LoggingServiceV2RetryPolicy = - ::google::cloud::internal::TraitBasedRetryPolicy< - logging_internal::LoggingServiceV2RetryTraits>; +/// @deprecated Use logging_v2::MakeLoggingServiceV2Connection directly. +using ::google::cloud::logging_v2::MakeLoggingServiceV2Connection; -using LoggingServiceV2LimitedTimeRetryPolicy = - ::google::cloud::internal::LimitedTimeRetryPolicy< - logging_internal::LoggingServiceV2RetryTraits>; +/// @deprecated Use logging_v2::LoggingServiceV2Connection directly. +using ::google::cloud::logging_v2::LoggingServiceV2Connection; -using LoggingServiceV2LimitedErrorCountRetryPolicy = - ::google::cloud::internal::LimitedErrorCountRetryPolicy< - logging_internal::LoggingServiceV2RetryTraits>; +/// @deprecated Use logging_v2::LoggingServiceV2LimitedErrorCountRetryPolicy +/// directly. +using ::google::cloud::logging_v2::LoggingServiceV2LimitedErrorCountRetryPolicy; -/** - * The `LoggingServiceV2Connection` object for `LoggingServiceV2Client`. - * - * This interface defines virtual methods for each of the user-facing overload - * sets in `LoggingServiceV2Client`. This allows users to inject custom behavior - * (e.g., with a Google Mock object) when writing tests that use objects of type - * `LoggingServiceV2Client`. - * - * To create a concrete instance, see `MakeLoggingServiceV2Connection()`. - * - * For mocking, see `logging_mocks::MockLoggingServiceV2Connection`. - */ -class LoggingServiceV2Connection { - public: - virtual ~LoggingServiceV2Connection() = 0; +/// @deprecated Use logging_v2::LoggingServiceV2LimitedTimeRetryPolicy directly. +using ::google::cloud::logging_v2::LoggingServiceV2LimitedTimeRetryPolicy; - virtual Options options() { return Options{}; } - - virtual Status DeleteLog( - google::logging::v2::DeleteLogRequest const& request); - - virtual StatusOr - WriteLogEntries(google::logging::v2::WriteLogEntriesRequest const& request); - - virtual StreamRange ListLogEntries( - google::logging::v2::ListLogEntriesRequest request); - - virtual StreamRange - ListMonitoredResourceDescriptors( - google::logging::v2::ListMonitoredResourceDescriptorsRequest request); - - virtual StreamRange ListLogs( - google::logging::v2::ListLogsRequest request); - - virtual std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< - google::logging::v2::TailLogEntriesRequest, - google::logging::v2::TailLogEntriesResponse>> - AsyncTailLogEntries(); - - virtual future> - AsyncWriteLogEntries( - google::logging::v2::WriteLogEntriesRequest const& request); -}; - -/** - * A factory function to construct an object of type - * `LoggingServiceV2Connection`. - * - * The returned connection object should not be used directly; instead it - * should be passed as an argument to the constructor of LoggingServiceV2Client. - * - * The optional @p options argument may be used to configure aspects of the - * returned `LoggingServiceV2Connection`. Expected options are any of the types - * in the following option lists: - * - * - `google::cloud::CommonOptionList` - * - `google::cloud::GrpcOptionList` - * - `google::cloud::UnifiedCredentialsOptionList` - * - `google::cloud::logging::LoggingServiceV2PolicyOptionList` - * - * @note Unexpected options will be ignored. To log unexpected options instead, - * set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment. - * - * @param options (optional) Configure the `LoggingServiceV2Connection` created - * by this function. - */ -std::shared_ptr MakeLoggingServiceV2Connection( - Options options = {}); +/// @deprecated Use logging_v2::LoggingServiceV2RetryPolicy directly. +using ::google::cloud::logging_v2::LoggingServiceV2RetryPolicy; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging diff --git a/google/cloud/logging/logging_service_v2_connection_idempotency_policy.h b/google/cloud/logging/logging_service_v2_connection_idempotency_policy.h index 251b5e7e129a..bf6becb4dfe5 100644 --- a/google/cloud/logging/logging_service_v2_connection_idempotency_policy.h +++ b/google/cloud/logging/logging_service_v2_connection_idempotency_policy.h @@ -19,43 +19,21 @@ #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_LOGGING_SERVICE_V2_CONNECTION_IDEMPOTENCY_POLICY_H #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_LOGGING_SERVICE_V2_CONNECTION_IDEMPOTENCY_POLICY_H -#include "google/cloud/idempotency.h" -#include "google/cloud/internal/retry_policy.h" -#include "google/cloud/version.h" -#include -#include +#include "google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h" namespace google { namespace cloud { namespace logging { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -class LoggingServiceV2ConnectionIdempotencyPolicy { - public: - virtual ~LoggingServiceV2ConnectionIdempotencyPolicy(); +/// @deprecated Use +/// logging_v2::MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy directly. +using ::google::cloud::logging_v2:: + MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy; - /// Create a new copy of this object. - virtual std::unique_ptr clone() - const; - - virtual google::cloud::Idempotency DeleteLog( - google::logging::v2::DeleteLogRequest const& request); - - virtual google::cloud::Idempotency WriteLogEntries( - google::logging::v2::WriteLogEntriesRequest const& request); - - virtual google::cloud::Idempotency ListLogEntries( - google::logging::v2::ListLogEntriesRequest request); - - virtual google::cloud::Idempotency ListMonitoredResourceDescriptors( - google::logging::v2::ListMonitoredResourceDescriptorsRequest request); - - virtual google::cloud::Idempotency ListLogs( - google::logging::v2::ListLogsRequest request); -}; - -std::unique_ptr -MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy(); +/// @deprecated Use logging_v2::LoggingServiceV2ConnectionIdempotencyPolicy +/// directly. +using ::google::cloud::logging_v2::LoggingServiceV2ConnectionIdempotencyPolicy; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging diff --git a/google/cloud/logging/logging_service_v2_options.h b/google/cloud/logging/logging_service_v2_options.h index 987d82cf7f02..4da2887298b9 100644 --- a/google/cloud/logging/logging_service_v2_options.h +++ b/google/cloud/logging/logging_service_v2_options.h @@ -21,52 +21,26 @@ #include "google/cloud/logging/logging_service_v2_connection.h" #include "google/cloud/logging/logging_service_v2_connection_idempotency_policy.h" -#include "google/cloud/backoff_policy.h" -#include "google/cloud/options.h" -#include "google/cloud/version.h" -#include +#include "google/cloud/logging/v2/logging_service_v2_options.h" namespace google { namespace cloud { namespace logging { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -/** - * Use with `google::cloud::Options` to configure the retry policy. - * - * @ingroup google-cloud-logging-options - */ -struct LoggingServiceV2RetryPolicyOption { - using Type = std::shared_ptr; -}; +/// @deprecated Use logging_v2::LoggingServiceV2BackoffPolicyOption directly. +using ::google::cloud::logging_v2::LoggingServiceV2BackoffPolicyOption; -/** - * Use with `google::cloud::Options` to configure the backoff policy. - * - * @ingroup google-cloud-logging-options - */ -struct LoggingServiceV2BackoffPolicyOption { - using Type = std::shared_ptr; -}; +/// @deprecated Use +/// logging_v2::LoggingServiceV2ConnectionIdempotencyPolicyOption directly. +using ::google::cloud::logging_v2:: + LoggingServiceV2ConnectionIdempotencyPolicyOption; -/** - * Use with `google::cloud::Options` to configure which operations are retried. - * - * @ingroup google-cloud-logging-options - */ -struct LoggingServiceV2ConnectionIdempotencyPolicyOption { - using Type = std::shared_ptr; -}; +/// @deprecated Use logging_v2::LoggingServiceV2PolicyOptionList directly. +using ::google::cloud::logging_v2::LoggingServiceV2PolicyOptionList; -/** - * The options applicable to LoggingServiceV2. - * - * @ingroup google-cloud-logging-options - */ -using LoggingServiceV2PolicyOptionList = - OptionList; +/// @deprecated Use logging_v2::LoggingServiceV2RetryPolicyOption directly. +using ::google::cloud::logging_v2::LoggingServiceV2RetryPolicyOption; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging diff --git a/google/cloud/logging/mocks/mock_logging_service_v2_connection.h b/google/cloud/logging/mocks/mock_logging_service_v2_connection.h index f3c391600f14..2dae7b03af33 100644 --- a/google/cloud/logging/mocks/mock_logging_service_v2_connection.h +++ b/google/cloud/logging/mocks/mock_logging_service_v2_connection.h @@ -20,64 +20,15 @@ #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_MOCKS_MOCK_LOGGING_SERVICE_V2_CONNECTION_H #include "google/cloud/logging/logging_service_v2_connection.h" -#include +#include "google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h" namespace google { namespace cloud { namespace logging_mocks { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN -/** - * A class to mock `LoggingServiceV2Connection`. - * - * Application developers may want to test their code with simulated responses, - * including errors, from an object of type `LoggingServiceV2Client`. To do so, - * construct an object of type `LoggingServiceV2Client` with an instance of this - * class. Then use the Google Test framework functions to program the behavior - * of this mock. - * - * @see [This example][bq-mock] for how to test your application with GoogleTest. - * While the example showcases types from the BigQuery library, the underlying - * principles apply for any pair of `*Client` and `*Connection`. - * - * [bq-mock]: @googleapis_dev_link{bigquery,bigquery-read-mock.html} - */ -class MockLoggingServiceV2Connection - : public logging::LoggingServiceV2Connection { - public: - MOCK_METHOD(Options, options, (), (override)); - - MOCK_METHOD(Status, DeleteLog, - (google::logging::v2::DeleteLogRequest const& request), - (override)); - - MOCK_METHOD(StatusOr, - WriteLogEntries, - (google::logging::v2::WriteLogEntriesRequest const& request), - (override)); - - MOCK_METHOD(StreamRange, ListLogEntries, - (google::logging::v2::ListLogEntriesRequest request), (override)); - - MOCK_METHOD( - StreamRange, - ListMonitoredResourceDescriptors, - (google::logging::v2::ListMonitoredResourceDescriptorsRequest request), - (override)); - - MOCK_METHOD(StreamRange, ListLogs, - (google::logging::v2::ListLogsRequest request), (override)); - - MOCK_METHOD((std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< - google::logging::v2::TailLogEntriesRequest, - google::logging::v2::TailLogEntriesResponse>>), - AsyncTailLogEntries, (), (override)); - - MOCK_METHOD(future>, - AsyncWriteLogEntries, - (google::logging::v2::WriteLogEntriesRequest const& request), - (override)); -}; +/// @deprecated Use logging_v2_mocks::MockLoggingServiceV2Connection directly. +using ::google::cloud::logging_v2_mocks::MockLoggingServiceV2Connection; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END } // namespace logging_mocks diff --git a/google/cloud/logging/samples/BUILD.bazel b/google/cloud/logging/samples/BUILD.bazel deleted file mode 100644 index 7ebc7fcbe71b..000000000000 --- a/google/cloud/logging/samples/BUILD.bazel +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright 2022 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 - -[cc_test( - name = sample.replace(".cc", ""), - srcs = [sample], - tags = ["integration-test"], - deps = [ - "//:logging", - "//google/cloud/testing_util:google_cloud_cpp_testing_private", - ], -) for sample in glob(["*.cc"])] diff --git a/google/cloud/logging/samples/CMakeLists.txt b/google/cloud/logging/samples/CMakeLists.txt deleted file mode 100644 index ced3dd32dcbd..000000000000 --- a/google/cloud/logging/samples/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 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. - -if ((NOT BUILD_TESTING) OR (NOT GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS)) - return() -endif () - -google_cloud_cpp_add_samples(logging) diff --git a/google/cloud/logging/internal/logging_service_v2_auth_decorator.cc b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.cc similarity index 96% rename from google/cloud/logging/internal/logging_service_v2_auth_decorator.cc rename to google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.cc index fef57875d670..f046772cc74a 100644 --- a/google/cloud/logging/internal/logging_service_v2_auth_decorator.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.cc @@ -16,14 +16,14 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_auth_decorator.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h" #include "google/cloud/internal/async_read_write_stream_auth.h" #include #include namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN LoggingServiceV2Auth::LoggingServiceV2Auth( @@ -113,6 +113,6 @@ LoggingServiceV2Auth::AsyncWriteLogEntries( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_auth_decorator.h b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h similarity index 88% rename from google/cloud/logging/internal/logging_service_v2_auth_decorator.h rename to google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h index f5769986fe59..bd4a6f251483 100644 --- a/google/cloud/logging/internal/logging_service_v2_auth_decorator.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h @@ -16,10 +16,10 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_AUTH_DECORATOR_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_AUTH_DECORATOR_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_AUTH_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_AUTH_DECORATOR_H -#include "google/cloud/logging/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" #include "google/cloud/internal/unified_grpc_credentials.h" #include "google/cloud/version.h" #include @@ -28,7 +28,7 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN class LoggingServiceV2Auth : public LoggingServiceV2Stub { @@ -78,8 +78,8 @@ class LoggingServiceV2Auth : public LoggingServiceV2Stub { }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_AUTH_DECORATOR_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_AUTH_DECORATOR_H diff --git a/google/cloud/logging/internal/logging_service_v2_connection_impl.cc b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.cc similarity index 93% rename from google/cloud/logging/internal/logging_service_v2_connection_impl.cc rename to google/cloud/logging/v2/internal/logging_service_v2_connection_impl.cc index 4c4f29d00845..7639fa359613 100644 --- a/google/cloud/logging/internal/logging_service_v2_connection_impl.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.cc @@ -16,8 +16,8 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_connection_impl.h" -#include "google/cloud/logging/internal/logging_service_v2_option_defaults.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_option_defaults.h" #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" @@ -28,12 +28,12 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN LoggingServiceV2ConnectionImpl::LoggingServiceV2ConnectionImpl( std::unique_ptr background, - std::shared_ptr stub, + std::shared_ptr stub, Options options) : background_(std::move(background)), stub_(std::move(stub)), @@ -70,7 +70,7 @@ LoggingServiceV2ConnectionImpl::ListLogEntries( google::logging::v2::ListLogEntriesRequest request) { request.clear_page_token(); auto& stub = stub_; - auto retry = std::shared_ptr( + auto retry = std::shared_ptr( retry_policy()); auto backoff = std::shared_ptr(backoff_policy()); auto idempotency = idempotency_policy()->ListLogEntries(request); @@ -101,7 +101,7 @@ LoggingServiceV2ConnectionImpl::ListMonitoredResourceDescriptors( google::logging::v2::ListMonitoredResourceDescriptorsRequest request) { request.clear_page_token(); auto& stub = stub_; - auto retry = std::shared_ptr( + auto retry = std::shared_ptr( retry_policy()); auto backoff = std::shared_ptr(backoff_policy()); auto idempotency = @@ -135,7 +135,7 @@ StreamRange LoggingServiceV2ConnectionImpl::ListLogs( google::logging::v2::ListLogsRequest request) { request.clear_page_token(); auto& stub = stub_; - auto retry = std::shared_ptr( + auto retry = std::shared_ptr( retry_policy()); auto backoff = std::shared_ptr(backoff_policy()); auto idempotency = idempotency_policy()->ListLogs(request); @@ -175,6 +175,6 @@ LoggingServiceV2ConnectionImpl::AsyncWriteLogEntries( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_connection_impl.h b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h similarity index 63% rename from google/cloud/logging/internal/logging_service_v2_connection_impl.h rename to google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h index fcfe4dfe932b..acbf52d07732 100644 --- a/google/cloud/logging/internal/logging_service_v2_connection_impl.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h @@ -16,14 +16,14 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_CONNECTION_IMPL_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_CONNECTION_IMPL_H - -#include "google/cloud/logging/internal/logging_service_v2_retry_traits.h" -#include "google/cloud/logging/internal/logging_service_v2_stub.h" -#include "google/cloud/logging/logging_service_v2_connection.h" -#include "google/cloud/logging/logging_service_v2_connection_idempotency_policy.h" -#include "google/cloud/logging/logging_service_v2_options.h" +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_CONNECTION_IMPL_H + +#include "google/cloud/logging/v2/internal/logging_service_v2_retry_traits.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/logging_service_v2_connection.h" +#include "google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h" +#include "google/cloud/logging/v2/logging_service_v2_options.h" #include "google/cloud/async_streaming_read_write_rpc.h" #include "google/cloud/background_threads.h" #include "google/cloud/backoff_policy.h" @@ -35,17 +35,17 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN class LoggingServiceV2ConnectionImpl - : public logging::LoggingServiceV2Connection { + : public logging_v2::LoggingServiceV2Connection { public: ~LoggingServiceV2ConnectionImpl() override = default; LoggingServiceV2ConnectionImpl( std::unique_ptr background, - std::shared_ptr stub, + std::shared_ptr stub, Options options); Options options() override { return options_; } @@ -77,46 +77,48 @@ class LoggingServiceV2ConnectionImpl google::logging::v2::WriteLogEntriesRequest const& request) override; private: - std::unique_ptr retry_policy() { + std::unique_ptr retry_policy() { auto const& options = internal::CurrentOptions(); - if (options.has()) { - return options.get()->clone(); + if (options.has()) { + return options.get() + ->clone(); } - return options_.get()->clone(); + return options_.get() + ->clone(); } std::unique_ptr backoff_policy() { auto const& options = internal::CurrentOptions(); - if (options.has()) { - return options.get() + if (options.has()) { + return options.get() ->clone(); } - return options_.get() + return options_.get() ->clone(); } - std::unique_ptr + std::unique_ptr idempotency_policy() { auto const& options = internal::CurrentOptions(); if (options.has< - logging::LoggingServiceV2ConnectionIdempotencyPolicyOption>()) { + logging_v2::LoggingServiceV2ConnectionIdempotencyPolicyOption>()) { return options - .get() + .get() ->clone(); } return options_ - .get() + .get() ->clone(); } std::unique_ptr background_; - std::shared_ptr stub_; + std::shared_ptr stub_; Options options_; }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_CONNECTION_IMPL_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_CONNECTION_IMPL_H diff --git a/google/cloud/logging/internal/logging_service_v2_logging_decorator.cc b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.cc similarity index 97% rename from google/cloud/logging/internal/logging_service_v2_logging_decorator.cc rename to google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.cc index b62d43928efa..5328d3c1feac 100644 --- a/google/cloud/logging/internal/logging_service_v2_logging_decorator.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.cc @@ -16,7 +16,7 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_logging_decorator.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h" #include "google/cloud/internal/async_read_write_stream_logging.h" #include "google/cloud/internal/log_wrapper.h" #include "google/cloud/status_or.h" @@ -25,7 +25,7 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN LoggingServiceV2Logging::LoggingServiceV2Logging( @@ -132,6 +132,6 @@ LoggingServiceV2Logging::AsyncWriteLogEntries( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_logging_decorator.h b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h similarity index 88% rename from google/cloud/logging/internal/logging_service_v2_logging_decorator.h rename to google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h index 860f3daa02b4..16d7cbd34a8e 100644 --- a/google/cloud/logging/internal/logging_service_v2_logging_decorator.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h @@ -16,10 +16,10 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_LOGGING_DECORATOR_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_LOGGING_DECORATOR_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_LOGGING_DECORATOR_H -#include "google/cloud/logging/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" #include "google/cloud/tracing_options.h" #include "google/cloud/version.h" #include @@ -28,7 +28,7 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN class LoggingServiceV2Logging : public LoggingServiceV2Stub { @@ -79,8 +79,8 @@ class LoggingServiceV2Logging : public LoggingServiceV2Stub { }; // LoggingServiceV2Logging GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_LOGGING_DECORATOR_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_LOGGING_DECORATOR_H diff --git a/google/cloud/logging/internal/logging_service_v2_metadata_decorator.cc b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.cc similarity index 96% rename from google/cloud/logging/internal/logging_service_v2_metadata_decorator.cc rename to google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.cc index b3b13480e90e..9a5d9693b309 100644 --- a/google/cloud/logging/internal/logging_service_v2_metadata_decorator.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.cc @@ -16,7 +16,7 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_metadata_decorator.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h" #include "google/cloud/common_options.h" #include "google/cloud/internal/api_client_header.h" #include "google/cloud/status_or.h" @@ -25,7 +25,7 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN LoggingServiceV2Metadata::LoggingServiceV2Metadata( @@ -111,6 +111,6 @@ void LoggingServiceV2Metadata::SetMetadata(grpc::ClientContext& context) { } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_metadata_decorator.h b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h similarity index 87% rename from google/cloud/logging/internal/logging_service_v2_metadata_decorator.h rename to google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h index c4b38f4d4841..db071987ab96 100644 --- a/google/cloud/logging/internal/logging_service_v2_metadata_decorator.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h @@ -16,17 +16,17 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_METADATA_DECORATOR_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_METADATA_DECORATOR_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_METADATA_DECORATOR_H -#include "google/cloud/logging/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" #include "google/cloud/version.h" #include #include namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN class LoggingServiceV2Metadata : public LoggingServiceV2Stub { @@ -79,8 +79,8 @@ class LoggingServiceV2Metadata : public LoggingServiceV2Stub { }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_METADATA_DECORATOR_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_METADATA_DECORATOR_H diff --git a/google/cloud/logging/internal/logging_service_v2_option_defaults.cc b/google/cloud/logging/v2/internal/logging_service_v2_option_defaults.cc similarity index 66% rename from google/cloud/logging/internal/logging_service_v2_option_defaults.cc rename to google/cloud/logging/v2/internal/logging_service_v2_option_defaults.cc index e5604a7af250..160d94bfe9ad 100644 --- a/google/cloud/logging/internal/logging_service_v2_option_defaults.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_option_defaults.cc @@ -16,16 +16,16 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_option_defaults.h" -#include "google/cloud/logging/logging_service_v2_connection.h" -#include "google/cloud/logging/logging_service_v2_options.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_option_defaults.h" +#include "google/cloud/logging/v2/logging_service_v2_connection.h" +#include "google/cloud/logging/v2/logging_service_v2_options.h" #include "google/cloud/internal/populate_common_options.h" #include "google/cloud/internal/populate_grpc_options.h" #include namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN namespace { @@ -39,28 +39,28 @@ Options LoggingServiceV2DefaultOptions(Options options) { "logging.googleapis.com"); options = google::cloud::internal::PopulateGrpcOptions(std::move(options), ""); - if (!options.has()) { - options.set( - logging::LoggingServiceV2LimitedTimeRetryPolicy( + if (!options.has()) { + options.set( + logging_v2::LoggingServiceV2LimitedTimeRetryPolicy( std::chrono::minutes(30)) .clone()); } - if (!options.has()) { - options.set( + if (!options.has()) { + options.set( ExponentialBackoffPolicy(std::chrono::seconds(1), std::chrono::minutes(5), kBackoffScaling) .clone()); } - if (!options - .has()) { - options.set( - logging::MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy()); + if (!options.has< + logging_v2::LoggingServiceV2ConnectionIdempotencyPolicyOption>()) { + options.set( + logging_v2::MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy()); } return options; } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_option_defaults.h b/google/cloud/logging/v2/internal/logging_service_v2_option_defaults.h similarity index 76% rename from google/cloud/logging/internal/logging_service_v2_option_defaults.h rename to google/cloud/logging/v2/internal/logging_service_v2_option_defaults.h index 5258e4d62889..acaec9480b2c 100644 --- a/google/cloud/logging/internal/logging_service_v2_option_defaults.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_option_defaults.h @@ -16,22 +16,22 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_OPTION_DEFAULTS_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_OPTION_DEFAULTS_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_OPTION_DEFAULTS_H #include "google/cloud/options.h" #include "google/cloud/version.h" namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN Options LoggingServiceV2DefaultOptions(Options options); GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_OPTION_DEFAULTS_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_OPTION_DEFAULTS_H diff --git a/google/cloud/logging/internal/logging_service_v2_retry_traits.h b/google/cloud/logging/v2/internal/logging_service_v2_retry_traits.h similarity index 80% rename from google/cloud/logging/internal/logging_service_v2_retry_traits.h rename to google/cloud/logging/v2/internal/logging_service_v2_retry_traits.h index 80f86b89babc..3aa8b94e6cb9 100644 --- a/google/cloud/logging/internal/logging_service_v2_retry_traits.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_retry_traits.h @@ -16,15 +16,15 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_RETRY_TRAITS_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_RETRY_TRAITS_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_RETRY_TRAITS_H #include "google/cloud/status.h" #include "google/cloud/version.h" namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN /// Define the gRPC status code semantics for retrying requests. @@ -37,8 +37,8 @@ struct LoggingServiceV2RetryTraits { }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_RETRY_TRAITS_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_RETRY_TRAITS_H diff --git a/google/cloud/logging/internal/logging_service_v2_stub.cc b/google/cloud/logging/v2/internal/logging_service_v2_stub.cc similarity index 97% rename from google/cloud/logging/internal/logging_service_v2_stub.cc rename to google/cloud/logging/v2/internal/logging_service_v2_stub.cc index 64f059552aca..873882df203b 100644 --- a/google/cloud/logging/internal/logging_service_v2_stub.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_stub.cc @@ -16,7 +16,7 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" #include "google/cloud/grpc_error_delegate.h" #include "google/cloud/internal/async_read_write_stream_impl.h" #include "google/cloud/status_or.h" @@ -25,7 +25,7 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN LoggingServiceV2Stub::~LoggingServiceV2Stub() = default; @@ -122,6 +122,6 @@ DefaultLoggingServiceV2Stub::AsyncWriteLogEntries( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_stub.h b/google/cloud/logging/v2/internal/logging_service_v2_stub.h similarity index 93% rename from google/cloud/logging/internal/logging_service_v2_stub.h rename to google/cloud/logging/v2/internal/logging_service_v2_stub.h index 4208acfe253d..b4b62c202332 100644 --- a/google/cloud/logging/internal/logging_service_v2_stub.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_stub.h @@ -16,8 +16,8 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_STUB_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_STUB_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_STUB_H #include "google/cloud/async_streaming_read_write_rpc.h" #include "google/cloud/completion_queue.h" @@ -29,7 +29,7 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN class LoggingServiceV2Stub { @@ -120,8 +120,8 @@ class DefaultLoggingServiceV2Stub : public LoggingServiceV2Stub { }; GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_STUB_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_STUB_H diff --git a/google/cloud/logging/internal/logging_service_v2_stub_factory.cc b/google/cloud/logging/v2/internal/logging_service_v2_stub_factory.cc similarity index 82% rename from google/cloud/logging/internal/logging_service_v2_stub_factory.cc rename to google/cloud/logging/v2/internal/logging_service_v2_stub_factory.cc index 150ecc40371a..015fe429668d 100644 --- a/google/cloud/logging/internal/logging_service_v2_stub_factory.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_stub_factory.cc @@ -16,12 +16,12 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_stub_factory.h" -#include "google/cloud/logging/internal/logging_service_v2_auth_decorator.h" -#include "google/cloud/logging/internal/logging_service_v2_logging_decorator.h" -#include "google/cloud/logging/internal/logging_service_v2_metadata_decorator.h" -#include "google/cloud/logging/internal/logging_service_v2_stub.h" -#include "google/cloud/logging/internal/logging_service_v2_tracing_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub_factory.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_auth_decorator.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_logging_decorator.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_metadata_decorator.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h" #include "google/cloud/common_options.h" #include "google/cloud/grpc_options.h" #include "google/cloud/internal/algorithm.h" @@ -33,7 +33,7 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN std::shared_ptr CreateDefaultLoggingServiceV2Stub( @@ -66,6 +66,6 @@ std::shared_ptr CreateDefaultLoggingServiceV2Stub( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_stub_factory.h b/google/cloud/logging/v2/internal/logging_service_v2_stub_factory.h similarity index 76% rename from google/cloud/logging/internal/logging_service_v2_stub_factory.h rename to google/cloud/logging/v2/internal/logging_service_v2_stub_factory.h index bd2032761f82..720b1024565e 100644 --- a/google/cloud/logging/internal/logging_service_v2_stub_factory.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_stub_factory.h @@ -16,10 +16,10 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_STUB_FACTORY_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_STUB_FACTORY_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_STUB_FACTORY_H -#include "google/cloud/logging/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" #include "google/cloud/completion_queue.h" #include "google/cloud/credentials.h" #include "google/cloud/internal/unified_grpc_credentials.h" @@ -28,15 +28,15 @@ namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN std::shared_ptr CreateDefaultLoggingServiceV2Stub( google::cloud::CompletionQueue cq, Options const& options); GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_STUB_FACTORY_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_STUB_FACTORY_H diff --git a/google/cloud/logging/internal/logging_service_v2_tracing_connection.cc b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.cc similarity index 83% rename from google/cloud/logging/internal/logging_service_v2_tracing_connection.cc rename to google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.cc index 16b82fe1e5e6..9c5cbe62b8a0 100644 --- a/google/cloud/logging/internal/logging_service_v2_tracing_connection.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.cc @@ -16,26 +16,26 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_tracing_connection.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h" #include "google/cloud/internal/opentelemetry.h" #include "google/cloud/internal/traced_stream_range.h" #include namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN #ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY LoggingServiceV2TracingConnection::LoggingServiceV2TracingConnection( - std::shared_ptr child) + std::shared_ptr child) : child_(std::move(child)) {} Status LoggingServiceV2TracingConnection::DeleteLog( google::logging::v2::DeleteLogRequest const& request) { auto span = - internal::MakeSpan("logging::LoggingServiceV2Connection::DeleteLog"); + internal::MakeSpan("logging_v2::LoggingServiceV2Connection::DeleteLog"); auto scope = opentelemetry::trace::Scope(span); return internal::EndSpan(*span, child_->DeleteLog(request)); } @@ -44,7 +44,7 @@ StatusOr LoggingServiceV2TracingConnection::WriteLogEntries( google::logging::v2::WriteLogEntriesRequest const& request) { auto span = internal::MakeSpan( - "logging::LoggingServiceV2Connection::WriteLogEntries"); + "logging_v2::LoggingServiceV2Connection::WriteLogEntries"); auto scope = opentelemetry::trace::Scope(span); return internal::EndSpan(*span, child_->WriteLogEntries(request)); } @@ -52,8 +52,8 @@ LoggingServiceV2TracingConnection::WriteLogEntries( StreamRange LoggingServiceV2TracingConnection::ListLogEntries( google::logging::v2::ListLogEntriesRequest request) { - auto span = - internal::MakeSpan("logging::LoggingServiceV2Connection::ListLogEntries"); + auto span = internal::MakeSpan( + "logging_v2::LoggingServiceV2Connection::ListLogEntries"); auto scope = opentelemetry::trace::Scope(span); auto sr = child_->ListLogEntries(std::move(request)); return internal::MakeTracedStreamRange( @@ -64,7 +64,8 @@ StreamRange LoggingServiceV2TracingConnection::ListMonitoredResourceDescriptors( google::logging::v2::ListMonitoredResourceDescriptorsRequest request) { auto span = internal::MakeSpan( - "logging::LoggingServiceV2Connection::ListMonitoredResourceDescriptors"); + "logging_v2::LoggingServiceV2Connection::" + "ListMonitoredResourceDescriptors"); auto scope = opentelemetry::trace::Scope(span); auto sr = child_->ListMonitoredResourceDescriptors(std::move(request)); return internal::MakeTracedStreamRange< @@ -74,7 +75,7 @@ LoggingServiceV2TracingConnection::ListMonitoredResourceDescriptors( StreamRange LoggingServiceV2TracingConnection::ListLogs( google::logging::v2::ListLogsRequest request) { auto span = - internal::MakeSpan("logging::LoggingServiceV2Connection::ListLogs"); + internal::MakeSpan("logging_v2::LoggingServiceV2Connection::ListLogs"); auto scope = opentelemetry::trace::Scope(span); auto sr = child_->ListLogs(std::move(request)); return internal::MakeTracedStreamRange(std::move(span), @@ -96,9 +97,9 @@ LoggingServiceV2TracingConnection::AsyncWriteLogEntries( #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY -std::shared_ptr +std::shared_ptr MakeLoggingServiceV2TracingConnection( - std::shared_ptr conn) { + std::shared_ptr conn) { #ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY if (internal::TracingEnabled(conn->options())) { conn = std::make_shared(std::move(conn)); @@ -108,6 +109,6 @@ MakeLoggingServiceV2TracingConnection( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_tracing_connection.h b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h similarity index 78% rename from google/cloud/logging/internal/logging_service_v2_tracing_connection.h rename to google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h index a2f5b45542b4..d09b63d52cad 100644 --- a/google/cloud/logging/internal/logging_service_v2_tracing_connection.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h @@ -16,27 +16,27 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_TRACING_CONNECTION_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_TRACING_CONNECTION_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_TRACING_CONNECTION_H -#include "google/cloud/logging/logging_service_v2_connection.h" +#include "google/cloud/logging/v2/logging_service_v2_connection.h" #include "google/cloud/version.h" #include namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN #ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY class LoggingServiceV2TracingConnection - : public logging::LoggingServiceV2Connection { + : public logging_v2::LoggingServiceV2Connection { public: ~LoggingServiceV2TracingConnection() override = default; explicit LoggingServiceV2TracingConnection( - std::shared_ptr child); + std::shared_ptr child); Options options() override { return child_->options(); } @@ -67,7 +67,7 @@ class LoggingServiceV2TracingConnection google::logging::v2::WriteLogEntriesRequest const& request) override; private: - std::shared_ptr child_; + std::shared_ptr child_; }; #endif // GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY @@ -78,13 +78,13 @@ class LoggingServiceV2TracingConnection * The connection is only decorated if tracing is enabled (as determined by the * connection's options). */ -std::shared_ptr +std::shared_ptr MakeLoggingServiceV2TracingConnection( - std::shared_ptr conn); + std::shared_ptr conn); GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_TRACING_CONNECTION_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_TRACING_CONNECTION_H diff --git a/google/cloud/logging/internal/logging_service_v2_tracing_stub.cc b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.cc similarity index 97% rename from google/cloud/logging/internal/logging_service_v2_tracing_stub.cc rename to google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.cc index cc6a6b5155bb..b886aa36b4fd 100644 --- a/google/cloud/logging/internal/logging_service_v2_tracing_stub.cc +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.cc @@ -16,12 +16,12 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/internal/logging_service_v2_tracing_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h" #include "google/cloud/internal/grpc_opentelemetry.h" namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN #ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY @@ -118,6 +118,6 @@ std::shared_ptr MakeLoggingServiceV2TracingStub( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/internal/logging_service_v2_tracing_stub.h b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h similarity index 88% rename from google/cloud/logging/internal/logging_service_v2_tracing_stub.h rename to google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h index 811f2fff910a..a248c39db7d6 100644 --- a/google/cloud/logging/internal/logging_service_v2_tracing_stub.h +++ b/google/cloud/logging/v2/internal/logging_service_v2_tracing_stub.h @@ -16,16 +16,16 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_TRACING_STUB_H -#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_TRACING_STUB_H +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_TRACING_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_TRACING_STUB_H -#include "google/cloud/logging/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" #include "google/cloud/options.h" #include "google/cloud/version.h" namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN #ifdef GOOGLE_CLOUD_CPP_HAVE_OPENTELEMETRY @@ -87,8 +87,8 @@ std::shared_ptr MakeLoggingServiceV2TracingStub( std::shared_ptr stub); GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google -#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_INTERNAL_LOGGING_SERVICE_V2_TRACING_STUB_H +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_INTERNAL_LOGGING_SERVICE_V2_TRACING_STUB_H diff --git a/google/cloud/logging/internal/streaming.cc b/google/cloud/logging/v2/internal/streaming.cc similarity index 88% rename from google/cloud/logging/internal/streaming.cc rename to google/cloud/logging/v2/internal/streaming.cc index 2225c3f6402b..c5376c13bf8d 100644 --- a/google/cloud/logging/internal/streaming.cc +++ b/google/cloud/logging/v2/internal/streaming.cc @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "google/cloud/logging/internal/logging_service_v2_connection_impl.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h" #include namespace google { namespace cloud { -namespace logging_internal { +namespace logging_v2_internal { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< @@ -30,6 +30,6 @@ LoggingServiceV2ConnectionImpl::AsyncTailLogEntries() { } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging_internal +} // namespace logging_v2_internal } // namespace cloud } // namespace google diff --git a/google/cloud/logging/logging_service_v2_client.cc b/google/cloud/logging/v2/logging_service_v2_client.cc similarity index 98% rename from google/cloud/logging/logging_service_v2_client.cc rename to google/cloud/logging/v2/logging_service_v2_client.cc index 78530c762463..7554ee78f1d0 100644 --- a/google/cloud/logging/logging_service_v2_client.cc +++ b/google/cloud/logging/v2/logging_service_v2_client.cc @@ -16,12 +16,12 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/logging_service_v2_client.h" +#include "google/cloud/logging/v2/logging_service_v2_client.h" #include namespace google { namespace cloud { -namespace logging { +namespace logging_v2 { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN LoggingServiceV2Client::LoggingServiceV2Client( @@ -138,6 +138,6 @@ LoggingServiceV2Client::AsyncWriteLogEntries( } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging +} // namespace logging_v2 } // namespace cloud } // namespace google diff --git a/google/cloud/logging/v2/logging_service_v2_client.h b/google/cloud/logging/v2/logging_service_v2_client.h new file mode 100644 index 000000000000..9f556e70ba36 --- /dev/null +++ b/google/cloud/logging/v2/logging_service_v2_client.h @@ -0,0 +1,486 @@ +// Copyright 2021 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. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/logging/v2/logging.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CLIENT_H + +#include "google/cloud/logging/v2/logging_service_v2_connection.h" +#include "google/cloud/future.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace logging_v2 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Service for ingesting and querying logs. +/// +/// @par Equality +/// +/// Instances of this class created via copy-construction or copy-assignment +/// always compare equal. Instances created with equal +/// `std::shared_ptr<*Connection>` objects compare equal. Objects that compare +/// equal share the same underlying resources. +/// +/// @par Performance +/// +/// Creating a new instance of this class is a relatively expensive operation, +/// new objects establish new connections to the service. In contrast, +/// copy-construction, move-construction, and the corresponding assignment +/// operations are relatively efficient as the copies share all underlying +/// resources. +/// +/// @par Thread Safety +/// +/// Concurrent access to different instances of this class, even if they compare +/// equal, is guaranteed to work. Two or more threads operating on the same +/// instance of this class is not guaranteed to work. Since copy-construction +/// and move-construction is a relatively efficient operation, consider using +/// such a copy when using this class from multiple threads. +/// +class LoggingServiceV2Client { + public: + explicit LoggingServiceV2Client( + std::shared_ptr connection, + Options opts = {}); + ~LoggingServiceV2Client(); + + ///@{ + /// @name Copy and move support + LoggingServiceV2Client(LoggingServiceV2Client const&) = default; + LoggingServiceV2Client& operator=(LoggingServiceV2Client const&) = default; + LoggingServiceV2Client(LoggingServiceV2Client&&) = default; + LoggingServiceV2Client& operator=(LoggingServiceV2Client&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(LoggingServiceV2Client const& a, + LoggingServiceV2Client const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(LoggingServiceV2Client const& a, + LoggingServiceV2Client const& b) { + return !(a == b); + } + ///@} + + /// + /// Deletes all the log entries in a log for the _Default Log Bucket. The log + /// reappears if it receives new entries. Log entries written shortly before + /// the delete operation might not be deleted. Entries received after the + /// delete operation with a timestamp before the operation will be deleted. + /// + /// @param log_name Required. The resource name of the log to delete: + /// * `projects/[PROJECT_ID]/logs/[LOG_ID]` + /// * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` + /// * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` + /// * `folders/[FOLDER_ID]/logs/[LOG_ID]` + /// `[LOG_ID]` must be URL-encoded. For example, + /// `"projects/my-project-id/logs/syslog"`, + /// `"organizations/123/logs/cloudaudit.googleapis.com%2Factivity"`. + /// For more information about log names, see + /// [LogEntry][google.logging.v2.LogEntry]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// + /// [google.logging.v2.DeleteLogRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L137} + /// + Status DeleteLog(std::string const& log_name, Options opts = {}); + + /// + /// Deletes all the log entries in a log for the _Default Log Bucket. The log + /// reappears if it receives new entries. Log entries written shortly before + /// the delete operation might not be deleted. Entries received after the + /// delete operation with a timestamp before the operation will be deleted. + /// + /// @param request + /// @googleapis_link{google::logging::v2::DeleteLogRequest,google/logging/v2/logging.proto#L137} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// + /// [google.logging.v2.DeleteLogRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L137} + /// + Status DeleteLog(google::logging::v2::DeleteLogRequest const& request, + Options opts = {}); + + /// + /// Writes log entries to Logging. This API method is the + /// only way to send log entries to Logging. This method + /// is used, directly or indirectly, by the Logging agent + /// (fluentd) and all logging libraries configured to use Logging. + /// A single request may contain log entries for a maximum of 1000 + /// different resources (projects, organizations, billing accounts or + /// folders) + /// + /// @param log_name Optional. A default log resource name that is assigned to + /// all log entries + /// in `entries` that do not specify a value for `log_name`: + /// * `projects/[PROJECT_ID]/logs/[LOG_ID]` + /// * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` + /// * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` + /// * `folders/[FOLDER_ID]/logs/[LOG_ID]` + /// `[LOG_ID]` must be URL-encoded. For example: + /// "projects/my-project-id/logs/syslog" + /// "organizations/123/logs/cloudaudit.googleapis.com%2Factivity" + /// The permission `logging.logEntries.create` is needed on each project, + /// organization, billing account, or folder that is receiving new log + /// entries, whether the resource is specified in `logName` or in an + /// individual log entry. + /// @param resource Optional. A default monitored resource object that is + /// assigned to all log + /// entries in `entries` that do not specify a value for `resource`. Example: + /// { "type": "gce_instance", + /// "labels": { + /// "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + /// See [LogEntry][google.logging.v2.LogEntry]. + /// @param labels Optional. Default labels that are added to the `labels` + /// field of all log + /// entries in `entries`. If a log entry already has a label with the same + /// key as a label in this parameter, then the log entry's label is not + /// changed. See [LogEntry][google.logging.v2.LogEntry]. + /// @param entries Required. The log entries to send to Logging. The order of + /// log + /// entries in this list does not matter. Values supplied in this method's + /// `log_name`, `resource`, and `labels` fields are copied into those log + /// entries in this list that do not include values for their corresponding + /// fields. For more information, see the + /// [LogEntry][google.logging.v2.LogEntry] type. + /// If the `timestamp` or `insert_id` fields are missing in log entries, then + /// this method supplies the current time or a unique identifier, + /// respectively. The supplied values are chosen so that, among the log + /// entries that did not supply their own values, the entries earlier in the + /// list will sort before the entries later in the list. See the + /// `entries.list` method. Log entries with timestamps that are more than the + /// [logs retention period](https://cloud.google.com/logging/quotas) in + /// the past or more than 24 hours in the future will not be available when + /// calling `entries.list`. However, those log entries can still be [exported + /// with + /// LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). + /// To improve throughput and to avoid exceeding the + /// [quota limit](https://cloud.google.com/logging/quotas) for calls to + /// `entries.write`, you should try to include several log entries in this + /// list, rather than calling this method for each individual log entry. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} + /// + /// [google.logging.v2.WriteLogEntriesRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} + /// [google.logging.v2.WriteLogEntriesResponse]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} + /// + StatusOr WriteLogEntries( + std::string const& log_name, + google::api::MonitoredResource const& resource, + std::map const& labels, + std::vector const& entries, + Options opts = {}); + + /// + /// Writes log entries to Logging. This API method is the + /// only way to send log entries to Logging. This method + /// is used, directly or indirectly, by the Logging agent + /// (fluentd) and all logging libraries configured to use Logging. + /// A single request may contain log entries for a maximum of 1000 + /// different resources (projects, organizations, billing accounts or + /// folders) + /// + /// @param request + /// @googleapis_link{google::logging::v2::WriteLogEntriesRequest,google/logging/v2/logging.proto#L160} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} + /// + /// [google.logging.v2.WriteLogEntriesRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} + /// [google.logging.v2.WriteLogEntriesResponse]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} + /// + StatusOr WriteLogEntries( + google::logging::v2::WriteLogEntriesRequest const& request, + Options opts = {}); + + /// + /// Lists log entries. Use this method to retrieve log entries that + /// originated from a project/folder/organization/billing account. For ways + /// to export log entries, see [Exporting + /// Logs](https://cloud.google.com/logging/docs/export). + /// + /// @param resource_names Required. Names of one or more parent resources + /// from which to + /// retrieve log entries: + /// * `projects/[PROJECT_ID]` + /// * `organizations/[ORGANIZATION_ID]` + /// * `billingAccounts/[BILLING_ACCOUNT_ID]` + /// * `folders/[FOLDER_ID]` + /// May alternatively be one or more views: + /// * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + /// * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + /// * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + /// * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` + /// Projects listed in the `project_ids` field are added to this list. + /// @param filter Optional. A filter that chooses which log entries to + /// return. See [Advanced + /// Logs + /// Queries](https://cloud.google.com/logging/docs/view/advanced-queries). + /// Only log entries that match the filter are returned. An empty filter + /// matches all log entries in the resources listed in `resource_names`. + /// Referencing a parent resource that is not listed in `resource_names` will + /// cause the filter to return no results. The maximum length of the filter + /// is 20000 characters. + /// @param order_by Optional. How the results should be sorted. Presently, + /// the only permitted + /// values are `"timestamp asc"` (default) and `"timestamp desc"`. The first + /// option returns entries in order of increasing values of + /// `LogEntry.timestamp` (oldest first), and the second option returns + /// entries in order of decreasing timestamps (newest first). Entries with + /// equal timestamps are returned in order of their `insert_id` values. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::logging::v2::LogEntry,google/logging/v2/log_entry.proto#L38} + /// + /// [google.logging.v2.ListLogEntriesRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L257} + /// [google.logging.v2.LogEntry]: + /// @googleapis_reference_link{google/logging/v2/log_entry.proto#L38} + /// + StreamRange ListLogEntries( + std::vector const& resource_names, std::string const& filter, + std::string const& order_by, Options opts = {}); + + /// + /// Lists log entries. Use this method to retrieve log entries that + /// originated from a project/folder/organization/billing account. For ways + /// to export log entries, see [Exporting + /// Logs](https://cloud.google.com/logging/docs/export). + /// + /// @param request + /// @googleapis_link{google::logging::v2::ListLogEntriesRequest,google/logging/v2/logging.proto#L257} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::logging::v2::LogEntry,google/logging/v2/log_entry.proto#L38} + /// + /// [google.logging.v2.ListLogEntriesRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L257} + /// [google.logging.v2.LogEntry]: + /// @googleapis_reference_link{google/logging/v2/log_entry.proto#L38} + /// + StreamRange ListLogEntries( + google::logging::v2::ListLogEntriesRequest request, Options opts = {}); + + /// + /// Lists the descriptors for monitored resource types used by Logging. + /// + /// @param request + /// @googleapis_link{google::logging::v2::ListMonitoredResourceDescriptorsRequest,google/logging/v2/logging.proto#L332} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::api::MonitoredResourceDescriptor,google/api/monitored_resource.proto#L40} + /// + /// [google.api.MonitoredResourceDescriptor]: + /// @googleapis_reference_link{google/api/monitored_resource.proto#L40} + /// [google.logging.v2.ListMonitoredResourceDescriptorsRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L332} + /// + StreamRange + ListMonitoredResourceDescriptors( + google::logging::v2::ListMonitoredResourceDescriptorsRequest request, + Options opts = {}); + + /// + /// Lists the logs in projects, organizations, folders, or billing accounts. + /// Only logs that have entries are listed. + /// + /// @param parent Required. The resource name that owns the logs: + /// * `projects/[PROJECT_ID]` + /// * `organizations/[ORGANIZATION_ID]` + /// * `billingAccounts/[BILLING_ACCOUNT_ID]` + /// * `folders/[FOLDER_ID]` + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return std::string + /// + /// [google.logging.v2.ListLogsRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L357} + /// + StreamRange ListLogs(std::string const& parent, + Options opts = {}); + + /// + /// Lists the logs in projects, organizations, folders, or billing accounts. + /// Only logs that have entries are listed. + /// + /// @param request + /// @googleapis_link{google::logging::v2::ListLogsRequest,google/logging/v2/logging.proto#L357} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return std::string + /// + /// [google.logging.v2.ListLogsRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L357} + /// + StreamRange ListLogs( + google::logging::v2::ListLogsRequest request, Options opts = {}); + + /// + /// Streaming read of log entries as they are ingested. Until the stream is + /// terminated, it will continue reading logs. + /// + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A bidirectional streaming interface with request (write) type: + /// @googleapis_link{google::logging::v2::TailLogEntriesRequest,google/logging/v2/logging.proto#L417} + /// and response (read) type: + /// @googleapis_link{google::logging::v2::TailLogEntriesResponse,google/logging/v2/logging.proto#L450} + /// + /// [google.logging.v2.TailLogEntriesRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L417} + /// [google.logging.v2.TailLogEntriesResponse]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L450} + /// + std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::logging::v2::TailLogEntriesRequest, + google::logging::v2::TailLogEntriesResponse>> + AsyncTailLogEntries(Options opts = {}); + + /// + /// Writes log entries to Logging. This API method is the + /// only way to send log entries to Logging. This method + /// is used, directly or indirectly, by the Logging agent + /// (fluentd) and all logging libraries configured to use Logging. + /// A single request may contain log entries for a maximum of 1000 + /// different resources (projects, organizations, billing accounts or + /// folders) + /// + /// @param log_name Optional. A default log resource name that is assigned to + /// all log entries + /// in `entries` that do not specify a value for `log_name`: + /// * `projects/[PROJECT_ID]/logs/[LOG_ID]` + /// * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` + /// * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` + /// * `folders/[FOLDER_ID]/logs/[LOG_ID]` + /// `[LOG_ID]` must be URL-encoded. For example: + /// "projects/my-project-id/logs/syslog" + /// "organizations/123/logs/cloudaudit.googleapis.com%2Factivity" + /// The permission `logging.logEntries.create` is needed on each project, + /// organization, billing account, or folder that is receiving new log + /// entries, whether the resource is specified in `logName` or in an + /// individual log entry. + /// @param resource Optional. A default monitored resource object that is + /// assigned to all log + /// entries in `entries` that do not specify a value for `resource`. Example: + /// { "type": "gce_instance", + /// "labels": { + /// "zone": "us-central1-a", "instance_id": "00000000000000000000" }} + /// See [LogEntry][google.logging.v2.LogEntry]. + /// @param labels Optional. Default labels that are added to the `labels` + /// field of all log + /// entries in `entries`. If a log entry already has a label with the same + /// key as a label in this parameter, then the log entry's label is not + /// changed. See [LogEntry][google.logging.v2.LogEntry]. + /// @param entries Required. The log entries to send to Logging. The order of + /// log + /// entries in this list does not matter. Values supplied in this method's + /// `log_name`, `resource`, and `labels` fields are copied into those log + /// entries in this list that do not include values for their corresponding + /// fields. For more information, see the + /// [LogEntry][google.logging.v2.LogEntry] type. + /// If the `timestamp` or `insert_id` fields are missing in log entries, then + /// this method supplies the current time or a unique identifier, + /// respectively. The supplied values are chosen so that, among the log + /// entries that did not supply their own values, the entries earlier in the + /// list will sort before the entries later in the list. See the + /// `entries.list` method. Log entries with timestamps that are more than the + /// [logs retention period](https://cloud.google.com/logging/quotas) in + /// the past or more than 24 hours in the future will not be available when + /// calling `entries.list`. However, those log entries can still be [exported + /// with + /// LogSinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs). + /// To improve throughput and to avoid exceeding the + /// [quota limit](https://cloud.google.com/logging/quotas) for calls to + /// `entries.write`, you should try to include several log entries in this + /// list, rather than calling this method for each individual log entry. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} + /// + /// [google.logging.v2.WriteLogEntriesRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} + /// [google.logging.v2.WriteLogEntriesResponse]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} + /// + future> + AsyncWriteLogEntries( + std::string const& log_name, + google::api::MonitoredResource const& resource, + std::map const& labels, + std::vector const& entries, + Options opts = {}); + + /// + /// Writes log entries to Logging. This API method is the + /// only way to send log entries to Logging. This method + /// is used, directly or indirectly, by the Logging agent + /// (fluentd) and all logging libraries configured to use Logging. + /// A single request may contain log entries for a maximum of 1000 + /// different resources (projects, organizations, billing accounts or + /// folders) + /// + /// @param request + /// @googleapis_link{google::logging::v2::WriteLogEntriesRequest,google/logging/v2/logging.proto#L160} + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return + /// @googleapis_link{google::logging::v2::WriteLogEntriesResponse,google/logging/v2/logging.proto#L241} + /// + /// [google.logging.v2.WriteLogEntriesRequest]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L160} + /// [google.logging.v2.WriteLogEntriesResponse]: + /// @googleapis_reference_link{google/logging/v2/logging.proto#L241} + /// + future> + AsyncWriteLogEntries( + google::logging::v2::WriteLogEntriesRequest const& request, + Options opts = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace logging_v2 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CLIENT_H diff --git a/google/cloud/logging/logging_service_v2_connection.cc b/google/cloud/logging/v2/logging_service_v2_connection.cc similarity index 83% rename from google/cloud/logging/logging_service_v2_connection.cc rename to google/cloud/logging/v2/logging_service_v2_connection.cc index fe5dbc6d7c2c..8b4365a2e8d4 100644 --- a/google/cloud/logging/logging_service_v2_connection.cc +++ b/google/cloud/logging/v2/logging_service_v2_connection.cc @@ -16,12 +16,12 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/logging_service_v2_connection.h" -#include "google/cloud/logging/internal/logging_service_v2_connection_impl.h" -#include "google/cloud/logging/internal/logging_service_v2_option_defaults.h" -#include "google/cloud/logging/internal/logging_service_v2_stub_factory.h" -#include "google/cloud/logging/internal/logging_service_v2_tracing_connection.h" -#include "google/cloud/logging/logging_service_v2_options.h" +#include "google/cloud/logging/v2/logging_service_v2_connection.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_connection_impl.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_option_defaults.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub_factory.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_tracing_connection.h" +#include "google/cloud/logging/v2/logging_service_v2_options.h" #include "google/cloud/background_threads.h" #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" @@ -31,7 +31,7 @@ namespace google { namespace cloud { -namespace logging { +namespace logging_v2 { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN LoggingServiceV2Connection::~LoggingServiceV2Connection() = default; @@ -96,16 +96,16 @@ std::shared_ptr MakeLoggingServiceV2Connection( LoggingServiceV2PolicyOptionList>(options, __func__); options = - logging_internal::LoggingServiceV2DefaultOptions(std::move(options)); + logging_v2_internal::LoggingServiceV2DefaultOptions(std::move(options)); auto background = internal::MakeBackgroundThreadsFactory(options)(); - auto stub = logging_internal::CreateDefaultLoggingServiceV2Stub( + auto stub = logging_v2_internal::CreateDefaultLoggingServiceV2Stub( background->cq(), options); - return logging_internal::MakeLoggingServiceV2TracingConnection( - std::make_shared( + return logging_v2_internal::MakeLoggingServiceV2TracingConnection( + std::make_shared( std::move(background), std::move(stub), std::move(options))); } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging +} // namespace logging_v2 } // namespace cloud } // namespace google diff --git a/google/cloud/logging/v2/logging_service_v2_connection.h b/google/cloud/logging/v2/logging_service_v2_connection.h new file mode 100644 index 000000000000..eb1b35fdb27f --- /dev/null +++ b/google/cloud/logging/v2/logging_service_v2_connection.h @@ -0,0 +1,124 @@ +// Copyright 2021 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. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/logging/v2/logging.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CONNECTION_H + +#include "google/cloud/logging/v2/internal/logging_service_v2_retry_traits.h" +#include "google/cloud/logging/v2/internal/logging_service_v2_stub.h" +#include "google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/internal/async_read_write_stream_impl.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace logging_v2 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using LoggingServiceV2RetryPolicy = + ::google::cloud::internal::TraitBasedRetryPolicy< + logging_v2_internal::LoggingServiceV2RetryTraits>; + +using LoggingServiceV2LimitedTimeRetryPolicy = + ::google::cloud::internal::LimitedTimeRetryPolicy< + logging_v2_internal::LoggingServiceV2RetryTraits>; + +using LoggingServiceV2LimitedErrorCountRetryPolicy = + ::google::cloud::internal::LimitedErrorCountRetryPolicy< + logging_v2_internal::LoggingServiceV2RetryTraits>; + +/** + * The `LoggingServiceV2Connection` object for `LoggingServiceV2Client`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `LoggingServiceV2Client`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `LoggingServiceV2Client`. + * + * To create a concrete instance, see `MakeLoggingServiceV2Connection()`. + * + * For mocking, see `logging_v2_mocks::MockLoggingServiceV2Connection`. + */ +class LoggingServiceV2Connection { + public: + virtual ~LoggingServiceV2Connection() = 0; + + virtual Options options() { return Options{}; } + + virtual Status DeleteLog( + google::logging::v2::DeleteLogRequest const& request); + + virtual StatusOr + WriteLogEntries(google::logging::v2::WriteLogEntriesRequest const& request); + + virtual StreamRange ListLogEntries( + google::logging::v2::ListLogEntriesRequest request); + + virtual StreamRange + ListMonitoredResourceDescriptors( + google::logging::v2::ListMonitoredResourceDescriptorsRequest request); + + virtual StreamRange ListLogs( + google::logging::v2::ListLogsRequest request); + + virtual std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::logging::v2::TailLogEntriesRequest, + google::logging::v2::TailLogEntriesResponse>> + AsyncTailLogEntries(); + + virtual future> + AsyncWriteLogEntries( + google::logging::v2::WriteLogEntriesRequest const& request); +}; + +/** + * A factory function to construct an object of type + * `LoggingServiceV2Connection`. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of LoggingServiceV2Client. + * + * The optional @p options argument may be used to configure aspects of the + * returned `LoggingServiceV2Connection`. Expected options are any of the types + * in the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::GrpcOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::logging_v2::LoggingServiceV2PolicyOptionList` + * + * @note Unexpected options will be ignored. To log unexpected options instead, + * set `GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes` in the environment. + * + * @param options (optional) Configure the `LoggingServiceV2Connection` created + * by this function. + */ +std::shared_ptr MakeLoggingServiceV2Connection( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace logging_v2 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CONNECTION_H diff --git a/google/cloud/logging/logging_service_v2_connection_idempotency_policy.cc b/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.cc similarity index 94% rename from google/cloud/logging/logging_service_v2_connection_idempotency_policy.cc rename to google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.cc index 1e563022e095..2a4b3db0d3a2 100644 --- a/google/cloud/logging/logging_service_v2_connection_idempotency_policy.cc +++ b/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.cc @@ -16,13 +16,13 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/logging_service_v2_connection_idempotency_policy.h" +#include "google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h" #include "absl/memory/memory.h" #include namespace google { namespace cloud { -namespace logging { +namespace logging_v2 { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN using ::google::cloud::Idempotency; @@ -67,6 +67,6 @@ MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy() { } GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END -} // namespace logging +} // namespace logging_v2 } // namespace cloud } // namespace google diff --git a/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h b/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h new file mode 100644 index 000000000000..f5c9d62b2830 --- /dev/null +++ b/google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h @@ -0,0 +1,65 @@ +// Copyright 2021 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. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/logging/v2/logging.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/idempotency.h" +#include "google/cloud/internal/retry_policy.h" +#include "google/cloud/version.h" +#include +#include + +namespace google { +namespace cloud { +namespace logging_v2 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class LoggingServiceV2ConnectionIdempotencyPolicy { + public: + virtual ~LoggingServiceV2ConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() + const; + + virtual google::cloud::Idempotency DeleteLog( + google::logging::v2::DeleteLogRequest const& request); + + virtual google::cloud::Idempotency WriteLogEntries( + google::logging::v2::WriteLogEntriesRequest const& request); + + virtual google::cloud::Idempotency ListLogEntries( + google::logging::v2::ListLogEntriesRequest request); + + virtual google::cloud::Idempotency ListMonitoredResourceDescriptors( + google::logging::v2::ListMonitoredResourceDescriptorsRequest request); + + virtual google::cloud::Idempotency ListLogs( + google::logging::v2::ListLogsRequest request); +}; + +std::unique_ptr +MakeDefaultLoggingServiceV2ConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace logging_v2 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/logging/v2/logging_service_v2_options.h b/google/cloud/logging/v2/logging_service_v2_options.h new file mode 100644 index 000000000000..384f85541aac --- /dev/null +++ b/google/cloud/logging/v2/logging_service_v2_options.h @@ -0,0 +1,76 @@ +// Copyright 2021 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. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/logging/v2/logging.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_OPTIONS_H + +#include "google/cloud/logging/v2/logging_service_v2_connection.h" +#include "google/cloud/logging/v2/logging_service_v2_connection_idempotency_policy.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace logging_v2 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-logging-options + */ +struct LoggingServiceV2RetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-logging-options + */ +struct LoggingServiceV2BackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-logging-options + */ +struct LoggingServiceV2ConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to LoggingServiceV2. + * + * @ingroup google-cloud-logging-options + */ +using LoggingServiceV2PolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace logging_v2 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_LOGGING_SERVICE_V2_OPTIONS_H diff --git a/google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h b/google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h new file mode 100644 index 000000000000..36a800d75af8 --- /dev/null +++ b/google/cloud/logging/v2/mocks/mock_logging_service_v2_connection.h @@ -0,0 +1,87 @@ +// Copyright 2021 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. + +// Generated by the Codegen C++ plugin. +// If you make any local changes, they will be lost. +// source: google/logging/v2/logging.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_MOCKS_MOCK_LOGGING_SERVICE_V2_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_MOCKS_MOCK_LOGGING_SERVICE_V2_CONNECTION_H + +#include "google/cloud/logging/v2/logging_service_v2_connection.h" +#include + +namespace google { +namespace cloud { +namespace logging_v2_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `LoggingServiceV2Connection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `LoggingServiceV2Client`. To do so, + * construct an object of type `LoggingServiceV2Client` with an instance of this + * class. Then use the Google Test framework functions to program the behavior + * of this mock. + * + * @see [This example][bq-mock] for how to test your application with GoogleTest. + * While the example showcases types from the BigQuery library, the underlying + * principles apply for any pair of `*Client` and `*Connection`. + * + * [bq-mock]: @googleapis_dev_link{bigquery,bigquery-read-mock.html} + */ +class MockLoggingServiceV2Connection + : public logging_v2::LoggingServiceV2Connection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD(Status, DeleteLog, + (google::logging::v2::DeleteLogRequest const& request), + (override)); + + MOCK_METHOD(StatusOr, + WriteLogEntries, + (google::logging::v2::WriteLogEntriesRequest const& request), + (override)); + + MOCK_METHOD(StreamRange, ListLogEntries, + (google::logging::v2::ListLogEntriesRequest request), (override)); + + MOCK_METHOD( + StreamRange, + ListMonitoredResourceDescriptors, + (google::logging::v2::ListMonitoredResourceDescriptorsRequest request), + (override)); + + MOCK_METHOD(StreamRange, ListLogs, + (google::logging::v2::ListLogsRequest request), (override)); + + MOCK_METHOD((std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< + google::logging::v2::TailLogEntriesRequest, + google::logging::v2::TailLogEntriesResponse>>), + AsyncTailLogEntries, (), (override)); + + MOCK_METHOD(future>, + AsyncWriteLogEntries, + (google::logging::v2::WriteLogEntriesRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace logging_v2_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_LOGGING_V2_MOCKS_MOCK_LOGGING_SERVICE_V2_CONNECTION_H diff --git a/google/cloud/logging/samples/logging_service_v2_client_samples.cc b/google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc similarity index 88% rename from google/cloud/logging/samples/logging_service_v2_client_samples.cc rename to google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc index 12e9aabc9904..580dcf6a000d 100644 --- a/google/cloud/logging/samples/logging_service_v2_client_samples.cc +++ b/google/cloud/logging/v2/samples/logging_service_v2_client_samples.cc @@ -16,7 +16,7 @@ // If you make any local changes, they will be lost. // source: google/logging/v2/logging.proto -#include "google/cloud/logging/logging_service_v2_client.h" +#include "google/cloud/logging/v2/logging_service_v2_client.h" #include "google/cloud/common_options.h" #include "google/cloud/credentials.h" #include "google/cloud/internal/getenv.h" @@ -26,7 +26,7 @@ #include #include -// main-dox-marker: logging::LoggingServiceV2Client +// main-dox-marker: logging_v2::LoggingServiceV2Client namespace { void SetClientEndpoint(std::vector const& argv) { @@ -38,8 +38,8 @@ void SetClientEndpoint(std::vector const& argv) { // https://cloud.google.com/vpc/docs/private-google-access auto options = google::cloud::Options{}.set( "private.googleapis.com"); - auto client = google::cloud::logging::LoggingServiceV2Client( - google::cloud::logging::MakeLoggingServiceV2Connection(options)); + auto client = google::cloud::logging_v2::LoggingServiceV2Client( + google::cloud::logging_v2::MakeLoggingServiceV2Connection(options)); //! [set-client-endpoint] } @@ -55,8 +55,8 @@ void WithServiceAccount(std::vector const& argv) { auto options = google::cloud::Options{}.set( google::cloud::MakeServiceAccountCredentials(contents)); - return google::cloud::logging::LoggingServiceV2Client( - google::cloud::logging::MakeLoggingServiceV2Connection(options)); + return google::cloud::logging_v2::LoggingServiceV2Client( + google::cloud::logging_v2::MakeLoggingServiceV2Connection(options)); } //! [with-service-account] (argv.at(0));