diff --git a/CHANGELOG.md b/CHANGELOG.md index 85cf4adf3c821..52e28fcfb4429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ for details on updating existing applications using v1.x.y or v2.x.y. We are happy to announce the following GA libraries. Unless specifically noted, the APIs in these libraries are stable, and are ready for production use. +- [Cloud FTP API](/google/cloud/ftp/README.md) - [Workload Identity API](/google/cloud/workloadidentity/README.md) ## v3.8.0 - 2026-08 diff --git a/README.md b/README.md index 5566f86157d88..d6d0d80edec21 100644 --- a/README.md +++ b/README.md @@ -305,6 +305,9 @@ See each library's `README.md` file for more information about: - [Financial Services API](google/cloud/financialservices/README.md) [[quickstart]](google/cloud/financialservices/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/financialservices/latest) +- [Cloud FTP API](google/cloud/ftp/README.md) + [[quickstart]](google/cloud/ftp/quickstart/README.md) + [[reference]](https://cloud.google.com/cpp/docs/reference/ftp/latest) - [Cloud Functions API](google/cloud/functions/README.md) [[quickstart]](google/cloud/functions/quickstart/README.md) [[reference]](https://cloud.google.com/cpp/docs/reference/functions/latest) diff --git a/ci/abi-dumps/google_cloud_cpp_ftp.expected.abi.dump.gz b/ci/abi-dumps/google_cloud_cpp_ftp.expected.abi.dump.gz new file mode 100644 index 0000000000000..f9d98dfede4b5 Binary files /dev/null and b/ci/abi-dumps/google_cloud_cpp_ftp.expected.abi.dump.gz differ diff --git a/ci/etc/expected_install_directories b/ci/etc/expected_install_directories index 864bc139c2061..532f6e2771152 100644 --- a/ci/etc/expected_install_directories +++ b/ci/etc/expected_install_directories @@ -785,6 +785,10 @@ ./include/google/cloud/financialservices/v1 ./include/google/cloud/financialservices/v1/internal ./include/google/cloud/financialservices/v1/mocks +./include/google/cloud/ftp +./include/google/cloud/ftp/v1 +./include/google/cloud/ftp/v1/internal +./include/google/cloud/ftp/v1/mocks ./include/google/cloud/functions ./include/google/cloud/functions/v1 ./include/google/cloud/functions/v1/internal @@ -1439,6 +1443,8 @@ ./lib64/cmake/google_cloud_cpp_filestore_mocks ./lib64/cmake/google_cloud_cpp_financialservices ./lib64/cmake/google_cloud_cpp_financialservices_mocks +./lib64/cmake/google_cloud_cpp_ftp +./lib64/cmake/google_cloud_cpp_ftp_mocks ./lib64/cmake/google_cloud_cpp_functions ./lib64/cmake/google_cloud_cpp_functions_mocks ./lib64/cmake/google_cloud_cpp_geminidataanalytics diff --git a/cmake/GoogleCloudCppFeatures.cmake b/cmake/GoogleCloudCppFeatures.cmake index 44e2d506e3ead..fd0608de8d025 100644 --- a/cmake/GoogleCloudCppFeatures.cmake +++ b/cmake/GoogleCloudCppFeatures.cmake @@ -108,6 +108,7 @@ set(GOOGLE_CLOUD_CPP_GA_LIBRARIES "eventarc" "filestore" "financialservices" + "ftp" "functions" "geminidataanalytics" "gkebackup" diff --git a/external/googleapis/protodeps/ftp.deps b/external/googleapis/protodeps/ftp.deps new file mode 100644 index 0000000000000..ce4eebcf1a3ab --- /dev/null +++ b/external/googleapis/protodeps/ftp.deps @@ -0,0 +1,9 @@ +@googleapis//google/api:annotations_proto +@googleapis//google/api:client_proto +@googleapis//google/api:field_behavior_proto +@googleapis//google/api:field_info_proto +@googleapis//google/api:http_proto +@googleapis//google/api:launch_stage_proto +@googleapis//google/api:resource_proto +@googleapis//google/longrunning:operations_proto +@googleapis//google/rpc:status_proto diff --git a/external/googleapis/protolists/ftp.list b/external/googleapis/protolists/ftp.list new file mode 100644 index 0000000000000..d8fe9a46521a4 --- /dev/null +++ b/external/googleapis/protolists/ftp.list @@ -0,0 +1 @@ +@googleapis//google/cloud/ftp/v1:service.proto diff --git a/external/googleapis/update_libraries.sh b/external/googleapis/update_libraries.sh index 898d25fce465f..e6d3414698d11 100755 --- a/external/googleapis/update_libraries.sh +++ b/external/googleapis/update_libraries.sh @@ -161,6 +161,7 @@ declare -A -r LIBRARIES=( )" ["filestore"]="@googleapis//google/cloud/filestore/v1:filestore_cc_grpc" ["financialservices"]="@googleapis//google/cloud/financialservices/v1:financialservices_cc_grpc" + ["ftp"]="@googleapis//google/cloud/ftp/v1:ftp_cc_proto" ["functions"]="$( printf ",%s" \ "@googleapis//google/cloud/functions/v1:functions_cc_grpc" \ diff --git a/generator/generator_config.textproto b/generator/generator_config.textproto index 21697fd84f4eb..f5a28cc50d01e 100644 --- a/generator/generator_config.textproto +++ b/generator/generator_config.textproto @@ -2649,6 +2649,16 @@ service { retryable_status_codes: ["kUnavailable"] } +# Ftp +service { + service_proto_path: "google/cloud/ftp/v1/service.proto" + product_path: "google/cloud/ftp/v1" + initial_copyright_year: "2026" + retryable_status_codes: ["kUnavailable"] + generate_rest_transport: true + generate_grpc_transport: false +} + # Functions service { service_proto_path: "google/cloud/functions/v1/functions.proto" diff --git a/google/cloud/ftp/BUILD.bazel b/google/cloud/ftp/BUILD.bazel new file mode 100644 index 0000000000000..9a465bfab5758 --- /dev/null +++ b/google/cloud/ftp/BUILD.bazel @@ -0,0 +1,35 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +load("//bazel:gapic.bzl", "cc_gapic_library") + +package(default_visibility = ["//visibility:private"]) + +licenses(["notice"]) # Apache 2.0 + +service_dirs = ["v1/"] + +googleapis_deps = [ + "@googleapis//google/cloud/ftp/v1:ftp_cc_proto", +] + +cc_gapic_library( + name = "ftp", + additional_deps = [ + "//google/cloud:google_cloud_cpp_rest_internal", + "//google/cloud:google_cloud_cpp_rest_protobuf_internal", + ], + googleapis_deps = googleapis_deps, + service_dirs = service_dirs, +) diff --git a/google/cloud/ftp/CMakeLists.txt b/google/cloud/ftp/CMakeLists.txt new file mode 100644 index 0000000000000..2dc56ca7b15f9 --- /dev/null +++ b/google/cloud/ftp/CMakeLists.txt @@ -0,0 +1,32 @@ +# ~~~ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +include(GoogleCloudCppLibrary) + +google_cloud_cpp_add_gapic_library(ftp "Cloud FTP API" REST_TRANSPORT + SERVICE_DIRS "v1/") + +if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS) + add_executable(ftp_quickstart "quickstart/quickstart.cc") + target_link_libraries(ftp_quickstart PRIVATE google-cloud-cpp::ftp) + google_cloud_cpp_add_common_options(ftp_quickstart) + add_test( + NAME ftp_quickstart + COMMAND cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake" + $ GOOGLE_CLOUD_PROJECT) + set_tests_properties(ftp_quickstart + PROPERTIES LABELS "integration-test;quickstart") +endif () diff --git a/google/cloud/ftp/README.md b/google/cloud/ftp/README.md new file mode 100644 index 0000000000000..fb8b2ec007870 --- /dev/null +++ b/google/cloud/ftp/README.md @@ -0,0 +1,60 @@ +# Cloud FTP API C++ Client Library + +This directory contains an idiomatic C++ client library for the +[Cloud FTP API][cloud-service-docs]. + +A managed, cloud-native solution to move data in and out of Google Cloud by +using SSH File Transfer Protocol (SFTP). + +While this library is **GA**, please note that the Google Cloud C++ client +libraries do **not** follow [Semantic Versioning](https://semver.org/). + +## Quickstart + +The [quickstart/](quickstart/README.md) directory contains a minimal environment +to get started using this client library in a larger project. The following +"Hello World" program is used in this quickstart, and should give you a taste of +this library. + + + +```cc +#include "google/cloud/ftp/v1/cloud_ftp_client.h" +#include "google/cloud/location.h" +#include + +int main(int argc, char* argv[]) try { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " project-id\n"; + return 1; + } + + auto const location = google::cloud::Location(argv[1], "-"); + + namespace ftp = ::google::cloud::ftp_v1; + auto client = ftp::CloudFtpClient(ftp::MakeCloudFtpConnectionRest()); + + for (auto const& server : client.ListServers(location.FullName())) { + if (!server) throw std::move(server).status(); + std::cout << server->DebugString() << "\n"; + } + + return 0; +} catch (google::cloud::Status const& status) { + std::cerr << "google::cloud::Status thrown: " << status << "\n"; + return 1; +} +``` + + + +## More Information + +- Official documentation about the [Cloud FTP API][cloud-service-docs] service +- [Reference doxygen documentation][doxygen-link] for each release of this + client library +- Detailed header comments in our [public `.h`][source-link] files + +[cloud-service-docs]: https://docs.cloud.google.com/cloud-ftp +[doxygen-link]: https://cloud.google.com/cpp/docs/reference/ftp/latest/ +[source-link]: https://github.com/googleapis/google-cloud-cpp/tree/main/google/cloud/ftp diff --git a/google/cloud/ftp/doc/environment-variables.dox b/google/cloud/ftp/doc/environment-variables.dox new file mode 100644 index 0000000000000..1d7e0268f1c0d --- /dev/null +++ b/google/cloud/ftp/doc/environment-variables.dox @@ -0,0 +1,49 @@ +/*! +@page ftp-env Environment Variables + +A number of environment variables can be used to configure the behavior of +the library. There are also functions to configure this behavior in code. The +environment variables are convenient when troubleshooting problems. + +@section ftp-env-endpoint Endpoint Overrides + + + +- `GOOGLE_CLOUD_CPP_CLOUD_FTP_ENDPOINT=...` overrides the + `EndpointOption` (which defaults to "ftp.googleapis.com") + used by `MakeCloudFtpConnection()`. + + + +@see google::cloud::EndpointOption + +@section ftp-env-logging Logging + +`GOOGLE_CLOUD_CPP_ENABLE_TRACING=rpc`: turns on tracing for most gRPC +calls. The library injects an additional Stub decorator that prints each gRPC +request and response. Unless you have configured your own logging backend, +you should also set `GOOGLE_CLOUD_CPP_ENABLE_CLOG` to produce any output on +the program's console. + +@see google::cloud::LoggingComponentsOption + +`GOOGLE_CLOUD_CPP_TRACING_OPTIONS=...`: modifies the behavior of gRPC tracing, +including whether messages will be output on multiple lines, or whether +string/bytes fields will be truncated. + +@see google::cloud::GrpcTracingOptionsOption + +`GOOGLE_CLOUD_CPP_ENABLE_CLOG=yes`: turns on logging in the library, basically +the library always "logs" but the logging infrastructure has no backend to +actually print anything until the application sets a backend or they set this +environment variable. + +@see google::cloud::LogBackend +@see google::cloud::LogSink + +@section ftp-env-project Setting the Default Project + +`GOOGLE_CLOUD_PROJECT=...`: is used in examples and integration tests to +configure the GCP project. This has no effect in the library. + +*/ diff --git a/google/cloud/ftp/doc/main.dox b/google/cloud/ftp/doc/main.dox new file mode 100644 index 0000000000000..d673e0e37e988 --- /dev/null +++ b/google/cloud/ftp/doc/main.dox @@ -0,0 +1,49 @@ +/*! + +@mainpage Cloud FTP API C++ Client Library + +An idiomatic C++ client library for the [Cloud FTP API][cloud-service-docs]. + +A managed, cloud-native solution to move data in and out of Google Cloud by +using SSH File Transfer Protocol (SFTP). + +While this library is **GA**, please note that the Google Cloud C++ client libraries do **not** follow +[Semantic Versioning](https://semver.org/). + +@tableofcontents{HTML:2} + +## Quickstart + +The following shows the code that you'll run in the +`google/cloud/ftp/quickstart/` directory, +which should give you a taste of the Cloud FTP API C++ client library API. + +@snippet quickstart.cc all + +## Main classes + + +The main class in this library is +[`ftp_v1::CloudFtpClient`](@ref google::cloud::ftp_v1::CloudFtpClient). All RPCs are exposed +as member functions of this class. Other classes provide helpers, configuration +parameters, and infrastructure to mock +[`ftp_v1::CloudFtpClient`](@ref google::cloud::ftp_v1::CloudFtpClient) when testing your +application. + + +## More Information + +- @ref common-error-handling - describes how the library reports errors. +- @ref ftp-override-endpoint - describes how to override the default + endpoint. +- @ref ftp-override-authentication - describes how to change the + authentication credentials used by the library. +- @ref ftp-override-retry - describes how to change the default retry + policies. +- @ref ftp-env - describes environment variables that can configure the + behavior of the library. +- @ref ftp-override-universe-domain - describes how to override the default universe domain. + +[cloud-service-docs]: https://docs.cloud.google.com/cloud-ftp + +*/ diff --git a/google/cloud/ftp/doc/options.dox b/google/cloud/ftp/doc/options.dox new file mode 100644 index 0000000000000..9ef84982794b6 --- /dev/null +++ b/google/cloud/ftp/doc/options.dox @@ -0,0 +1,10 @@ +/*! +@defgroup google-cloud-ftp-options Cloud FTP API Configuration Options + +This library uses the same mechanism (`google::cloud::Options`) and the common +[options](@ref options) as all other C++ client libraries for its configuration. +Some `*Option` classes, which are only used in this library, are documented in +this page. + +@see @ref options - for an overview of client library configuration. +*/ diff --git a/google/cloud/ftp/doc/override-authentication.dox b/google/cloud/ftp/doc/override-authentication.dox new file mode 100644 index 0000000000000..50a07fed1df3b --- /dev/null +++ b/google/cloud/ftp/doc/override-authentication.dox @@ -0,0 +1,35 @@ +/*! +@page ftp-override-authentication How to Override the Authentication Credentials + +Unless otherwise configured, the client libraries use +[Application Default Credentials] to authenticate with Google Cloud Services. +While this works for most applications, in some cases you may need to override +this default. You can do so by providing the +[UnifiedCredentialsOption](@ref google::cloud::UnifiedCredentialsOption) +The following example shows how to explicitly load a service account key file: + + +@snippet cloud_ftp_client_samples.cc with-service-account + + + +Keep in mind that we chose this as an example because it is relatively easy to +understand. Consult the [Best practices for managing service account keys] +guide for more details. + +@see @ref guac - for more information on the factory functions to create +`google::cloud::Credentials` objects. + +[Best practices for managing service account keys]: https://cloud.google.com/iam/docs/best-practices-for-managing-service-account-keys +[Application Default Credentials]: https://cloud.google.com/docs/authentication#adc + +*/ + +// + +/*! @page ftp_v1::CloudFtpClient-service-account-snippet Override ftp_v1::CloudFtpClient Authentication Defaults + +@snippet google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc with-service-account + +*/ +// diff --git a/google/cloud/ftp/doc/override-endpoint.dox b/google/cloud/ftp/doc/override-endpoint.dox new file mode 100644 index 0000000000000..a78fe114a52d5 --- /dev/null +++ b/google/cloud/ftp/doc/override-endpoint.dox @@ -0,0 +1,25 @@ +/*! +@page ftp-override-endpoint How to Override the Default Endpoint + +In some cases, you may need to override the default endpoint used by the client +library. Use the +[EndpointOption](@ref google::cloud::EndpointOption) when initializing the +client library to change this default. + + +For example, this will override the default endpoint for `ftp_v1::CloudFtpClient`: + +@snippet cloud_ftp_client_samples.cc set-client-endpoint + + + +*/ + +// + +/*! @page ftp_v1::CloudFtpClient-endpoint-snippet Override ftp_v1::CloudFtpClient Endpoint Configuration + +@snippet google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc set-client-endpoint + +*/ +// diff --git a/google/cloud/ftp/doc/override-retry-policies.dox b/google/cloud/ftp/doc/override-retry-policies.dox new file mode 100644 index 0000000000000..e7b50375262cd --- /dev/null +++ b/google/cloud/ftp/doc/override-retry-policies.dox @@ -0,0 +1,108 @@ +/*! +@page ftp-override-retry Override Retry, Backoff, and Idempotency Policies + +When it is safe to do so, the library automatically retries requests that fail +due to a transient error. The library then uses [exponential backoff] to backoff +before trying again. Which operations are considered safe to retry, which +errors are treated as transient failures, the details of the exponential backoff +algorithm, and for how long the library retries are all configurable via +policies. + +This document provides examples showing how to override the default policies. + +The policies can be set when the `*Connection` object is created. The library +provides default policies for any policy that is not set. The application can +also override some (or all) policies when the `*Client` object is created. This +can be useful if multiple `*Client` objects share the same `*Connection` object, +but you want different retry behavior in some of the clients. Finally, the +application can override some retry policies when calling a specific member +function. + +The library uses three different options to control the retry loop. The options +have per-client names. + +@section ftp-override-retry-retry-policy Configuring the transient errors and retry duration + +The `*RetryPolicyOption` controls: + +- Which errors are to be treated as transient errors. +- How long the library will keep retrying transient errors. + +You can provide your own class for this option. The library also provides two +built-in policies: + +- `*LimitedErrorCountRetryPolicy`: stops retrying after a specified number + of transient errors. +- `*LimitedTimeRetryPolicy`: stops retrying after a specified time. + +Note that a library may have more than one version of these classes. Their name +match the `*Client` and `*Connection` object they are intended to be used +with. Some `*Client` objects treat different error codes as transient errors. +In most cases, only [kUnavailable](@ref google::cloud::StatusCode) is treated +as a transient error. + +@section ftp-override-retry-backoff-policy Controlling the backoff algorithm + +The `*BackoffPolicyOption` controls how long the client library will wait +before retrying a request that failed with a transient error. You can provide +your own class for this option. + +The only built-in backoff policy is +[`ExponentialBackoffPolicy`](@ref google::cloud::ExponentialBackoffPolicy). +This class implements a truncated exponential backoff algorithm, with jitter. +In summary, it doubles the current backoff time after each failure. The actual +backoff time for an RPC is chosen at random, but never exceeds the current +backoff. The current backoff is doubled after each failure, but never exceeds +(or is "truncated") if it reaches a prescribed maximum. + +@section ftp-override-retry-idempotency-policy Controlling which operations are retryable + +The `*IdempotencyPolicyOption` controls which requests are retryable, as some +requests are never safe to retry. + +Only one built-in idempotency policy is provided by the library. The name +matches the name of the client it is intended for. For example, `FooBarClient` +will use `FooBarIdempotencyPolicy`. This policy is very conservative. + +@section ftp-override-retry-example Example + + +For example, this will override the retry policies for `ftp_v1::CloudFtpClient`: + +@snippet cloud_ftp_client_samples.cc set-retry-policy + +This assumes you have created a custom idempotency policy. Such as: + +@snippet cloud_ftp_client_samples.cc custom-idempotency-policy + +This will override the polling policies for `ftp_v1::CloudFtpClient` + +@snippet cloud_ftp_client_samples.cc set-polling-policy + + + + +@section ftp-override-retry-more-information More Information + +@see google::cloud::Options +@see google::cloud::BackoffPolicy +@see google::cloud::ExponentialBackoffPolicy + +[exponential backoff]: https://en.wikipedia.org/wiki/Exponential_backoff + +*/ + +// + +/*! @page ftp_v1::CloudFtpClient-retry-snippet Override ftp_v1::CloudFtpClient Retry Policies + +This shows how to override the retry policies for ftp_v1::CloudFtpClient: + +@snippet google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc set-retry-policy + +Assuming you have created a custom idempotency policy. Such as: + +@snippet google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc custom-idempotency-policy + +*/ +// diff --git a/google/cloud/ftp/doc/override-universe-domain.dox b/google/cloud/ftp/doc/override-universe-domain.dox new file mode 100644 index 0000000000000..f6830b56da146 --- /dev/null +++ b/google/cloud/ftp/doc/override-universe-domain.dox @@ -0,0 +1,24 @@ +/*! +@page ftp-override-universe-domain How to Override the Default Universe Domain + +In some cases, you may need to override the default universe domain used by the +client library. Use `AddUniverseDomainOption` when initializing the client +library to change this default. + + +For example, this will override the default universe domain for `ftp_v1::CloudFtpClient`: + +@snippet cloud_ftp_client_samples.cc set-client-universe-domain + + + +*/ + +// + +/*! @page ftp_v1::CloudFtpClient-universe-domain-snippet Override ftp_v1::CloudFtpClient Universe Domain + +@snippet google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc set-client-universe-domain + +*/ +// diff --git a/google/cloud/ftp/quickstart/.bazelrc b/google/cloud/ftp/quickstart/.bazelrc new file mode 100644 index 0000000000000..e88672558bca1 --- /dev/null +++ b/google/cloud/ftp/quickstart/.bazelrc @@ -0,0 +1,29 @@ +# Copyright 2026 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. + +# Use host-OS-specific config lines from bazelrc files. +build --enable_platform_specific_config=true + +# The project requires C++ >= 17. +build:linux --cxxopt=-std=c++17 +build:macos --cxxopt=-std=c++17 +# Protobuf and gRPC require (or soon will require) C++17 to compile the "host" +# targets, such as protoc and the grpc plugin. +build:linux --host_cxxopt=-std=c++17 +build:macos --host_cxxopt=-std=c++17 + +# Do not create the convenience links. They are inconvenient when the build +# runs inside a docker image or if one builds a quickstart and then builds +# the project separately. +build --experimental_convenience_symlinks=ignore diff --git a/google/cloud/ftp/quickstart/BUILD.bazel b/google/cloud/ftp/quickstart/BUILD.bazel new file mode 100644 index 0000000000000..970598716b39f --- /dev/null +++ b/google/cloud/ftp/quickstart/BUILD.bazel @@ -0,0 +1,25 @@ +# Copyright 2026 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. + +licenses(["notice"]) # Apache 2.0 + +cc_binary( + name = "quickstart", + srcs = [ + "quickstart.cc", + ], + deps = [ + "@google_cloud_cpp//:ftp", + ], +) diff --git a/google/cloud/ftp/quickstart/CMakeLists.txt b/google/cloud/ftp/quickstart/CMakeLists.txt new file mode 100644 index 0000000000000..75e7c6526872d --- /dev/null +++ b/google/cloud/ftp/quickstart/CMakeLists.txt @@ -0,0 +1,35 @@ +# Copyright 2026 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. + +# This file shows how to use the Cloud FTP API C++ client library from a larger +# CMake project. + +cmake_minimum_required(VERSION 3.22...3.31) +project(google-cloud-cpp-ftp-quickstart CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(google_cloud_cpp_ftp REQUIRED) + +# MSVC requires some additional code to select the correct runtime library +if (VCPKG_TARGET_TRIPLET MATCHES "-static$") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +else () + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") +endif () + +# Define your targets. +add_executable(quickstart quickstart.cc) +target_link_libraries(quickstart google-cloud-cpp::ftp) diff --git a/google/cloud/ftp/quickstart/Makefile b/google/cloud/ftp/quickstart/Makefile new file mode 100644 index 0000000000000..7293dec02096a --- /dev/null +++ b/google/cloud/ftp/quickstart/Makefile @@ -0,0 +1,35 @@ +# Copyright 2026 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. + +# This is a minimal Makefile to show how to use the Cloud FTP API C++ client +# for developers who use make(1) as their build system. + +# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for +# our tests, but applications would typically make them configurable parameters. +CXX=g++ +CXXFLAGS=-std=c++17 +CXXLD=$(CXX) +BIN=. + +all: $(BIN)/quickstart + +# Configuration variables to compile and link against the Cloud FTP API C++ +# client library. +CLIENT_MODULE := google_cloud_cpp_ftp +CLIENT_CXXFLAGS := $(shell pkg-config $(CLIENT_MODULE) --cflags) +CLIENT_CXXLDFLAGS := $(shell pkg-config $(CLIENT_MODULE) --libs-only-L) +CLIENT_LIBS := $(shell pkg-config $(CLIENT_MODULE) --libs-only-l) + +$(BIN)/quickstart: quickstart.cc + $(CXXLD) $(CXXFLAGS) $(CLIENT_CXXFLAGS) $(CLIENT_CXXLDFLAGS) -o $@ $^ $(CLIENT_LIBS) diff --git a/google/cloud/ftp/quickstart/README.md b/google/cloud/ftp/quickstart/README.md new file mode 100644 index 0000000000000..c9f6261a6ff58 --- /dev/null +++ b/google/cloud/ftp/quickstart/README.md @@ -0,0 +1,135 @@ +# HOWTO: using the Cloud FTP API C++ client in your project + +This directory contains small examples showing how to use the Cloud FTP API C++ +client library in your own project. These instructions assume that you have some +experience as a C++ developer and that you have a working C++ toolchain +(compiler, linker, etc.) installed on your platform. + +- Packaging maintainers or developers who prefer to install the library in a + fixed directory (such as `/usr/local` or `/opt`) should consult the + [packaging guide](/doc/packaging.md). +- Developers who prefer using a package manager such as + [vcpkg](https://vcpkg.io), or [Conda](https://conda.io), should follow the + instructions for their package manager. +- Developers wanting to use the libraries as part of a larger CMake or Bazel + project should consult the current document. Note that there are similar + documents for each library in their corresponding directories. +- Developers wanting to compile the library just to run some examples or tests + should consult the + [building and installing](/README.md#building-and-installing) section of the + top-level README file. +- Contributors and developers to `google-cloud-cpp` should consult the guide to + [set up a development workstation][howto-setup-dev-workstation]. + +## Before you begin + +To run the quickstart examples you will need a working Google Cloud Platform +(GCP) project. + +## Configuring authentication for the C++ Client Library + +Like most Google Cloud Platform (GCP) services, Cloud FTP API requires that your +application authenticates with the service before accessing any data. If you are +not familiar with GCP authentication please take this opportunity to review the +[Authentication methods at Google][authentication-quickstart]. + +## Using with Bazel + +> :warning: If you are using Windows or macOS there are additional instructions +> at the end of this document. + +1. Install Bazel using [the instructions][bazel-install] from the `bazel.build` + website. + +1. Compile this example using Bazel: + + ```bash + cd $HOME/google-cloud-cpp/google/cloud/ftp/quickstart + bazel build ... + ``` + + Note that Bazel automatically downloads and compiles all dependencies of the + project. As it is often the case with C++ libraries, compiling these + dependencies may take several minutes. + +1. Run the example, changing the placeholder(s) to appropriate values: + + ```bash + bazel run :quickstart -- [...] + ``` + +## Using with CMake + +> :warning: If you are using Windows or macOS there are additional instructions +> at the end of this document. + +1. Install CMake. The package managers for most Linux distributions include a + package for CMake. Likewise, you can install CMake on Windows using a package + manager such as [chocolatey][choco-cmake-link], and on macOS using + [homebrew][homebrew-cmake-link]. You can also obtain the software directly + from the [cmake.org](https://cmake.org/download/). + +1. Install the dependencies with your favorite tools. As an example, if you use + [vcpkg](https://github.com/Microsoft/vcpkg.git): + + ```bash + cd $HOME/vcpkg + ./vcpkg install google-cloud-cpp[core,ftp] + ``` + + Note that, as it is often the case with C++ libraries, compiling these + dependencies may take several minutes. + +1. Configure CMake, if necessary, configure the directory where you installed + the dependencies: + + ```bash + cd $HOME/google-cloud-cpp/google/cloud/ftp/quickstart + cmake -S . -B .build -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake + cmake --build .build + ``` + +1. Run the example, changing the placeholder(s) to appropriate values: + + ```bash + .build/quickstart [...] + ``` + +## Platform Specific Notes + +### macOS + +gRPC [requires][grpc-roots-pem-bug] an environment variable to configure the +trust store for SSL certificates, you can download and configure this using: + +```bash +curl -Lo roots.pem https://pki.google.com/roots.pem +export GRPC_DEFAULT_SSL_ROOTS_FILE_PATH="$PWD/roots.pem" +``` + +### Windows + +Bazel tends to create very long file names and paths. You may need to use a +short directory to store the build output, such as `c:\b`, and instruct Bazel to +use it via: + +```shell +bazel --output_user_root=c:\b build ... +``` + +gRPC [requires][grpc-roots-pem-bug] an environment variable to configure the +trust store for SSL certificates, you can download and configure this using: + +```console +@powershell -NoProfile -ExecutionPolicy unrestricted -Command ^ + (new-object System.Net.WebClient).Downloadfile( ^ + 'https://pki.google.com/roots.pem', 'roots.pem') +set GRPC_DEFAULT_SSL_ROOTS_FILE_PATH=%cd%\roots.pem +``` + +[authentication-quickstart]: https://cloud.google.com/docs/authentication/client-libraries "Authenticate for using client libraries" +[bazel-install]: https://docs.bazel.build/versions/main/install.html +[choco-cmake-link]: https://chocolatey.org/packages/cmake +[grpc-roots-pem-bug]: https://github.com/grpc/grpc/issues/16571 +[homebrew-cmake-link]: https://formulae.brew.sh/formula/cmake +[howto-setup-dev-workstation]: /doc/contributor/howto-guide-setup-development-workstation.md diff --git a/google/cloud/ftp/quickstart/WORKSPACE.bazel b/google/cloud/ftp/quickstart/WORKSPACE.bazel new file mode 100644 index 0000000000000..00952813423c4 --- /dev/null +++ b/google/cloud/ftp/quickstart/WORKSPACE.bazel @@ -0,0 +1,53 @@ +# Copyright 2026 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. + +# A minimal WORKSPACE file showing how to use the Cloud FTP API +# C++ client library in Bazel-based projects. +workspace(name = "qs") + +# Add the necessary Starlark functions to fetch google-cloud-cpp. +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +# Fetch the Google Cloud C++ libraries. +# NOTE: Update this version and SHA256 as needed. +http_archive( + name = "google_cloud_cpp", + sha256 = "d0a3a670f468ddd059ffb39780df958b3ffaca12ebcae63193072b759b95add2", + strip_prefix = "google-cloud-cpp-3.8.0", + url = "https://github.com/googleapis/google-cloud-cpp/archive/v3.8.0.tar.gz", +) + +load("@google_cloud_cpp//bazel:workspace0.bzl", "gl_cpp_workspace0") + +gl_cpp_workspace0() + +load("@google_cloud_cpp//bazel:workspace1.bzl", "gl_cpp_workspace1") + +gl_cpp_workspace1() + +load("@google_cloud_cpp//bazel:workspace2.bzl", "gl_cpp_workspace2") + +gl_cpp_workspace2() + +load("@google_cloud_cpp//bazel:workspace3.bzl", "gl_cpp_workspace3") + +gl_cpp_workspace3() + +load("@google_cloud_cpp//bazel:workspace4.bzl", "gl_cpp_workspace4") + +gl_cpp_workspace4() + +load("@google_cloud_cpp//bazel:workspace5.bzl", "gl_cpp_workspace5") + +gl_cpp_workspace5() diff --git a/google/cloud/ftp/quickstart/quickstart.cc b/google/cloud/ftp/quickstart/quickstart.cc new file mode 100644 index 0000000000000..2f3a9285925e0 --- /dev/null +++ b/google/cloud/ftp/quickstart/quickstart.cc @@ -0,0 +1,41 @@ +// Copyright 2026 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. + +//! [all] +#include "google/cloud/ftp/v1/cloud_ftp_client.h" +#include "google/cloud/location.h" +#include + +int main(int argc, char* argv[]) try { + if (argc != 2) { + std::cerr << "Usage: " << argv[0] << " project-id\n"; + return 1; + } + + auto const location = google::cloud::Location(argv[1], "-"); + + namespace ftp = ::google::cloud::ftp_v1; + auto client = ftp::CloudFtpClient(ftp::MakeCloudFtpConnectionRest()); + + for (auto const& server : client.ListServers(location.FullName())) { + if (!server) throw std::move(server).status(); + std::cout << server->DebugString() << "\n"; + } + + return 0; +} catch (google::cloud::Status const& status) { + std::cerr << "google::cloud::Status thrown: " << status << "\n"; + return 1; +} +//! [all] diff --git a/google/cloud/ftp/v1/.repo-metadata.json b/google/cloud/ftp/v1/.repo-metadata.json new file mode 100644 index 0000000000000..476b244026ee5 --- /dev/null +++ b/google/cloud/ftp/v1/.repo-metadata.json @@ -0,0 +1,14 @@ +{ + "api_id": "ftp.googleapis.com", + "api_shortname": "ftp", + "client_documentation": "https://cloud.google.com/cpp/docs/reference/ftp/latest", + "distribution_name": "google-cloud-cpp", + "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:1088719%20status=open", + "language": "cpp", + "library_type": "GAPIC_AUTO", + "name_pretty": "Cloud FTP API", + "product_documentation": "https://docs.cloud.google.com/cloud-ftp", + "release_level": "stable", + "repo": "googleapis/google-cloud-cpp", + "requires_billing": true +} diff --git a/google/cloud/ftp/v1/cloud_ftp_client.cc b/google/cloud/ftp/v1/cloud_ftp_client.cc new file mode 100644 index 0000000000000..1ac0faec977cf --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_client.cc @@ -0,0 +1,467 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/cloud_ftp_client.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +CloudFtpClient::CloudFtpClient(std::shared_ptr connection, + Options opts) + : connection_(std::move(connection)), + options_( + internal::MergeOptions(std::move(opts), connection_->options())) {} +CloudFtpClient::~CloudFtpClient() = default; + +StreamRange CloudFtpClient::ListServers( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::ListServersRequest request; + request.set_parent(parent); + return connection_->ListServers(request); +} + +StreamRange CloudFtpClient::ListServers( + google::cloud::ftp::v1::ListServersRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListServers(std::move(request)); +} + +StatusOr CloudFtpClient::GetServer( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::GetServerRequest request; + request.set_name(name); + return connection_->GetServer(request); +} + +StatusOr CloudFtpClient::GetServer( + google::cloud::ftp::v1::GetServerRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetServer(request); +} + +future> CloudFtpClient::CreateServer( + std::string const& parent, google::cloud::ftp::v1::Server const& server, + std::string const& server_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::CreateServerRequest request; + request.set_parent(parent); + *request.mutable_server() = server; + request.set_server_id(server_id); + return connection_->CreateServer(request); +} + +StatusOr CloudFtpClient::CreateServer( + NoAwaitTag, std::string const& parent, + google::cloud::ftp::v1::Server const& server, std::string const& server_id, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::CreateServerRequest request; + request.set_parent(parent); + *request.mutable_server() = server; + request.set_server_id(server_id); + return connection_->CreateServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateServer(request); +} + +StatusOr CloudFtpClient::CreateServer( + NoAwaitTag, google::cloud::ftp::v1::CreateServerRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::CreateServer( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateServer(operation); +} + +future> CloudFtpClient::UpdateServer( + google::cloud::ftp::v1::Server const& server, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::UpdateServerRequest request; + *request.mutable_server() = server; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateServer(request); +} + +StatusOr CloudFtpClient::UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::Server const& server, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::UpdateServerRequest request; + *request.mutable_server() = server; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateServer(request); +} + +StatusOr CloudFtpClient::UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::UpdateServerRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::UpdateServer( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateServer(operation); +} + +future> +CloudFtpClient::DeleteServer(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::DeleteServerRequest request; + request.set_name(name); + return connection_->DeleteServer(request); +} + +StatusOr CloudFtpClient::DeleteServer( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::DeleteServerRequest request; + request.set_name(name); + return connection_->DeleteServer(NoAwaitTag{}, request); +} + +future> +CloudFtpClient::DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteServer(request); +} + +StatusOr CloudFtpClient::DeleteServer( + NoAwaitTag, google::cloud::ftp::v1::DeleteServerRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteServer(NoAwaitTag{}, request); +} + +future> +CloudFtpClient::DeleteServer(google::longrunning::Operation const& operation, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteServer(operation); +} + +StreamRange CloudFtpClient::ListUsers( + std::string const& parent, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::ListUsersRequest request; + request.set_parent(parent); + return connection_->ListUsers(request); +} + +StreamRange CloudFtpClient::ListUsers( + google::cloud::ftp::v1::ListUsersRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListUsers(std::move(request)); +} + +StatusOr CloudFtpClient::GetUser( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::GetUserRequest request; + request.set_name(name); + return connection_->GetUser(request); +} + +StatusOr CloudFtpClient::GetUser( + google::cloud::ftp::v1::GetUserRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetUser(request); +} + +future> CloudFtpClient::CreateUser( + std::string const& parent, google::cloud::ftp::v1::User const& user, + std::string const& user_id, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::CreateUserRequest request; + request.set_parent(parent); + *request.mutable_user() = user; + request.set_user_id(user_id); + return connection_->CreateUser(request); +} + +StatusOr CloudFtpClient::CreateUser( + NoAwaitTag, std::string const& parent, + google::cloud::ftp::v1::User const& user, std::string const& user_id, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::CreateUserRequest request; + request.set_parent(parent); + *request.mutable_user() = user; + request.set_user_id(user_id); + return connection_->CreateUser(NoAwaitTag{}, request); +} + +future> CloudFtpClient::CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateUser(request); +} + +StatusOr CloudFtpClient::CreateUser( + NoAwaitTag, google::cloud::ftp::v1::CreateUserRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateUser(NoAwaitTag{}, request); +} + +future> CloudFtpClient::CreateUser( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CreateUser(operation); +} + +future> CloudFtpClient::UpdateUser( + google::cloud::ftp::v1::User const& user, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::UpdateUserRequest request; + *request.mutable_user() = user; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateUser(request); +} + +StatusOr CloudFtpClient::UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::User const& user, + google::protobuf::FieldMask const& update_mask, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::UpdateUserRequest request; + *request.mutable_user() = user; + *request.mutable_update_mask() = update_mask; + return connection_->UpdateUser(NoAwaitTag{}, request); +} + +future> CloudFtpClient::UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateUser(request); +} + +StatusOr CloudFtpClient::UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::UpdateUserRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateUser(NoAwaitTag{}, request); +} + +future> CloudFtpClient::UpdateUser( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->UpdateUser(operation); +} + +future> +CloudFtpClient::DeleteUser(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::DeleteUserRequest request; + request.set_name(name); + return connection_->DeleteUser(request); +} + +StatusOr CloudFtpClient::DeleteUser( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::DeleteUserRequest request; + request.set_name(name); + return connection_->DeleteUser(NoAwaitTag{}, request); +} + +future> +CloudFtpClient::DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteUser(request); +} + +StatusOr CloudFtpClient::DeleteUser( + NoAwaitTag, google::cloud::ftp::v1::DeleteUserRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteUser(NoAwaitTag{}, request); +} + +future> +CloudFtpClient::DeleteUser(google::longrunning::Operation const& operation, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteUser(operation); +} + +future> CloudFtpClient::StartServer( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::StartServerRequest request; + request.set_name(name); + return connection_->StartServer(request); +} + +StatusOr CloudFtpClient::StartServer( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::StartServerRequest request; + request.set_name(name); + return connection_->StartServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::StartServer( + google::cloud::ftp::v1::StartServerRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->StartServer(request); +} + +StatusOr CloudFtpClient::StartServer( + NoAwaitTag, google::cloud::ftp::v1::StartServerRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->StartServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::StartServer( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->StartServer(operation); +} + +future> CloudFtpClient::StopServer( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::StopServerRequest request; + request.set_name(name); + return connection_->StopServer(request); +} + +StatusOr CloudFtpClient::StopServer( + NoAwaitTag, std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::cloud::ftp::v1::StopServerRequest request; + request.set_name(name); + return connection_->StopServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::StopServer( + google::cloud::ftp::v1::StopServerRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->StopServer(request); +} + +StatusOr CloudFtpClient::StopServer( + NoAwaitTag, google::cloud::ftp::v1::StopServerRequest const& request, + Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->StopServer(NoAwaitTag{}, request); +} + +future> CloudFtpClient::StopServer( + google::longrunning::Operation const& operation, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->StopServer(operation); +} + +StreamRange CloudFtpClient::ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListLocations(std::move(request)); +} + +StatusOr CloudFtpClient::GetLocation( + google::cloud::location::GetLocationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetLocation(request); +} + +StreamRange CloudFtpClient::ListOperations( + std::string const& name, std::string const& filter, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::ListOperationsRequest request; + request.set_name(name); + request.set_filter(filter); + return connection_->ListOperations(request); +} + +StreamRange CloudFtpClient::ListOperations( + google::longrunning::ListOperationsRequest request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->ListOperations(std::move(request)); +} + +StatusOr CloudFtpClient::GetOperation( + std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::GetOperationRequest request; + request.set_name(name); + return connection_->GetOperation(request); +} + +StatusOr CloudFtpClient::GetOperation( + google::longrunning::GetOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->GetOperation(request); +} + +Status CloudFtpClient::DeleteOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::DeleteOperationRequest request; + request.set_name(name); + return connection_->DeleteOperation(request); +} + +Status CloudFtpClient::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->DeleteOperation(request); +} + +Status CloudFtpClient::CancelOperation(std::string const& name, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + google::longrunning::CancelOperationRequest request; + request.set_name(name); + return connection_->CancelOperation(request); +} + +Status CloudFtpClient::CancelOperation( + google::longrunning::CancelOperationRequest const& request, Options opts) { + internal::OptionsSpan span(internal::MergeOptions(std::move(opts), options_)); + return connection_->CancelOperation(request); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/cloud_ftp_client.h b/google/cloud/ftp/v1/cloud_ftp_client.h new file mode 100644 index 0000000000000..99b70a66761f6 --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_client.h @@ -0,0 +1,1615 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CLIENT_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CLIENT_H + +#include "google/cloud/ftp/v1/cloud_ftp_rest_connection.h" +#include "google/cloud/future.h" +#include "google/cloud/no_await_tag.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// +/// Service describing handlers for resources +/// +/// @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 CloudFtpClient { + public: + explicit CloudFtpClient(std::shared_ptr connection, + Options opts = {}); + ~CloudFtpClient(); + + ///@{ + /// @name Copy and move support + CloudFtpClient(CloudFtpClient const&) = default; + CloudFtpClient& operator=(CloudFtpClient const&) = default; + CloudFtpClient(CloudFtpClient&&) = default; + CloudFtpClient& operator=(CloudFtpClient&&) = default; + ///@} + + ///@{ + /// @name Equality + friend bool operator==(CloudFtpClient const& a, CloudFtpClient const& b) { + return a.connection_ == b.connection_; + } + friend bool operator!=(CloudFtpClient const& a, CloudFtpClient const& b) { + return !(a == b); + } + ///@} + + // clang-format off + /// + /// Lists Servers in a given project and location. + /// + /// @param parent Required. Parent value for ListServersRequest + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.ftp.v1.Server], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.ListServersRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L429} + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// + // clang-format on + StreamRange ListServers( + std::string const& parent, Options opts = {}); + + // clang-format off + /// + /// Lists Servers in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.ListServersRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.ftp.v1.Server], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.ListServersRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L429} + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// + // clang-format on + StreamRange ListServers( + google::cloud::ftp::v1::ListServersRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Server. + /// + /// @param name Required. Name of the resource + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.ftp.v1.Server]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.GetServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L469} + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// + // clang-format on + StatusOr GetServer(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets details of a single Server. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.GetServerRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.ftp.v1.Server]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.GetServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L469} + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// + // clang-format on + StatusOr GetServer( + google::cloud::ftp::v1::GetServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Creates a new Server in a given project and location. + /// + /// @param parent Required. Value for parent. + /// @param server Required. The resource being created + /// @param server_id Required. A unique ID for the server. Must start with a lowercase letter, + /// and end with a lowercase letter or number. Can contain lowercase letters, + /// numbers, and hyphens. Maximum length is 30 characters. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.CreateServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L481} + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// + // clang-format on + future> CreateServer( + std::string const& parent, google::cloud::ftp::v1::Server const& server, + std::string const& server_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateServer( + NoAwaitTag, std::string const& parent, + google::cloud::ftp::v1::Server const& server, + std::string const& server_id, Options opts = {}); + + // clang-format off + /// + /// Creates a new Server in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.CreateServerRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.CreateServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L481} + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// + // clang-format on + future> CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateServer( + NoAwaitTag, google::cloud::ftp::v1::CreateServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateServer + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> CreateServer( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single Server. + /// + /// @param server Required. The resource being updated + /// @param update_mask Optional. Field mask is used to specify the fields to be overwritten in the + /// Server resource by the update. + /// The fields specified in the update_mask are relative to the resource, not + /// the full request. A field will be overwritten if it is in the mask. If the + /// user does not provide a mask then all fields present in the request will be + /// overwritten. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// [google.cloud.ftp.v1.UpdateServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L518} + /// + // clang-format on + future> UpdateServer( + google::cloud::ftp::v1::Server const& server, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::Server const& server, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single Server. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.UpdateServerRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// [google.cloud.ftp.v1.UpdateServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L518} + /// + // clang-format on + future> UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::UpdateServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateServer + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> UpdateServer( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Deletes a single Server. + /// + /// @param name Required. Name of the resource + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.DeleteServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L555} + /// [google.cloud.ftp.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L826} + /// + // clang-format on + future> DeleteServer( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteServer(NoAwaitTag, + std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Deletes a single Server. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.DeleteServerRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.DeleteServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L555} + /// [google.cloud.ftp.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L826} + /// + // clang-format on + future> DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteServer( + NoAwaitTag, google::cloud::ftp::v1::DeleteServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteServer + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> DeleteServer( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Lists Users in a given project and location. + /// + /// @param parent Required. Parent value for ListUsersRequest + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.ftp.v1.User], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.ListUsersRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L672} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + StreamRange ListUsers(std::string const& parent, + Options opts = {}); + + // clang-format off + /// + /// Lists Users in a given project and location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.ListUsersRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.ftp.v1.User], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.ListUsersRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L672} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + StreamRange ListUsers( + google::cloud::ftp::v1::ListUsersRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets details of a single User. + /// + /// @param name Required. Name of the resource + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.ftp.v1.User]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.GetUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L711} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + StatusOr GetUser(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets details of a single User. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.GetUserRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.ftp.v1.User]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.GetUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L711} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + StatusOr GetUser( + google::cloud::ftp::v1::GetUserRequest const& request, Options opts = {}); + + // clang-format off + /// + /// Creates a new User in a given project and location and Server. + /// + /// @param parent Required. Value for parent. + /// @param user Required. The resource being created + /// @param user_id Required. A unique user ID for the SFTP user. The user ID must start with a + /// lowercase letter and can include lowercase letters, numbers, or hyphens. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.User] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.CreateUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L723} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + future> CreateUser( + std::string const& parent, google::cloud::ftp::v1::User const& user, + std::string const& user_id, Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateUser + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateUser( + NoAwaitTag, std::string const& parent, + google::cloud::ftp::v1::User const& user, std::string const& user_id, + Options opts = {}); + + // clang-format off + /// + /// Creates a new User in a given project and location and Server. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.CreateUserRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.User] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.CreateUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L723} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + future> CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateUser + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr CreateUser( + NoAwaitTag, google::cloud::ftp::v1::CreateUserRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief CreateUser + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> CreateUser( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single User. + /// + /// @param user Required. The resource being updated + /// @param update_mask Optional. Field mask is used to specify the fields to be overwritten in the + /// User resource by the update. + /// The fields specified in the update_mask are relative to the resource, not + /// the full request. A field will be overwritten if it is in the mask. If the + /// user does not provide a mask then all fields present in the request will be + /// overwritten. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.User] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.UpdateUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L757} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + future> UpdateUser( + google::cloud::ftp::v1::User const& user, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateUser + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::User const& user, + google::protobuf::FieldMask const& update_mask, Options opts = {}); + + // clang-format off + /// + /// Updates the parameters of a single User. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.UpdateUserRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.User] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.UpdateUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L757} + /// [google.cloud.ftp.v1.User]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L607} + /// + // clang-format on + future> UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateUser + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::UpdateUserRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief UpdateUser + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> UpdateUser( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Deletes a single User. + /// + /// @param name Required. Name of the resource + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.DeleteUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L772} + /// [google.cloud.ftp.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L826} + /// + // clang-format on + future> DeleteUser( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteUser + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteUser(NoAwaitTag, + std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Deletes a single User. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.DeleteUserRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.OperationMetadata] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.DeleteUserRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L772} + /// [google.cloud.ftp.v1.OperationMetadata]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L826} + /// + // clang-format on + future> DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteUser + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr DeleteUser( + NoAwaitTag, google::cloud::ftp::v1::DeleteUserRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief DeleteUser + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> DeleteUser( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Starts a stopping/stopped Server. + /// + /// @param name Required. Name of the resource + /// Format: `projects/{project}/locations/{location}/servers/{server}` + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// [google.cloud.ftp.v1.StartServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L784} + /// + // clang-format on + future> StartServer( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief StartServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr StartServer(NoAwaitTag, + std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Starts a stopping/stopped Server. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.StartServerRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// [google.cloud.ftp.v1.StartServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L784} + /// + // clang-format on + future> StartServer( + google::cloud::ftp::v1::StartServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief StartServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr StartServer( + NoAwaitTag, google::cloud::ftp::v1::StartServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief StartServer + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> StartServer( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Stops an active Server. + /// + /// @param name Required. Name of the resource. + /// Format: `projects/{project}/locations/{location}/servers/{server}` + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// [google.cloud.ftp.v1.StopServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L794} + /// + // clang-format on + future> StopServer( + std::string const& name, Options opts = {}); + + // clang-format off + /// + /// @copybrief StopServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr StopServer(NoAwaitTag, + std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Stops an active Server. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.ftp.v1.StopServerRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return A [`future`] that becomes satisfied when the LRO + /// ([Long Running Operation]) completes or the polling policy in effect + /// for this call is exhausted. The future is satisfied with an error if + /// the LRO completes with an error or the polling policy is exhausted. + /// In this case the [`StatusOr`] returned by the future contains the + /// error. If the LRO completes successfully the value of the future + /// contains the LRO's result. For this RPC the result is a + /// [google.cloud.ftp.v1.Server] proto message. + /// The C++ class representing this message is created by Protobuf, using + /// the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [Long Running Operation]: https://google.aip.dev/151 + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.ftp.v1.Server]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L337} + /// [google.cloud.ftp.v1.StopServerRequest]: @googleapis_reference_link{google/cloud/ftp/v1/service.proto#L794} + /// + // clang-format on + future> StopServer( + google::cloud::ftp::v1::StopServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief StopServer + /// + /// Specifying the [`NoAwaitTag`] immediately returns the + /// [`google::longrunning::Operation`] that corresponds to the Long Running + /// Operation that has been started. No polling for operation status occurs. + /// + /// [`NoAwaitTag`]: @ref google::cloud::NoAwaitTag + /// + // clang-format on + StatusOr StopServer( + NoAwaitTag, google::cloud::ftp::v1::StopServerRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// @copybrief StopServer + /// + /// This method accepts a `google::longrunning::Operation` that corresponds + /// to a previously started Long Running Operation (LRO) and polls the status + /// of the LRO in the background. + /// + // clang-format on + future> StopServer( + google::longrunning::Operation const& operation, Options opts = {}); + + // clang-format off + /// + /// Lists information about the supported locations for this service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.ListLocationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.cloud.location.Location], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.ListLocationsRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L58} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets information about a location. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.cloud.location.GetLocationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.cloud.location.Location]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.cloud.location.GetLocationRequest]: @googleapis_reference_link{google/cloud/location/locations.proto#L82} + /// [google.cloud.location.Location]: @googleapis_reference_link{google/cloud/location/locations.proto#L88} + /// + // clang-format on + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param name The name of the operation's parent resource. + /// @param filter The standard list filter. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + std::string const& name, std::string const& filter, Options opts = {}); + + // clang-format off + /// + /// Lists operations that match the specified filter in the request. If the + /// server doesn't support this method, it returns `UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.ListOperationsRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [StreamRange](@ref google::cloud::StreamRange) + /// to iterate of the results. See the documentation of this type for + /// details. In brief, this class has `begin()` and `end()` member + /// functions returning a iterator class meeting the + /// [input iterator requirements]. The value type for this iterator is a + /// [`StatusOr`] as the iteration may fail even after some values are + /// retrieved successfully, for example, if there is a network disconnect. + /// An empty set of results does not indicate an error, it indicates + /// that there are no resources meeting the request criteria. + /// On a successful iteration the `StatusOr` contains elements of type + /// [google.longrunning.Operation], or rather, + /// the C++ class generated by Protobuf from that type. Please consult the + /// Protobuf documentation for details on the [Protobuf mapping rules]. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.ListOperationsRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L167} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request, Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param name The name of the operation resource. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation(std::string const& name, + Options opts = {}); + + // clang-format off + /// + /// Gets the latest state of a long-running operation. Clients can use this + /// method to poll the operation result at intervals as recommended by the API + /// service. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.GetOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return the result of the RPC. The response message type + /// ([google.longrunning.Operation]) + /// is mapped to a C++ class using the [Protobuf mapping rules]. + /// If the request fails, the [`StatusOr`] contains the error details. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.GetOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L160} + /// [google.longrunning.Operation]: @googleapis_reference_link{google/longrunning/operations.proto#L121} + /// + // clang-format on + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param name The name of the operation resource to be deleted. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Deletes a long-running operation. This method indicates that the client is + /// no longer interested in the operation result. It does not cancel the + /// operation. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.DeleteOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.DeleteOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L219} + /// + // clang-format on + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request, + Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param name The name of the operation resource to be cancelled. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L37} + /// + // clang-format on + Status CancelOperation(std::string const& name, Options opts = {}); + + // clang-format off + /// + /// Starts asynchronous cancellation on a long-running operation. The server + /// makes a best effort to cancel the operation, but success is not + /// guaranteed. If the server doesn't support this method, it returns + /// `google.rpc.Code.UNIMPLEMENTED`. Clients can use + /// [Operations.GetOperation][google.longrunning.Operations.GetOperation] or + /// other methods to check whether the cancellation succeeded or whether the + /// operation completed despite cancellation. On successful cancellation, + /// the operation is not deleted; instead, it becomes an operation with + /// an [Operation.error][google.longrunning.Operation.error] value with a + /// [google.rpc.Status.code][google.rpc.Status.code] of `1`, corresponding to + /// `Code.CANCELLED`. + /// + /// @param request Unary RPCs, such as the one wrapped by this + /// function, receive a single `request` proto message which includes all + /// the inputs for the RPC. In this case, the proto message is a + /// [google.longrunning.CancelOperationRequest]. + /// Proto messages are converted to C++ classes by Protobuf, using the + /// [Protobuf mapping rules]. + /// @param opts Optional. Override the class-level options, such as retry and + /// backoff policies. + /// @return a [`Status`] object. If the request failed, the + /// status contains the details of the failure. + /// + /// [Protobuf mapping rules]: https://protobuf.dev/reference/cpp/cpp-generated/ + /// [input iterator requirements]: https://en.cppreference.com/w/cpp/named_req/InputIterator + /// [`std::string`]: https://en.cppreference.com/w/cpp/string/basic_string + /// [`future`]: @ref google::cloud::future + /// [`StatusOr`]: @ref google::cloud::StatusOr + /// [`Status`]: @ref google::cloud::Status + /// [google.longrunning.CancelOperationRequest]: @googleapis_reference_link{google/longrunning/operations.proto#L212} + /// [google.longrunning.Operation.error]: @googleapis_reference_link{google/longrunning/operations.proto#L144} + /// [google.longrunning.Operations.GetOperation]: @googleapis_reference_link{google/longrunning/operations.proto#L70} + /// [google.rpc.Status.code]: @googleapis_reference_link{google/rpc/status.proto#L37} + /// + // clang-format on + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request, + Options opts = {}); + + private: + std::shared_ptr connection_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CLIENT_H diff --git a/google/cloud/ftp/v1/cloud_ftp_connection.cc b/google/cloud/ftp/v1/cloud_ftp_connection.cc new file mode 100644 index 0000000000000..27aecc4e2c8c8 --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_connection.cc @@ -0,0 +1,266 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/cloud_ftp_connection.h" +#include "google/cloud/ftp/v1/cloud_ftp_options.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/grpc_options.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/unified_grpc_credentials.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +CloudFtpConnection::~CloudFtpConnection() = default; + +StreamRange CloudFtpConnection::ListServers( + google::cloud::ftp::v1:: + ListServersRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudFtpConnection::GetServer( + google::cloud::ftp::v1::GetServerRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> +CloudFtpConnection::CreateServer( + google::cloud::ftp::v1::CreateServerRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::CreateServer( + NoAwaitTag, google::cloud::ftp::v1::CreateServerRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::CreateServer(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::UpdateServerRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::UpdateServer(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::DeleteServer( + NoAwaitTag, google::cloud::ftp::v1::DeleteServerRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::DeleteServer(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange CloudFtpConnection::ListUsers( + google::cloud::ftp::v1:: + ListUsersRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudFtpConnection::GetUser( + google::cloud::ftp::v1::GetUserRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +future> CloudFtpConnection::CreateUser( + google::cloud::ftp::v1::CreateUserRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::CreateUser( + NoAwaitTag, google::cloud::ftp::v1::CreateUserRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> CloudFtpConnection::CreateUser( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> CloudFtpConnection::UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::UpdateUserRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> CloudFtpConnection::UpdateUser( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::DeleteUser( + NoAwaitTag, google::cloud::ftp::v1::DeleteUserRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::DeleteUser(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::StartServer( + google::cloud::ftp::v1::StartServerRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::StartServer( + NoAwaitTag, google::cloud::ftp::v1::StartServerRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> +CloudFtpConnection::StartServer(google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> CloudFtpConnection::StopServer( + google::cloud::ftp::v1::StopServerRequest const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StatusOr CloudFtpConnection::StopServer( + NoAwaitTag, google::cloud::ftp::v1::StopServerRequest const&) { + return StatusOr( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +future> CloudFtpConnection::StopServer( + google::longrunning::Operation const&) { + return google::cloud::make_ready_future< + StatusOr>( + Status(StatusCode::kUnimplemented, "not implemented")); +} + +StreamRange +CloudFtpConnection::ListLocations( + google::cloud::location:: + ListLocationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudFtpConnection::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +StreamRange CloudFtpConnection::ListOperations( + google::longrunning:: + ListOperationsRequest) { // NOLINT(performance-unnecessary-value-param) + return google::cloud::internal::MakeUnimplementedPaginationRange< + StreamRange>(); +} + +StatusOr CloudFtpConnection::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudFtpConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +Status CloudFtpConnection::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Status(StatusCode::kUnimplemented, "not implemented"); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/cloud_ftp_connection.h b/google/cloud/ftp/v1/cloud_ftp_connection.h new file mode 100644 index 0000000000000..92e1bbe95cb59 --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_connection.h @@ -0,0 +1,294 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CONNECTION_H + +#include "google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_retry_traits.h" +#include "google/cloud/ftp/v1/service.pb.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/future.h" +#include "google/cloud/internal/retry_policy_impl.h" +#include "google/cloud/no_await_tag.h" +#include "google/cloud/options.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.grpc.pb.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// The retry policy for `CloudFtpConnection`. +class CloudFtpRetryPolicy : public ::google::cloud::RetryPolicy { + public: + /// Creates a new instance of the policy, reset to the initial state. + virtual std::unique_ptr clone() const = 0; +}; + +/** + * A retry policy for `CloudFtpConnection` based on counting errors. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - More than a prescribed number of transient failures is detected. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class CloudFtpLimitedErrorCountRetryPolicy : public CloudFtpRetryPolicy { + public: + /** + * Create an instance that tolerates up to @p maximum_failures transient + * errors. + * + * @note Disable the retry loop by providing an instance of this policy with + * @p maximum_failures == 0. + */ + explicit CloudFtpLimitedErrorCountRetryPolicy(int maximum_failures) + : impl_(maximum_failures) {} + + CloudFtpLimitedErrorCountRetryPolicy( + CloudFtpLimitedErrorCountRetryPolicy&& rhs) noexcept + : CloudFtpLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + CloudFtpLimitedErrorCountRetryPolicy( + CloudFtpLimitedErrorCountRetryPolicy const& rhs) noexcept + : CloudFtpLimitedErrorCountRetryPolicy(rhs.maximum_failures()) {} + + int maximum_failures() const { return impl_.maximum_failures(); } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique( + maximum_failures()); + } + + // This is provided only for backwards compatibility. + using BaseType = CloudFtpRetryPolicy; + + private: + google::cloud::internal::LimitedErrorCountRetryPolicy< + ftp_v1_internal::CloudFtpRetryTraits> + impl_; +}; + +/** + * A retry policy for `CloudFtpConnection` based on elapsed time. + * + * This policy stops retrying if: + * - An RPC returns a non-transient error. + * - The elapsed time in the retry loop exceeds a prescribed duration. + * + * In this class the following status codes are treated as transient errors: + * - [`kUnavailable`](@ref google::cloud::StatusCode) + */ +class CloudFtpLimitedTimeRetryPolicy : public CloudFtpRetryPolicy { + public: + /** + * Constructor given a `std::chrono::duration<>` object. + * + * @tparam DurationRep a placeholder to match the `Rep` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the underlying + * arithmetic type used to store the number of ticks. For our purposes it + * is simply a formal parameter. + * @tparam DurationPeriod a placeholder to match the `Period` tparam for @p + * duration's type. The semantics of this template parameter are + * documented in `std::chrono::duration<>`. In brief, the length of the + * tick in seconds, expressed as a `std::ratio<>`. For our purposes it is + * simply a formal parameter. + * @param maximum_duration the maximum time allowed before the policy expires. + * While the application can express this time in any units they desire, + * the class truncates to milliseconds. + * + * @see https://en.cppreference.com/w/cpp/chrono/duration for more information + * about `std::chrono::duration`. + */ + template + explicit CloudFtpLimitedTimeRetryPolicy( + std::chrono::duration maximum_duration) + : impl_(maximum_duration) {} + + CloudFtpLimitedTimeRetryPolicy(CloudFtpLimitedTimeRetryPolicy&& rhs) noexcept + : CloudFtpLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + CloudFtpLimitedTimeRetryPolicy( + CloudFtpLimitedTimeRetryPolicy const& rhs) noexcept + : CloudFtpLimitedTimeRetryPolicy(rhs.maximum_duration()) {} + + std::chrono::milliseconds maximum_duration() const { + return impl_.maximum_duration(); + } + + bool OnFailure(Status const& status) override { + return impl_.OnFailure(status); + } + bool IsExhausted() const override { return impl_.IsExhausted(); } + bool IsPermanentFailure(Status const& status) const override { + return impl_.IsPermanentFailure(status); + } + std::unique_ptr clone() const override { + return std::make_unique(maximum_duration()); + } + + // This is provided only for backwards compatibility. + using BaseType = CloudFtpRetryPolicy; + + private: + google::cloud::internal::LimitedTimeRetryPolicy< + ftp_v1_internal::CloudFtpRetryTraits> + impl_; +}; + +/** + * The `CloudFtpConnection` object for `CloudFtpClient`. + * + * This interface defines virtual methods for each of the user-facing overload + * sets in `CloudFtpClient`. This allows users to inject custom behavior + * (e.g., with a Google Mock object) when writing tests that use objects of type + * `CloudFtpClient`. + * + * To create a concrete instance, see `MakeCloudFtpConnection()`. + * + * For mocking, see `ftp_v1_mocks::MockCloudFtpConnection`. + */ +class CloudFtpConnection { + public: + virtual ~CloudFtpConnection() = 0; + + virtual Options options() { return Options{}; } + + virtual StreamRange ListServers( + google::cloud::ftp::v1::ListServersRequest request); + + virtual StatusOr GetServer( + google::cloud::ftp::v1::GetServerRequest const& request); + + virtual future> CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request); + + virtual StatusOr CreateServer( + NoAwaitTag, google::cloud::ftp::v1::CreateServerRequest const& request); + + virtual future> CreateServer( + google::longrunning::Operation const& operation); + + virtual future> UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request); + + virtual StatusOr UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::UpdateServerRequest const& request); + + virtual future> UpdateServer( + google::longrunning::Operation const& operation); + + virtual future> + DeleteServer(google::cloud::ftp::v1::DeleteServerRequest const& request); + + virtual StatusOr DeleteServer( + NoAwaitTag, google::cloud::ftp::v1::DeleteServerRequest const& request); + + virtual future> + DeleteServer(google::longrunning::Operation const& operation); + + virtual StreamRange ListUsers( + google::cloud::ftp::v1::ListUsersRequest request); + + virtual StatusOr GetUser( + google::cloud::ftp::v1::GetUserRequest const& request); + + virtual future> CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request); + + virtual StatusOr CreateUser( + NoAwaitTag, google::cloud::ftp::v1::CreateUserRequest const& request); + + virtual future> CreateUser( + google::longrunning::Operation const& operation); + + virtual future> UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request); + + virtual StatusOr UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::UpdateUserRequest const& request); + + virtual future> UpdateUser( + google::longrunning::Operation const& operation); + + virtual future> + DeleteUser(google::cloud::ftp::v1::DeleteUserRequest const& request); + + virtual StatusOr DeleteUser( + NoAwaitTag, google::cloud::ftp::v1::DeleteUserRequest const& request); + + virtual future> + DeleteUser(google::longrunning::Operation const& operation); + + virtual future> StartServer( + google::cloud::ftp::v1::StartServerRequest const& request); + + virtual StatusOr StartServer( + NoAwaitTag, google::cloud::ftp::v1::StartServerRequest const& request); + + virtual future> StartServer( + google::longrunning::Operation const& operation); + + virtual future> StopServer( + google::cloud::ftp::v1::StopServerRequest const& request); + + virtual StatusOr StopServer( + NoAwaitTag, google::cloud::ftp::v1::StopServerRequest const& request); + + virtual future> StopServer( + google::longrunning::Operation const& operation); + + virtual StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual StreamRange ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual Status CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CONNECTION_H diff --git a/google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.cc b/google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.cc new file mode 100644 index 0000000000000..e825f66030cf7 --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.cc @@ -0,0 +1,135 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +using ::google::cloud::Idempotency; + +CloudFtpConnectionIdempotencyPolicy::~CloudFtpConnectionIdempotencyPolicy() = + default; + +std::unique_ptr +CloudFtpConnectionIdempotencyPolicy::clone() const { + return std::make_unique(*this); +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::ListServers( + google::cloud::ftp::v1::ListServersRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::GetServer( + google::cloud::ftp::v1::GetServerRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::CreateServer( + google::cloud::ftp::v1::CreateServerRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::ListUsers( + google::cloud::ftp::v1::ListUsersRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::GetUser( + google::cloud::ftp::v1::GetUserRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::CreateUser( + google::cloud::ftp::v1::CreateUserRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::StartServer( + google::cloud::ftp::v1::StartServerRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::StopServer( + google::cloud::ftp::v1::StopServerRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::ListLocations( + google::cloud::location::ListLocationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::GetLocation( + google::cloud::location::GetLocationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::ListOperations( + google::longrunning::ListOperationsRequest) { // NOLINT + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::GetOperation( + google::longrunning::GetOperationRequest const&) { + return Idempotency::kIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::DeleteOperation( + google::longrunning::DeleteOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +Idempotency CloudFtpConnectionIdempotencyPolicy::CancelOperation( + google::longrunning::CancelOperationRequest const&) { + return Idempotency::kNonIdempotent; +} + +std::unique_ptr +MakeDefaultCloudFtpConnectionIdempotencyPolicy() { + return std::make_unique(); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.h b/google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.h new file mode 100644 index 0000000000000..a64a0309873b4 --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.h @@ -0,0 +1,104 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CONNECTION_IDEMPOTENCY_POLICY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CONNECTION_IDEMPOTENCY_POLICY_H + +#include "google/cloud/ftp/v1/service.pb.h" +#include "google/cloud/location/locations.pb.h" +#include "google/cloud/idempotency.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.pb.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class CloudFtpConnectionIdempotencyPolicy { + public: + virtual ~CloudFtpConnectionIdempotencyPolicy(); + + /// Create a new copy of this object. + virtual std::unique_ptr clone() const; + + virtual google::cloud::Idempotency ListServers( + google::cloud::ftp::v1::ListServersRequest request); + + virtual google::cloud::Idempotency GetServer( + google::cloud::ftp::v1::GetServerRequest const& request); + + virtual google::cloud::Idempotency CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request); + + virtual google::cloud::Idempotency UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request); + + virtual google::cloud::Idempotency DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const& request); + + virtual google::cloud::Idempotency ListUsers( + google::cloud::ftp::v1::ListUsersRequest request); + + virtual google::cloud::Idempotency GetUser( + google::cloud::ftp::v1::GetUserRequest const& request); + + virtual google::cloud::Idempotency CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request); + + virtual google::cloud::Idempotency UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request); + + virtual google::cloud::Idempotency DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const& request); + + virtual google::cloud::Idempotency StartServer( + google::cloud::ftp::v1::StartServerRequest const& request); + + virtual google::cloud::Idempotency StopServer( + google::cloud::ftp::v1::StopServerRequest const& request); + + virtual google::cloud::Idempotency ListLocations( + google::cloud::location::ListLocationsRequest request); + + virtual google::cloud::Idempotency GetLocation( + google::cloud::location::GetLocationRequest const& request); + + virtual google::cloud::Idempotency ListOperations( + google::longrunning::ListOperationsRequest request); + + virtual google::cloud::Idempotency GetOperation( + google::longrunning::GetOperationRequest const& request); + + virtual google::cloud::Idempotency DeleteOperation( + google::longrunning::DeleteOperationRequest const& request); + + virtual google::cloud::Idempotency CancelOperation( + google::longrunning::CancelOperationRequest const& request); +}; + +std::unique_ptr +MakeDefaultCloudFtpConnectionIdempotencyPolicy(); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_CONNECTION_IDEMPOTENCY_POLICY_H diff --git a/google/cloud/ftp/v1/cloud_ftp_options.h b/google/cloud/ftp/v1/cloud_ftp_options.h new file mode 100644 index 0000000000000..9f07054559e79 --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_options.h @@ -0,0 +1,86 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_OPTIONS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_OPTIONS_H + +#include "google/cloud/ftp/v1/cloud_ftp_connection.h" +#include "google/cloud/ftp/v1/cloud_ftp_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 ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * Use with `google::cloud::Options` to configure the retry policy. + * + * @ingroup google-cloud-ftp-options + */ +struct CloudFtpRetryPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the backoff policy. + * + * @ingroup google-cloud-ftp-options + */ +struct CloudFtpBackoffPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure which operations are retried. + * + * @ingroup google-cloud-ftp-options + */ +struct CloudFtpConnectionIdempotencyPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * Use with `google::cloud::Options` to configure the long-running operations + * polling policy. + * + * @ingroup google-cloud-ftp-options + */ +struct CloudFtpPollingPolicyOption { + using Type = std::shared_ptr; +}; + +/** + * The options applicable to CloudFtp. + * + * @ingroup google-cloud-ftp-options + */ +using CloudFtpPolicyOptionList = + OptionList; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_OPTIONS_H diff --git a/google/cloud/ftp/v1/cloud_ftp_rest_connection.cc b/google/cloud/ftp/v1/cloud_ftp_rest_connection.cc new file mode 100644 index 0000000000000..d3ee99e49ef62 --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_rest_connection.cc @@ -0,0 +1,55 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/cloud_ftp_rest_connection.h" +#include "google/cloud/ftp/v1/cloud_ftp_options.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/rest_background_threads_impl.h" +#include "google/cloud/internal/rest_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr MakeCloudFtpConnectionRest( + Options options) { + internal::CheckExpectedOptions< + CommonOptionList, RestOptionList, UnifiedCredentialsOptionList, + rest_internal::TargetApiVersionOption, CloudFtpPolicyOptionList>( + options, __func__); + options = ftp_v1_internal::CloudFtpDefaultOptions(std::move(options)); + auto background = std::make_unique< + rest_internal::AutomaticallyCreatedRestBackgroundThreads>(); + auto stub = ftp_v1_internal::CreateDefaultCloudFtpRestStub(options); + return ftp_v1_internal::MakeCloudFtpTracingConnection( + std::make_shared( + std::move(background), std::move(stub), std::move(options))); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/cloud_ftp_rest_connection.h b/google/cloud/ftp/v1/cloud_ftp_rest_connection.h new file mode 100644 index 0000000000000..2901fae2b611f --- /dev/null +++ b/google/cloud/ftp/v1/cloud_ftp_rest_connection.h @@ -0,0 +1,64 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_REST_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_REST_CONNECTION_H + +#include "google/cloud/ftp/v1/cloud_ftp_connection.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1 { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A factory function to construct an object of type `CloudFtpConnection` + * that uses REST over HTTP as transport in lieu of gRPC. REST transport should + * only be used for services that do not support gRPC or if the existing network + * configuration precludes using gRPC. + * + * The returned connection object should not be used directly; instead it + * should be passed as an argument to the constructor of CloudFtpClient. + * + * The optional @p options argument may be used to configure aspects of the + * returned `CloudFtpConnection`. Expected options are any of the types in + * the following option lists: + * + * - `google::cloud::CommonOptionList` + * - `google::cloud::RestOptionList` + * - `google::cloud::UnifiedCredentialsOptionList` + * - `google::cloud::ftp_v1::CloudFtpPolicyOptionList` + * + * @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 `CloudFtpConnection` created by + * this function. + */ +std::shared_ptr MakeCloudFtpConnectionRest( + Options options = {}); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1 +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_CLOUD_FTP_REST_CONNECTION_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.cc b/google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.cc new file mode 100644 index 0000000000000..9272a13068e2c --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.cc @@ -0,0 +1,74 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.h" +#include "google/cloud/ftp/v1/cloud_ftp_connection.h" +#include "google/cloud/ftp/v1/cloud_ftp_options.h" +#include "google/cloud/internal/populate_common_options.h" +#include "google/cloud/internal/populate_grpc_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +namespace { +auto constexpr kBackoffScaling = 2.0; +} // namespace + +Options CloudFtpDefaultOptions(Options options) { + options = internal::PopulateCommonOptions( + std::move(options), "GOOGLE_CLOUD_CPP_CLOUD_FTP_ENDPOINT", "", + "GOOGLE_CLOUD_CPP_CLOUD_FTP_AUTHORITY", "ftp.googleapis.com"); + options = internal::PopulateGrpcOptions(std::move(options)); + if (!options.has()) { + options.set( + ftp_v1::CloudFtpLimitedTimeRetryPolicy(std::chrono::minutes(10)) + .clone()); + } + if (!options.has()) { + options.set( + ExponentialBackoffPolicy( + std::chrono::seconds(0), std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling, kBackoffScaling) + .clone()); + } + if (!options.has()) { + options.set( + GenericPollingPolicy( + options.get()->clone(), + ExponentialBackoffPolicy(std::chrono::seconds(1), + std::chrono::minutes(5), kBackoffScaling) + .clone()) + .clone()); + } + if (!options.has()) { + options.set( + ftp_v1::MakeDefaultCloudFtpConnectionIdempotencyPolicy()); + } + + return options; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.h b/google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.h new file mode 100644 index 0000000000000..d123de06adf7b --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.h @@ -0,0 +1,37 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_OPTION_DEFAULTS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_OPTION_DEFAULTS_H + +#include "google/cloud/options.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +Options CloudFtpDefaultOptions(Options options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_OPTION_DEFAULTS_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.cc b/google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.cc new file mode 100644 index 0000000000000..ee35408cb36a2 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.cc @@ -0,0 +1,943 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/async_rest_long_running_operation.h" +#include "google/cloud/internal/extract_long_running_result.h" +#include "google/cloud/internal/pagination_range.h" +#include "google/cloud/internal/rest_retry_loop.h" +#include "google/cloud/rest_options.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +CloudFtpRestConnectionImpl::CloudFtpRestConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options) + : background_(std::move(background)), + stub_(std::move(stub)), + options_(internal::MergeOptions(std::move(options), + CloudFtpConnection::options())) {} + +StreamRange +CloudFtpRestConnectionImpl::ListServers( + google::cloud::ftp::v1::ListServersRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListServers(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr(retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::ftp::v1::ListServersRequest const& r) { + return google::cloud::rest_internal::RestRetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) { + return stub->ListServers(rest_context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ftp::v1::ListServersResponse r) { + std::vector result(r.servers().size()); + auto& messages = *r.mutable_servers(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr CloudFtpRestConnectionImpl::GetServer( + google::cloud::ftp::v1::GetServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetServer(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) { + return stub_->GetServer(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, request, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + return stub->AsyncCreateServer(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateServer(request), + polling_policy(*current), __func__); +} + +StatusOr +CloudFtpRestConnectionImpl::CreateServer( + NoAwaitTag, google::cloud::ftp::v1::CreateServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateServer(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + return stub_->CreateServer(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::CreateServer( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to CreateServer", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + polling_policy(*current), __func__); +} + +future> +CloudFtpRestConnectionImpl::UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, request, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + return stub->AsyncUpdateServer(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateServer(request), + polling_policy(*current), __func__); +} + +StatusOr +CloudFtpRestConnectionImpl::UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::UpdateServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateServer(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + return stub_->UpdateServer(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::UpdateServer( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to UpdateServer", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + polling_policy(*current), __func__); +} + +future> +CloudFtpRestConnectionImpl::DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::OperationMetadata>( + background_->cq(), current, request, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + return stub->AsyncDeleteServer(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::ftp::v1::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteServer(request), + polling_policy(*current), __func__); +} + +StatusOr +CloudFtpRestConnectionImpl::DeleteServer( + NoAwaitTag, google::cloud::ftp::v1::DeleteServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteServer(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + return stub_->DeleteServer(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::DeleteServer( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future< + StatusOr>( + internal::InvalidArgumentError( + "operation does not correspond to DeleteServer", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::OperationMetadata>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::ftp::v1::OperationMetadata>, + polling_policy(*current), __func__); +} + +StreamRange CloudFtpRestConnectionImpl::ListUsers( + google::cloud::ftp::v1::ListUsersRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListUsers(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr(retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& r) { + return google::cloud::rest_internal::RestRetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) { + return stub->ListUsers(rest_context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::ftp::v1::ListUsersResponse r) { + std::vector result(r.users().size()); + auto& messages = *r.mutable_users(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr CloudFtpRestConnectionImpl::GetUser( + google::cloud::ftp::v1::GetUserRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetUser(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) { + return stub_->GetUser(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::User>( + background_->cq(), current, request, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + return stub->AsyncCreateUser(cq, std::move(context), std::move(options), + request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::User>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateUser(request), + polling_policy(*current), __func__); +} + +StatusOr CloudFtpRestConnectionImpl::CreateUser( + NoAwaitTag, google::cloud::ftp::v1::CreateUserRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CreateUser(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + return stub_->CreateUser(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::CreateUser( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to CreateUser", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::User>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::User>, + polling_policy(*current), __func__); +} + +future> +CloudFtpRestConnectionImpl::UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::User>( + background_->cq(), current, request, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + return stub->AsyncUpdateUser(cq, std::move(context), std::move(options), + request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::User>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateUser(request), + polling_policy(*current), __func__); +} + +StatusOr CloudFtpRestConnectionImpl::UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::UpdateUserRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->UpdateUser(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + return stub_->UpdateUser(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::UpdateUser( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to UpdateUser", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::User>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::User>, + polling_policy(*current), __func__); +} + +future> +CloudFtpRestConnectionImpl::DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::OperationMetadata>( + background_->cq(), current, request, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + return stub->AsyncDeleteUser(cq, std::move(context), std::move(options), + request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::ftp::v1::OperationMetadata>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteUser(request), + polling_policy(*current), __func__); +} + +StatusOr CloudFtpRestConnectionImpl::DeleteUser( + NoAwaitTag, google::cloud::ftp::v1::DeleteUserRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteUser(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + return stub_->DeleteUser(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::DeleteUser( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future< + StatusOr>( + internal::InvalidArgumentError( + "operation does not correspond to DeleteUser", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::OperationMetadata>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultMetadata< + google::cloud::ftp::v1::OperationMetadata>, + polling_policy(*current), __func__); +} + +future> +CloudFtpRestConnectionImpl::StartServer( + google::cloud::ftp::v1::StartServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, request, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) { + return stub->AsyncStartServer(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->StartServer(request), + polling_policy(*current), __func__); +} + +StatusOr +CloudFtpRestConnectionImpl::StartServer( + NoAwaitTag, google::cloud::ftp::v1::StartServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->StartServer(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) { + return stub_->StartServer(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::StartServer( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to StartServer", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + polling_policy(*current), __func__); +} + +future> +CloudFtpRestConnectionImpl::StopServer( + google::cloud::ftp::v1::StopServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return rest_internal::AsyncRestLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, request, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) { + return stub->AsyncStopServer(cq, std::move(context), std::move(options), + request); + }, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->StopServer(request), + polling_policy(*current), __func__); +} + +StatusOr CloudFtpRestConnectionImpl::StopServer( + NoAwaitTag, google::cloud::ftp::v1::StopServerRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->StopServer(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) { + return stub_->StopServer(rest_context, options, request); + }, + *current, request, __func__); +} + +future> +CloudFtpRestConnectionImpl::StopServer( + google::longrunning::Operation const& operation) { + auto current = google::cloud::internal::SaveCurrentOptions(); + if (!operation.metadata() + .Is()) { + return make_ready_future>( + internal::InvalidArgumentError( + "operation does not correspond to StopServer", + GCP_ERROR_INFO().WithMetadata("operation", + operation.metadata().DebugString()))); + } + return rest_internal::AsyncRestAwaitLongRunningOperation< + google::cloud::ftp::v1::Server>( + background_->cq(), current, operation, + [stub = stub_](CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return stub->AsyncGetOperation(cq, std::move(context), + std::move(options), request); + }, + [stub = stub_]( + CompletionQueue& cq, + std::unique_ptr context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return stub->AsyncCancelOperation(cq, std::move(context), + std::move(options), request); + }, + &google::cloud::internal::ExtractLongRunningResultResponse< + google::cloud::ftp::v1::Server>, + polling_policy(*current), __func__); +} + +StreamRange +CloudFtpRestConnectionImpl::ListLocations( + google::cloud::location::ListLocationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListLocations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr(retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::cloud::location::ListLocationsRequest const& r) { + return google::cloud::rest_internal::RestRetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub]( + rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return stub->ListLocations(rest_context, options, request); + }, + options, r, function_name); + }, + [](google::cloud::location::ListLocationsResponse r) { + std::vector result( + r.locations().size()); + auto& messages = *r.mutable_locations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudFtpRestConnectionImpl::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetLocation(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return stub_->GetLocation(rest_context, options, request); + }, + *current, request, __func__); +} + +StreamRange +CloudFtpRestConnectionImpl::ListOperations( + google::longrunning::ListOperationsRequest request) { + request.clear_page_token(); + auto current = google::cloud::internal::SaveCurrentOptions(); + auto idempotency = idempotency_policy(*current)->ListOperations(request); + char const* function_name = __func__; + return google::cloud::internal::MakePaginationRange< + StreamRange>( + current, std::move(request), + [idempotency, function_name, stub = stub_, + retry = + std::shared_ptr(retry_policy(*current)), + backoff = std::shared_ptr(backoff_policy(*current))]( + Options const& options, + google::longrunning::ListOperationsRequest const& r) { + return google::cloud::rest_internal::RestRetryLoop( + retry->clone(), backoff->clone(), idempotency, + [stub](rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return stub->ListOperations(rest_context, options, request); + }, + options, r, function_name); + }, + [](google::longrunning::ListOperationsResponse r) { + std::vector result( + r.operations().size()); + auto& messages = *r.mutable_operations(); + std::move(messages.begin(), messages.end(), result.begin()); + return result; + }); +} + +StatusOr +CloudFtpRestConnectionImpl::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->GetOperation(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return stub_->GetOperation(rest_context, options, request); + }, + *current, request, __func__); +} + +Status CloudFtpRestConnectionImpl::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->DeleteOperation(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return stub_->DeleteOperation(rest_context, options, request); + }, + *current, request, __func__); +} + +Status CloudFtpRestConnectionImpl::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto current = google::cloud::internal::SaveCurrentOptions(); + return google::cloud::rest_internal::RestRetryLoop( + retry_policy(*current), backoff_policy(*current), + idempotency_policy(*current)->CancelOperation(request), + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return stub_->CancelOperation(rest_context, options, request); + }, + *current, request, __func__); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.h b/google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.h new file mode 100644 index 0000000000000..089096c744b7a --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.h @@ -0,0 +1,191 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_CONNECTION_IMPL_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_CONNECTION_IMPL_H + +#include "google/cloud/ftp/v1/cloud_ftp_connection.h" +#include "google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.h" +#include "google/cloud/ftp/v1/cloud_ftp_options.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_retry_traits.h" +#include "google/cloud/background_threads.h" +#include "google/cloud/backoff_policy.h" +#include "google/cloud/options.h" +#include "google/cloud/status_or.h" +#include "google/cloud/stream_range.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.pb.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class CloudFtpRestConnectionImpl : public ftp_v1::CloudFtpConnection { + public: + ~CloudFtpRestConnectionImpl() override = default; + + CloudFtpRestConnectionImpl( + std::unique_ptr background, + std::shared_ptr stub, Options options); + + Options options() override { return options_; } + + StreamRange ListServers( + google::cloud::ftp::v1::ListServersRequest request) override; + + StatusOr GetServer( + google::cloud::ftp::v1::GetServerRequest const& request) override; + + future> CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + StatusOr CreateServer( + NoAwaitTag, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + future> CreateServer( + google::longrunning::Operation const& operation) override; + + future> UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + StatusOr UpdateServer( + NoAwaitTag, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + future> UpdateServer( + google::longrunning::Operation const& operation) override; + + future> DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr DeleteServer( + NoAwaitTag, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + future> DeleteServer( + google::longrunning::Operation const& operation) override; + + StreamRange ListUsers( + google::cloud::ftp::v1::ListUsersRequest request) override; + + StatusOr GetUser( + google::cloud::ftp::v1::GetUserRequest const& request) override; + + future> CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + StatusOr CreateUser( + NoAwaitTag, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + future> CreateUser( + google::longrunning::Operation const& operation) override; + + future> UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + StatusOr UpdateUser( + NoAwaitTag, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + future> UpdateUser( + google::longrunning::Operation const& operation) override; + + future> DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + StatusOr DeleteUser( + NoAwaitTag, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + future> DeleteUser( + google::longrunning::Operation const& operation) override; + + future> StartServer( + google::cloud::ftp::v1::StartServerRequest const& request) override; + + StatusOr StartServer( + NoAwaitTag, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + future> StartServer( + google::longrunning::Operation const& operation) override; + + future> StopServer( + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr StopServer( + NoAwaitTag, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + future> StopServer( + google::longrunning::Operation const& operation) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + static std::unique_ptr retry_policy( + Options const& options) { + return options.get()->clone(); + } + + static std::unique_ptr backoff_policy(Options const& options) { + return options.get()->clone(); + } + + static std::unique_ptr + idempotency_policy(Options const& options) { + return options.get() + ->clone(); + } + + static std::unique_ptr polling_policy(Options const& options) { + return options.get()->clone(); + } + + std::unique_ptr background_; + std::shared_ptr stub_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_CONNECTION_IMPL_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.cc b/google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.cc new file mode 100644 index 0000000000000..b4217d95d40d8 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.cc @@ -0,0 +1,421 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.h" +#include "google/cloud/internal/log_wrapper.h" +#include "google/cloud/status_or.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +CloudFtpRestLogging::CloudFtpRestLogging( + std::shared_ptr child, TracingOptions tracing_options, + std::set components) + : child_(std::move(child)), + tracing_options_(std::move(tracing_options)), + components_(std::move(components)) {} + +StatusOr +CloudFtpRestLogging::ListServers( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) { + return child_->ListServers(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr CloudFtpRestLogging::GetServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) { + return child_->GetServer(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncCreateServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + return child_->AsyncCreateServer(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::CreateServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + return child_->CreateServer(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncUpdateServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + return child_->AsyncUpdateServer(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::UpdateServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + return child_->UpdateServer(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncDeleteServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + return child_->AsyncDeleteServer(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::DeleteServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + return child_->DeleteServer(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudFtpRestLogging::ListUsers( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) { + return child_->ListUsers(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr CloudFtpRestLogging::GetUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) { + return child_->GetUser(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncCreateUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + return child_->AsyncCreateUser(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::CreateUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + return child_->CreateUser(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncUpdateUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + return child_->AsyncUpdateUser(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::UpdateUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + return child_->UpdateUser(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncDeleteUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + return child_->AsyncDeleteUser(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::DeleteUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + return child_->DeleteUser(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncStartServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) { + return child_->AsyncStartServer(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::StartServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) { + return child_->StartServer(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncStopServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) { + return child_->AsyncStopServer(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +StatusOr CloudFtpRestLogging::StopServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) { + return child_->StopServer(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudFtpRestLogging::ListLocations( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + return child_->ListLocations(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr CloudFtpRestLogging::GetLocation( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + return child_->GetLocation(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr +CloudFtpRestLogging::ListOperations( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + return child_->ListOperations(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +StatusOr CloudFtpRestLogging::GetOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + return child_->GetOperation(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +Status CloudFtpRestLogging::DeleteOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + return child_->DeleteOperation(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +Status CloudFtpRestLogging::CancelOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + return child_->CancelOperation(rest_context, options, request); + }, + rest_context, options, request, __func__, tracing_options_); +} + +future> +CloudFtpRestLogging::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + return child_->AsyncGetOperation(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +future CloudFtpRestLogging::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return google::cloud::internal::LogWrapper( + [this](CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + return child_->AsyncCancelOperation(cq, std::move(rest_context), + std::move(options), request); + }, + cq, std::move(rest_context), std::move(options), request, __func__, + tracing_options_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.h b/google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.h new file mode 100644 index 0000000000000..fcffbb5b014d3 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.h @@ -0,0 +1,206 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_LOGGING_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_LOGGING_DECORATOR_H + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h" +#include "google/cloud/ftp/v1/service.pb.h" +#include "google/cloud/future.h" +#include "google/cloud/internal/rest_context.h" +#include "google/cloud/tracing_options.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.pb.h" +#include +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class CloudFtpRestLogging : public CloudFtpRestStub { + public: + ~CloudFtpRestLogging() override = default; + CloudFtpRestLogging(std::shared_ptr child, + TracingOptions tracing_options, + std::set components); + + StatusOr ListServers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) override; + + StatusOr GetServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) override; + + future> AsyncCreateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + StatusOr CreateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + future> AsyncUpdateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + StatusOr UpdateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + future> AsyncDeleteServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr DeleteServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr ListUsers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) override; + + StatusOr GetUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) override; + + future> AsyncCreateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + StatusOr CreateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + future> AsyncUpdateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + StatusOr UpdateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + future> AsyncDeleteUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + StatusOr DeleteUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + future> AsyncStartServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + StatusOr StartServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + future> AsyncStopServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr StopServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr ListLocations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; + TracingOptions tracing_options_; + std::set components_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_LOGGING_DECORATOR_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.cc b/google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.cc new file mode 100644 index 0000000000000..fbd461cc5df9a --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.cc @@ -0,0 +1,290 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.h" +#include "google/cloud/internal/api_client_header.h" +#include "google/cloud/internal/rest_set_metadata.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/str_format.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +CloudFtpRestMetadata::CloudFtpRestMetadata( + std::shared_ptr child, std::string api_client_header) + : child_(std::move(child)), + api_client_header_( + api_client_header.empty() + ? google::cloud::internal::GeneratedLibClientHeader() + : std::move(api_client_header)) {} + +StatusOr +CloudFtpRestMetadata::ListServers( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) { + SetMetadata(rest_context, options); + return child_->ListServers(rest_context, options, request); +} + +StatusOr CloudFtpRestMetadata::GetServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) { + SetMetadata(rest_context, options); + return child_->GetServer(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncCreateServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncCreateServer(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::CreateServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + SetMetadata(rest_context, options); + return child_->CreateServer(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncUpdateServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncUpdateServer(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::UpdateServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + SetMetadata(rest_context, options); + return child_->UpdateServer(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncDeleteServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncDeleteServer(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::DeleteServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + SetMetadata(rest_context, options); + return child_->DeleteServer(rest_context, options, request); +} + +StatusOr +CloudFtpRestMetadata::ListUsers( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) { + SetMetadata(rest_context, options); + return child_->ListUsers(rest_context, options, request); +} + +StatusOr CloudFtpRestMetadata::GetUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) { + SetMetadata(rest_context, options); + return child_->GetUser(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncCreateUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncCreateUser(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::CreateUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + SetMetadata(rest_context, options); + return child_->CreateUser(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncUpdateUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncUpdateUser(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::UpdateUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + SetMetadata(rest_context, options); + return child_->UpdateUser(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncDeleteUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncDeleteUser(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::DeleteUser( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + SetMetadata(rest_context, options); + return child_->DeleteUser(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncStartServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncStartServer(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::StartServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) { + SetMetadata(rest_context, options); + return child_->StartServer(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncStopServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncStopServer(cq, std::move(rest_context), + std::move(options), request); +} + +StatusOr CloudFtpRestMetadata::StopServer( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) { + SetMetadata(rest_context, options); + return child_->StopServer(rest_context, options, request); +} + +StatusOr +CloudFtpRestMetadata::ListLocations( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + SetMetadata(rest_context, options); + return child_->ListLocations(rest_context, options, request); +} + +StatusOr CloudFtpRestMetadata::GetLocation( + rest_internal::RestContext& rest_context, Options const& options, + google::cloud::location::GetLocationRequest const& request) { + SetMetadata(rest_context, options); + return child_->GetLocation(rest_context, options, request); +} + +StatusOr +CloudFtpRestMetadata::ListOperations( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::ListOperationsRequest const& request) { + SetMetadata(rest_context, options); + return child_->ListOperations(rest_context, options, request); +} + +StatusOr CloudFtpRestMetadata::GetOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(rest_context, options); + return child_->GetOperation(rest_context, options, request); +} + +Status CloudFtpRestMetadata::DeleteOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + SetMetadata(rest_context, options); + return child_->DeleteOperation(rest_context, options, request); +} + +Status CloudFtpRestMetadata::CancelOperation( + rest_internal::RestContext& rest_context, Options const& options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(rest_context, options); + return child_->CancelOperation(rest_context, options, request); +} + +future> +CloudFtpRestMetadata::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncGetOperation(cq, std::move(rest_context), + std::move(options), request); +} + +future CloudFtpRestMetadata::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + SetMetadata(*rest_context, *options); + return child_->AsyncCancelOperation(cq, std::move(rest_context), + std::move(options), request); +} + +void CloudFtpRestMetadata::SetMetadata(rest_internal::RestContext& rest_context, + Options const& options, + std::vector const& params) { + google::cloud::rest_internal::SetMetadata(rest_context, options, params, + api_client_header_); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.h b/google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.h new file mode 100644 index 0000000000000..b847f7238372e --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.h @@ -0,0 +1,215 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_METADATA_DECORATOR_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_METADATA_DECORATOR_H + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h" +#include "google/cloud/ftp/v1/service.pb.h" +#include "google/cloud/future.h" +#include "google/cloud/rest_options.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.pb.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class CloudFtpRestMetadata : public CloudFtpRestStub { + public: + ~CloudFtpRestMetadata() override = default; + explicit CloudFtpRestMetadata(std::shared_ptr child, + std::string api_client_header = ""); + + StatusOr ListServers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) override; + + StatusOr GetServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) override; + + google::cloud::future> + AsyncCreateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + StatusOr CreateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + google::cloud::future> + AsyncUpdateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + StatusOr UpdateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + google::cloud::future> + AsyncDeleteServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr DeleteServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr ListUsers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) override; + + StatusOr GetUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) override; + + google::cloud::future> + AsyncCreateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + StatusOr CreateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + google::cloud::future> + AsyncUpdateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + StatusOr UpdateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + google::cloud::future> + AsyncDeleteUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + StatusOr DeleteUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + google::cloud::future> + AsyncStartServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + StatusOr StartServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + google::cloud::future> + AsyncStopServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr StopServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr ListLocations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + google::cloud::future> + AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + google::cloud::future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + void SetMetadata(rest_internal::RestContext& rest_context, + Options const& options, + std::vector const& params = {}); + + std::shared_ptr child_; + std::string api_client_header_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_METADATA_DECORATOR_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.cc b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.cc new file mode 100644 index 0000000000000..1b3f5fe8be84e --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.cc @@ -0,0 +1,617 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h" +#include "google/cloud/ftp/v1/service.pb.h" +#include "google/cloud/common_options.h" +#include "google/cloud/internal/rest_stub_helpers.h" +#include "google/cloud/status_or.h" +#include "absl/strings/str_cat.h" +#include "google/longrunning/operations.pb.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +DefaultCloudFtpRestStub::DefaultCloudFtpRestStub(Options options) + : service_(rest_internal::MakePooledRestClient( + options.get(), options)), + operations_(rest_internal::MakePooledRestClient( + options.get(), options)), + options_(std::move(options)) {} + +DefaultCloudFtpRestStub::DefaultCloudFtpRestStub( + std::shared_ptr service, + std::shared_ptr operations, Options options) + : service_(std::move(service)), + operations_(std::move(operations)), + options_(std::move(options)) {} + +StatusOr +DefaultCloudFtpRestStub::ListServers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) { + std::vector> query_params; + query_params.push_back({"page_size", std::to_string(request.page_size())}); + query_params.push_back({"page_token", request.page_token()}); + query_params.push_back({"filter", request.filter()}); + query_params.push_back({"order_by", request.order_by()}); + query_params.push_back({"view", std::to_string(request.view())}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.parent(), "/", "servers"), + std::move(query_params)); +} + +StatusOr DefaultCloudFtpRestStub::GetServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) { + std::vector> query_params; + query_params.push_back({"view", std::to_string(request.view())}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncCreateServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + query_params.push_back({"server_id", request.server_id()}); + query_params.push_back({"request_id", request.request_id()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + p.set_value(rest_internal::Post( + *service, *rest_context, request.server(), false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.parent(), "/", "servers"), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::CreateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) { + std::vector> query_params; + query_params.push_back({"server_id", request.server_id()}); + query_params.push_back({"request_id", request.request_id()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Post( + *service_, rest_context, request.server(), false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.parent(), "/", "servers"), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncUpdateServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + query_params.push_back({"request_id", request.request_id()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + p.set_value(rest_internal::Patch( + *service, *rest_context, request.server(), false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.server().name()), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::UpdateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) { + std::vector> query_params; + query_params.push_back({"request_id", request.request_id()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Patch( + *service_, rest_context, request.server(), false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.server().name()), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncDeleteServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + p.set_value(rest_internal::Delete( + *service, *rest_context, request, false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.name()), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::DeleteServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) { + std::vector> query_params; + return rest_internal::Delete( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +StatusOr +DefaultCloudFtpRestStub::ListUsers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) { + std::vector> query_params; + query_params.push_back({"page_size", std::to_string(request.page_size())}); + query_params.push_back({"page_token", request.page_token()}); + query_params.push_back({"filter", request.filter()}); + query_params.push_back({"order_by", request.order_by()}); + query_params.push_back({"view", std::to_string(request.view())}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.parent(), "/", "users"), + std::move(query_params)); +} + +StatusOr DefaultCloudFtpRestStub::GetUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) { + std::vector> query_params; + query_params.push_back({"view", std::to_string(request.view())}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncCreateUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + query_params.push_back({"user_id", request.user_id()}); + query_params.push_back({"request_id", request.request_id()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + p.set_value(rest_internal::Post( + *service, *rest_context, request.user(), false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.parent(), "/", "users"), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::CreateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) { + std::vector> query_params; + query_params.push_back({"user_id", request.user_id()}); + query_params.push_back({"request_id", request.request_id()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Post( + *service_, rest_context, request.user(), false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.parent(), "/", "users"), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncUpdateUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + p.set_value(rest_internal::Patch( + *service, *rest_context, request.user(), false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.user().name()), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::UpdateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) { + std::vector> query_params; + return rest_internal::Patch( + *service_, rest_context, request.user(), false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.user().name()), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncDeleteUser( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + query_params.push_back({"force", (request.force() ? "1" : "0")}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + p.set_value(rest_internal::Delete( + *service, *rest_context, request, false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.name()), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::DeleteUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) { + std::vector> query_params; + query_params.push_back({"force", (request.force() ? "1" : "0")}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Delete( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncStartServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + p.set_value(rest_internal::Post( + *service, *rest_context, request, false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.name(), ":start"), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::StartServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) { + std::vector> query_params; + return rest_internal::Post( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name(), ":start"), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncStopServer( + CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto service, auto request, auto rest_context, auto options) { + std::vector> query_params; + p.set_value(rest_internal::Post( + *service, *rest_context, request, false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.name(), ":stop"), + std::move(query_params))); + }, + std::move(p), + service_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +StatusOr DefaultCloudFtpRestStub::StopServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) { + std::vector> query_params; + return rest_internal::Post( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name(), ":stop"), + std::move(query_params)); +} + +StatusOr +DefaultCloudFtpRestStub::ListLocations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::ListLocationsRequest const& request) { + std::vector> query_params; + query_params.push_back({"filter", request.filter()}); + query_params.push_back({"page_size", std::to_string(request.page_size())}); + query_params.push_back({"page_token", request.page_token()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name(), "/", "locations"), + std::move(query_params)); +} + +StatusOr +DefaultCloudFtpRestStub::GetLocation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::GetLocationRequest const& request) { + std::vector> query_params; + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +StatusOr +DefaultCloudFtpRestStub::ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) { + std::vector> query_params; + query_params.push_back({"filter", request.filter()}); + query_params.push_back({"page_size", std::to_string(request.page_size())}); + query_params.push_back({"page_token", request.page_token()}); + query_params = + rest_internal::TrimEmptyQueryParameters(std::move(query_params)); + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name(), "/", "operations"), + std::move(query_params)); +} + +StatusOr DefaultCloudFtpRestStub::GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) { + std::vector> query_params; + return rest_internal::Get( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +Status DefaultCloudFtpRestStub::DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) { + std::vector> query_params; + return rest_internal::Delete( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name()), + std::move(query_params)); +} + +Status DefaultCloudFtpRestStub::CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) { + std::vector> query_params; + return rest_internal::Post( + *service_, rest_context, request, false, + absl::StrCat("/", rest_internal::DetermineApiVersion("v1", options), "/", + request.name(), ":cancel"), + std::move(query_params)); +} + +future> +DefaultCloudFtpRestStub::AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto operations, auto request, auto rest_context, + auto options) { + p.set_value(rest_internal::Get( + *operations, *rest_context, request, false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.name()))); + }, + std::move(p), + operations_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get(); + }); +} + +future DefaultCloudFtpRestStub::AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) { + promise> p; + future> f = p.get_future(); + std::thread t{ + [](auto p, auto operations, auto request, auto rest_context, + auto options) { + p.set_value(rest_internal::Post( + *operations, *rest_context, request, false, + absl::StrCat("/", + rest_internal::DetermineApiVersion("v1", *options), + "/", request.name(), ":cancel"))); + }, + std::move(p), + operations_, + request, + std::move(rest_context), + std::move(options)}; + return f.then([t = std::move(t), cq](auto f) mutable { + cq.RunAsync([t = std::move(t)]() mutable { t.join(); }); + return f.get().status(); + }); +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h new file mode 100644 index 0000000000000..b0ca39a41cde8 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h @@ -0,0 +1,363 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_STUB_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_STUB_H + +#include "google/cloud/ftp/v1/service.pb.h" +#include "google/cloud/location/locations.pb.h" +#include "google/cloud/completion_queue.h" +#include "google/cloud/internal/rest_client.h" +#include "google/cloud/internal/rest_context.h" +#include "google/cloud/status_or.h" +#include "google/cloud/version.h" +#include "google/longrunning/operations.pb.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class CloudFtpRestStub { + public: + virtual ~CloudFtpRestStub() = default; + + virtual StatusOr ListServers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) = 0; + + virtual StatusOr GetServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) = 0; + + virtual future> AsyncCreateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) = 0; + + virtual StatusOr CreateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) = 0; + + virtual future> AsyncUpdateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) = 0; + + virtual StatusOr UpdateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) = 0; + + virtual future> AsyncDeleteServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) = 0; + + virtual StatusOr DeleteServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) = 0; + + virtual StatusOr ListUsers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) = 0; + + virtual StatusOr GetUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) = 0; + + virtual future> AsyncCreateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) = 0; + + virtual StatusOr CreateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) = 0; + + virtual future> AsyncUpdateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) = 0; + + virtual StatusOr UpdateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) = 0; + + virtual future> AsyncDeleteUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) = 0; + + virtual StatusOr DeleteUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) = 0; + + virtual future> AsyncStartServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) = 0; + + virtual StatusOr StartServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) = 0; + + virtual future> AsyncStopServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) = 0; + + virtual StatusOr StopServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) = 0; + + virtual StatusOr + ListLocations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::ListLocationsRequest const& request) = 0; + + virtual StatusOr GetLocation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::GetLocationRequest const& request) = 0; + + virtual StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) = 0; + + virtual StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) = 0; + + virtual Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) = 0; + + virtual future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) = 0; + + virtual future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) = 0; +}; + +class DefaultCloudFtpRestStub : public CloudFtpRestStub { + public: + ~DefaultCloudFtpRestStub() override = default; + + explicit DefaultCloudFtpRestStub(Options options); + DefaultCloudFtpRestStub(std::shared_ptr service, + std::shared_ptr operations, + Options options); + + StatusOr ListServers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListServersRequest const& request) override; + + StatusOr GetServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetServerRequest const& request) override; + + future> AsyncCreateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + StatusOr CreateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + future> AsyncUpdateServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + StatusOr UpdateServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + future> AsyncDeleteServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr DeleteServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr ListUsers( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::ListUsersRequest const& request) override; + + StatusOr GetUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::GetUserRequest const& request) override; + + future> AsyncCreateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + StatusOr CreateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + future> AsyncUpdateUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + StatusOr UpdateUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + future> AsyncDeleteUser( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + StatusOr DeleteUser( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + future> AsyncStartServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + StatusOr StartServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + future> AsyncStopServer( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr StopServer( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr ListLocations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::ListLocationsRequest const& request) override; + + StatusOr GetLocation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::cloud::location::GetLocationRequest const& request) override; + + StatusOr ListOperations( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::ListOperationsRequest const& request) override; + + StatusOr GetOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::cloud::rest_internal::RestContext& rest_context, + Options const& options, + google::longrunning::CancelOperationRequest const& request) override; + + future> AsyncGetOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::GetOperationRequest const& request) override; + + future AsyncCancelOperation( + google::cloud::CompletionQueue& cq, + std::unique_ptr rest_context, + google::cloud::internal::ImmutableOptions options, + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr service_; + std::shared_ptr operations_; + Options options_; +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_STUB_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.cc b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.cc new file mode 100644 index 0000000000000..8d0077c72007c --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.cc @@ -0,0 +1,56 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.h" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h" +#include "google/cloud/common_options.h" +#include "google/cloud/internal/algorithm.h" +#include "google/cloud/internal/populate_rest_options.h" +#include "google/cloud/log.h" +#include "google/cloud/options.h" +#include "google/cloud/rest_options.h" +#include "absl/strings/match.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultCloudFtpRestStub( + Options const& options) { + auto opts = internal::PopulateRestOptions(options); + std::shared_ptr stub = + std::make_shared(std::move(opts)); + stub = std::make_shared(std::move(stub)); + if (internal::Contains(options.get(), "rpc")) { + GCP_LOG(INFO) << "Enabled logging for REST rpc calls"; + stub = std::make_shared( + std::move(stub), options.get(), + options.get()); + } + return stub; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.h b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.h new file mode 100644 index 0000000000000..bc90b986df5f3 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.h @@ -0,0 +1,40 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_STUB_FACTORY_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_STUB_FACTORY_H + +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.h" +#include "google/cloud/options.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +std::shared_ptr CreateDefaultCloudFtpRestStub( + Options const& options); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_REST_STUB_FACTORY_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_retry_traits.h b/google/cloud/ftp/v1/internal/cloud_ftp_retry_traits.h new file mode 100644 index 0000000000000..9729eec7399e8 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_retry_traits.h @@ -0,0 +1,43 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_RETRY_TRAITS_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_RETRY_TRAITS_H + +#include "google/cloud/status.h" +#include "google/cloud/version.h" + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/// Define the gRPC status code semantics for retrying requests. +struct CloudFtpRetryTraits { + static bool IsPermanentFailure(google::cloud::Status const& status) { + return status.code() != StatusCode::kOk && + status.code() != StatusCode::kUnavailable; + } +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_RETRY_TRAITS_H diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_sources.cc b/google/cloud/ftp/v1/internal/cloud_ftp_sources.cc new file mode 100644 index 0000000000000..c9441db23bae8 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_sources.cc @@ -0,0 +1,31 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +// NOLINTBEGIN(bugprone-suspicious-include) +#include "google/cloud/ftp/v1/cloud_ftp_client.cc" +#include "google/cloud/ftp/v1/cloud_ftp_connection.cc" +#include "google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.cc" +#include "google/cloud/ftp/v1/cloud_ftp_rest_connection.cc" +#include "google/cloud/ftp/v1/internal/cloud_ftp_option_defaults.cc" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_connection_impl.cc" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_logging_decorator.cc" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_metadata_decorator.cc" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub.cc" +#include "google/cloud/ftp/v1/internal/cloud_ftp_rest_stub_factory.cc" +#include "google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.cc" +// NOLINTEND(bugprone-suspicious-include) diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.cc b/google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.cc new file mode 100644 index 0000000000000..4b679a48170d1 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.cc @@ -0,0 +1,315 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.h" +#include "google/cloud/internal/opentelemetry.h" +#include "google/cloud/internal/traced_stream_range.h" +#include +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +CloudFtpTracingConnection::CloudFtpTracingConnection( + std::shared_ptr child) + : child_(std::move(child)) {} + +StreamRange +CloudFtpTracingConnection::ListServers( + google::cloud::ftp::v1::ListServersRequest request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::ListServers"); + internal::OTelScope scope(span); + auto sr = child_->ListServers(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr CloudFtpTracingConnection::GetServer( + google::cloud::ftp::v1::GetServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::GetServer"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetServer(request)); +} + +future> +CloudFtpTracingConnection::CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::CreateServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateServer(request)); +} + +StatusOr +CloudFtpTracingConnection::CreateServer( + NoAwaitTag, google::cloud::ftp::v1::CreateServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::CreateServer"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->CreateServer(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::CreateServer( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::CreateServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateServer(operation)); +} + +future> +CloudFtpTracingConnection::UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::UpdateServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->UpdateServer(request)); +} + +StatusOr +CloudFtpTracingConnection::UpdateServer( + NoAwaitTag, google::cloud::ftp::v1::UpdateServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::UpdateServer"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->UpdateServer(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::UpdateServer( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::UpdateServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->UpdateServer(operation)); +} + +future> +CloudFtpTracingConnection::DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::DeleteServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteServer(request)); +} + +StatusOr +CloudFtpTracingConnection::DeleteServer( + NoAwaitTag, google::cloud::ftp::v1::DeleteServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::DeleteServer"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->DeleteServer(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::DeleteServer( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::DeleteServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteServer(operation)); +} + +StreamRange CloudFtpTracingConnection::ListUsers( + google::cloud::ftp::v1::ListUsersRequest request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::ListUsers"); + internal::OTelScope scope(span); + auto sr = child_->ListUsers(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr CloudFtpTracingConnection::GetUser( + google::cloud::ftp::v1::GetUserRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::GetUser"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetUser(request)); +} + +future> +CloudFtpTracingConnection::CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::CreateUser"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateUser(request)); +} + +StatusOr CloudFtpTracingConnection::CreateUser( + NoAwaitTag, google::cloud::ftp::v1::CreateUserRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::CreateUser"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->CreateUser(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::CreateUser( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::CreateUser"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->CreateUser(operation)); +} + +future> +CloudFtpTracingConnection::UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::UpdateUser"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->UpdateUser(request)); +} + +StatusOr CloudFtpTracingConnection::UpdateUser( + NoAwaitTag, google::cloud::ftp::v1::UpdateUserRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::UpdateUser"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->UpdateUser(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::UpdateUser( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::UpdateUser"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->UpdateUser(operation)); +} + +future> +CloudFtpTracingConnection::DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::DeleteUser"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteUser(request)); +} + +StatusOr CloudFtpTracingConnection::DeleteUser( + NoAwaitTag, google::cloud::ftp::v1::DeleteUserRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::DeleteUser"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->DeleteUser(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::DeleteUser( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::DeleteUser"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->DeleteUser(operation)); +} + +future> +CloudFtpTracingConnection::StartServer( + google::cloud::ftp::v1::StartServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::StartServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->StartServer(request)); +} + +StatusOr CloudFtpTracingConnection::StartServer( + NoAwaitTag, google::cloud::ftp::v1::StartServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::StartServer"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->StartServer(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::StartServer( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::StartServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->StartServer(operation)); +} + +future> +CloudFtpTracingConnection::StopServer( + google::cloud::ftp::v1::StopServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::StopServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->StopServer(request)); +} + +StatusOr CloudFtpTracingConnection::StopServer( + NoAwaitTag, google::cloud::ftp::v1::StopServerRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::StopServer"); + opentelemetry::trace::Scope scope(span); + return internal::EndSpan(*span, child_->StopServer(NoAwaitTag{}, request)); +} + +future> +CloudFtpTracingConnection::StopServer( + google::longrunning::Operation const& operation) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::StopServer"); + internal::OTelScope scope(span); + return internal::EndSpan(std::move(span), child_->StopServer(operation)); +} + +StreamRange +CloudFtpTracingConnection::ListLocations( + google::cloud::location::ListLocationsRequest request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::ListLocations"); + internal::OTelScope scope(span); + auto sr = child_->ListLocations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudFtpTracingConnection::GetLocation( + google::cloud::location::GetLocationRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::GetLocation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetLocation(request)); +} + +StreamRange +CloudFtpTracingConnection::ListOperations( + google::longrunning::ListOperationsRequest request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::ListOperations"); + internal::OTelScope scope(span); + auto sr = child_->ListOperations(std::move(request)); + return internal::MakeTracedStreamRange( + std::move(span), std::move(sr)); +} + +StatusOr +CloudFtpTracingConnection::GetOperation( + google::longrunning::GetOperationRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::GetOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->GetOperation(request)); +} + +Status CloudFtpTracingConnection::DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::DeleteOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->DeleteOperation(request)); +} + +Status CloudFtpTracingConnection::CancelOperation( + google::longrunning::CancelOperationRequest const& request) { + auto span = internal::MakeSpan("ftp_v1::CloudFtpConnection::CancelOperation"); + auto scope = opentelemetry::trace::Scope(span); + return internal::EndSpan(*span, child_->CancelOperation(request)); +} + +std::shared_ptr MakeCloudFtpTracingConnection( + std::shared_ptr conn) { + if (internal::TracingEnabled(conn->options())) { + conn = std::make_shared(std::move(conn)); + } + return conn; +} + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google diff --git a/google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.h b/google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.h new file mode 100644 index 0000000000000..95fe0c30d0319 --- /dev/null +++ b/google/cloud/ftp/v1/internal/cloud_ftp_tracing_connection.h @@ -0,0 +1,168 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_TRACING_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_TRACING_CONNECTION_H + +#include "google/cloud/ftp/v1/cloud_ftp_connection.h" +#include "google/cloud/version.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1_internal { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +class CloudFtpTracingConnection : public ftp_v1::CloudFtpConnection { + public: + ~CloudFtpTracingConnection() override = default; + + explicit CloudFtpTracingConnection( + std::shared_ptr child); + + Options options() override { return child_->options(); } + + StreamRange ListServers( + google::cloud::ftp::v1::ListServersRequest request) override; + + StatusOr GetServer( + google::cloud::ftp::v1::GetServerRequest const& request) override; + + future> CreateServer( + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + StatusOr CreateServer( + NoAwaitTag, + google::cloud::ftp::v1::CreateServerRequest const& request) override; + + future> CreateServer( + google::longrunning::Operation const& operation) override; + + future> UpdateServer( + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + StatusOr UpdateServer( + NoAwaitTag, + google::cloud::ftp::v1::UpdateServerRequest const& request) override; + + future> UpdateServer( + google::longrunning::Operation const& operation) override; + + future> DeleteServer( + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + StatusOr DeleteServer( + NoAwaitTag, + google::cloud::ftp::v1::DeleteServerRequest const& request) override; + + future> DeleteServer( + google::longrunning::Operation const& operation) override; + + StreamRange ListUsers( + google::cloud::ftp::v1::ListUsersRequest request) override; + + StatusOr GetUser( + google::cloud::ftp::v1::GetUserRequest const& request) override; + + future> CreateUser( + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + StatusOr CreateUser( + NoAwaitTag, + google::cloud::ftp::v1::CreateUserRequest const& request) override; + + future> CreateUser( + google::longrunning::Operation const& operation) override; + + future> UpdateUser( + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + StatusOr UpdateUser( + NoAwaitTag, + google::cloud::ftp::v1::UpdateUserRequest const& request) override; + + future> UpdateUser( + google::longrunning::Operation const& operation) override; + + future> DeleteUser( + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + StatusOr DeleteUser( + NoAwaitTag, + google::cloud::ftp::v1::DeleteUserRequest const& request) override; + + future> DeleteUser( + google::longrunning::Operation const& operation) override; + + future> StartServer( + google::cloud::ftp::v1::StartServerRequest const& request) override; + + StatusOr StartServer( + NoAwaitTag, + google::cloud::ftp::v1::StartServerRequest const& request) override; + + future> StartServer( + google::longrunning::Operation const& operation) override; + + future> StopServer( + google::cloud::ftp::v1::StopServerRequest const& request) override; + + StatusOr StopServer( + NoAwaitTag, + google::cloud::ftp::v1::StopServerRequest const& request) override; + + future> StopServer( + google::longrunning::Operation const& operation) override; + + StreamRange ListLocations( + google::cloud::location::ListLocationsRequest request) override; + + StatusOr GetLocation( + google::cloud::location::GetLocationRequest const& request) override; + + StreamRange ListOperations( + google::longrunning::ListOperationsRequest request) override; + + StatusOr GetOperation( + google::longrunning::GetOperationRequest const& request) override; + + Status DeleteOperation( + google::longrunning::DeleteOperationRequest const& request) override; + + Status CancelOperation( + google::longrunning::CancelOperationRequest const& request) override; + + private: + std::shared_ptr child_; +}; + +/** + * Conditionally applies the tracing decorator to the given connection. + * + * The connection is only decorated if tracing is enabled (as determined by the + * connection's options). + */ +std::shared_ptr MakeCloudFtpTracingConnection( + std::shared_ptr conn); + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_internal +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_INTERNAL_CLOUD_FTP_TRACING_CONNECTION_H diff --git a/google/cloud/ftp/v1/mocks/mock_cloud_ftp_connection.h b/google/cloud/ftp/v1/mocks/mock_cloud_ftp_connection.h new file mode 100644 index 0000000000000..5d774eb7a34ed --- /dev/null +++ b/google/cloud/ftp/v1/mocks/mock_cloud_ftp_connection.h @@ -0,0 +1,372 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_MOCKS_MOCK_CLOUD_FTP_CONNECTION_H +#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_MOCKS_MOCK_CLOUD_FTP_CONNECTION_H + +#include "google/cloud/ftp/v1/cloud_ftp_connection.h" +#include + +namespace google { +namespace cloud { +namespace ftp_v1_mocks { +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN + +/** + * A class to mock `CloudFtpConnection`. + * + * Application developers may want to test their code with simulated responses, + * including errors, from an object of type `CloudFtpClient`. To do so, + * construct an object of type `CloudFtpClient` 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]: @cloud_cpp_docs_link{bigquery,bigquery-read-mock} + */ +class MockCloudFtpConnection : public ftp_v1::CloudFtpConnection { + public: + MOCK_METHOD(Options, options, (), (override)); + + MOCK_METHOD((StreamRange), ListServers, + (google::cloud::ftp::v1::ListServersRequest request), (override)); + + MOCK_METHOD(StatusOr, GetServer, + (google::cloud::ftp::v1::GetServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreateServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, CreateServer, + (google::cloud::ftp::v1::CreateServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreateServer(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, CreateServer, + (NoAwaitTag, + google::cloud::ftp::v1::CreateServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, CreateServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, CreateServer, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdateServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, UpdateServer, + (google::cloud::ftp::v1::UpdateServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, UpdateServer(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, UpdateServer, + (NoAwaitTag, + google::cloud::ftp::v1::UpdateServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, UpdateServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, UpdateServer, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeleteServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeleteServer, + (google::cloud::ftp::v1::DeleteServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeleteServer(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, DeleteServer, + (NoAwaitTag, + google::cloud::ftp::v1::DeleteServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, DeleteServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeleteServer, (google::longrunning::Operation const& operation), + (override)); + + MOCK_METHOD((StreamRange), ListUsers, + (google::cloud::ftp::v1::ListUsersRequest request), (override)); + + MOCK_METHOD(StatusOr, GetUser, + (google::cloud::ftp::v1::GetUserRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// CreateUser(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, CreateUser, + (google::cloud::ftp::v1::CreateUserRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, CreateUser(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, CreateUser, + (NoAwaitTag, + google::cloud::ftp::v1::CreateUserRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, CreateUser(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, CreateUser, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// UpdateUser(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, UpdateUser, + (google::cloud::ftp::v1::UpdateUserRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, UpdateUser(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, UpdateUser, + (NoAwaitTag, + google::cloud::ftp::v1::UpdateUserRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, UpdateUser(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, UpdateUser, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// DeleteUser(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeleteUser, + (google::cloud::ftp::v1::DeleteUserRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, DeleteUser(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, DeleteUser, + (NoAwaitTag, + google::cloud::ftp::v1::DeleteUserRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, DeleteUser(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, + DeleteUser, (google::longrunning::Operation const& operation), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// StartServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, StartServer, + (google::cloud::ftp::v1::StartServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, StartServer(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, StartServer, + (NoAwaitTag, + google::cloud::ftp::v1::StartServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, StartServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, StartServer, + (google::longrunning::Operation const& operation), (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, + /// StopServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, StopServer, + (google::cloud::ftp::v1::StopServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// EXPECT_CALL(*mock, StopServer(_, _)) + /// @endcode + MOCK_METHOD(StatusOr, StopServer, + (NoAwaitTag, + google::cloud::ftp::v1::StopServerRequest const& request), + (override)); + + /// To disambiguate calls, use: + /// + /// @code + /// using ::testing::_; + /// using ::testing::Matcher; + /// EXPECT_CALL(*mock, StopServer(Matcher(_))) + /// @endcode + MOCK_METHOD(future>, StopServer, + (google::longrunning::Operation const& operation), (override)); + + MOCK_METHOD((StreamRange), ListLocations, + (google::cloud::location::ListLocationsRequest request), + (override)); + + MOCK_METHOD(StatusOr, GetLocation, + (google::cloud::location::GetLocationRequest const& request), + (override)); + + MOCK_METHOD((StreamRange), ListOperations, + (google::longrunning::ListOperationsRequest request), (override)); + + MOCK_METHOD(StatusOr, GetOperation, + (google::longrunning::GetOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, DeleteOperation, + (google::longrunning::DeleteOperationRequest const& request), + (override)); + + MOCK_METHOD(Status, CancelOperation, + (google::longrunning::CancelOperationRequest const& request), + (override)); +}; + +GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END +} // namespace ftp_v1_mocks +} // namespace cloud +} // namespace google + +#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_FTP_V1_MOCKS_MOCK_CLOUD_FTP_CONNECTION_H diff --git a/google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc b/google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc new file mode 100644 index 0000000000000..8d83e5d340f67 --- /dev/null +++ b/google/cloud/ftp/v1/samples/cloud_ftp_client_samples.cc @@ -0,0 +1,218 @@ +// Copyright 2026 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/cloud/ftp/v1/service.proto + +#include "google/cloud/ftp/v1/cloud_ftp_client.h" +#include "google/cloud/ftp/v1/cloud_ftp_connection_idempotency_policy.h" +#include "google/cloud/ftp/v1/cloud_ftp_options.h" +#include "google/cloud/common_options.h" +#include "google/cloud/credentials.h" +#include "google/cloud/internal/getenv.h" +#include "google/cloud/polling_policy.h" +#include "google/cloud/testing_util/example_driver.h" +#include "google/cloud/universe_domain.h" +#include +#include +#include +#include + +// clang-format off +// main-dox-marker: ftp_v1::CloudFtpClient +// lro-marker: true +// clang-format on +namespace { + +void SetClientEndpoint(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-endpoint"}; + } + //! [set-client-endpoint] + // This configuration is common with Private Google Access: + // https://cloud.google.com/vpc/docs/private-google-access + auto options = google::cloud::Options{}.set( + "private.googleapis.com"); + auto vpc_client = google::cloud::ftp_v1::CloudFtpClient( + google::cloud::ftp_v1::MakeCloudFtpConnectionRest(options)); + //! [set-client-endpoint] +} + +void SetClientUniverseDomain(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-universe-domain"}; + } + //! [set-client-universe-domain] + google::cloud::Options options; + + // AddUniverseDomainOption interrogates the UnifiedCredentialsOption, if set, + // in the provided Options for the Universe Domain associated with the + // credentials and adds it to the set of Options. + // If no UnifiedCredentialsOption is set, GoogleDefaultCredentials are used. + auto ud_options = google::cloud::AddUniverseDomainOption(std::move(options)); + + if (!ud_options.ok()) throw std::move(ud_options).status(); + auto ud_client = google::cloud::ftp_v1::CloudFtpClient( + google::cloud::ftp_v1::MakeCloudFtpConnectionRest(*ud_options)); + //! [set-client-universe-domain] +} + +//! [custom-idempotency-policy] +class CustomIdempotencyPolicy + : public google::cloud::ftp_v1::CloudFtpConnectionIdempotencyPolicy { + public: + ~CustomIdempotencyPolicy() override = default; + std::unique_ptr + clone() const override { + return std::make_unique(*this); + } + // Override inherited functions to define as needed. +}; +//! [custom-idempotency-policy] + +void SetRetryPolicy(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-retry-policy"}; + } + //! [set-retry-policy] + auto options = + google::cloud::Options{} + .set< + google::cloud::ftp_v1::CloudFtpConnectionIdempotencyPolicyOption>( + CustomIdempotencyPolicy().clone()) + .set( + google::cloud::ftp_v1::CloudFtpLimitedErrorCountRetryPolicy(3) + .clone()) + .set( + google::cloud::ExponentialBackoffPolicy( + /*initial_delay=*/std::chrono::milliseconds(200), + /*maximum_delay=*/std::chrono::seconds(45), + /*scaling=*/2.0) + .clone()); + auto connection = google::cloud::ftp_v1::MakeCloudFtpConnectionRest(options); + + // c1 and c2 share the same retry policies + auto c1 = google::cloud::ftp_v1::CloudFtpClient(connection); + auto c2 = google::cloud::ftp_v1::CloudFtpClient(connection); + + // You can override any of the policies in a new client. This new client + // will share the policies from c1 (or c2) *except* for the retry policy. + auto c3 = google::cloud::ftp_v1::CloudFtpClient( + connection, google::cloud::Options{} + .set( + google::cloud::ftp_v1::CloudFtpLimitedTimeRetryPolicy( + std::chrono::minutes(5)) + .clone())); + + // You can also override the policies in a single call: + // c3.SomeRpc(..., google::cloud::Options{} + // .set( + // google::cloud::ftp_v1::CloudFtpLimitedErrorCountRetryPolicy(10).clone())); + //! [set-retry-policy] +} + +void SetPollingPolicy(std::vector const& argv) { + if (!argv.empty()) { + throw google::cloud::testing_util::Usage{"set-client-policy-policy"}; + } + //! [set-polling-policy] + + // The polling policy controls how the client waits for long-running + // operations. `GenericPollingPolicy<>` combines existing policies. + // In this case, keep polling until the operation completes (with success + // or error) or 45 minutes, whichever happens first. Initially pause for + // 10 seconds between polling requests, increasing the pause by a factor + // of 4 until it becomes 2 minutes. + auto options = + google::cloud::Options{} + .set( + google::cloud::GenericPollingPolicy< + google::cloud::ftp_v1::CloudFtpRetryPolicyOption::Type, + google::cloud::ftp_v1::CloudFtpBackoffPolicyOption::Type>( + google::cloud::ftp_v1::CloudFtpLimitedTimeRetryPolicy( + /*maximum_duration=*/std::chrono::minutes(45)) + .clone(), + google::cloud::ExponentialBackoffPolicy( + /*initial_delay=*/std::chrono::seconds(10), + /*maximum_delay=*/std::chrono::minutes(2), + /*scaling=*/4.0) + .clone()) + .clone()); + + auto connection = google::cloud::ftp_v1::MakeCloudFtpConnectionRest(options); + + // c1 and c2 share the same polling policies. + auto c1 = google::cloud::ftp_v1::CloudFtpClient(connection); + auto c2 = google::cloud::ftp_v1::CloudFtpClient(connection); + //! [set-polling-policy] +} + +void WithServiceAccount(std::vector const& argv) { + if (argv.size() != 1 || argv[0] == "--help") { + throw google::cloud::testing_util::Usage{"with-service-account "}; + } + //! [with-service-account] + [](std::string const& keyfile) { + auto is = std::ifstream(keyfile); + is.exceptions(std::ios::badbit); // Minimal error handling in examples + auto contents = std::string(std::istreambuf_iterator(is.rdbuf()), {}); + auto options = + google::cloud::Options{}.set( + google::cloud::MakeServiceAccountCredentials(contents)); + return google::cloud::ftp_v1::CloudFtpClient( + google::cloud::ftp_v1::MakeCloudFtpConnectionRest(options)); + } + //! [with-service-account] + (argv.at(0)); +} + +void AutoRun(std::vector const& argv) { + namespace examples = ::google::cloud::testing_util; + using ::google::cloud::internal::GetEnv; + if (!argv.empty()) throw examples::Usage{"auto"}; + examples::CheckEnvironmentVariablesAreSet( + {"GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE"}); + auto const keyfile = + GetEnv("GOOGLE_CLOUD_CPP_TEST_SERVICE_ACCOUNT_KEYFILE").value(); + + std::cout << "\nRunning SetClientEndpoint() example" << std::endl; + SetClientEndpoint({}); + + std::cout << "\nRunning SetRetryPolicy() example" << std::endl; + SetRetryPolicy({}); + + std::cout << "\nRunning SetPollingPolicy() example" << std::endl; + SetPollingPolicy({}); + + std::cout << "\nRunning WithServiceAccount() example" << std::endl; + WithServiceAccount({keyfile}); + + std::cout << "\nRunning SetClientUniverseDomain() example" << std::endl; + SetClientUniverseDomain({}); +} + +} // namespace + +int main(int argc, char* argv[]) { // NOLINT(bugprone-exception-escape) + google::cloud::testing_util::Example example({ + {"set-client-endpoint", SetClientEndpoint}, + {"set-retry-policy", SetRetryPolicy}, + {"set-polling-policy", SetPollingPolicy}, + {"with-service-account", WithServiceAccount}, + {"set-client-universe-domain", SetClientUniverseDomain}, + {"auto", AutoRun}, + }); + return example.Run(argc, argv); +} diff --git a/libraries.bzl b/libraries.bzl index c25f8adee6e7d..11d5f63548028 100644 --- a/libraries.bzl +++ b/libraries.bzl @@ -169,6 +169,7 @@ GOOGLE_CLOUD_CPP_GA_LIBRARIES = [ "eventarc", "filestore", "financialservices", + "ftp", "functions", "geminidataanalytics", "gkebackup",