Skip to content

Commit 5d9c54a

Browse files
authored
impl(rest): add user facing RestOptions (googleapis#10240)
1 parent ba4669e commit 5d9c54a

8 files changed

Lines changed: 76 additions & 17 deletions

google/cloud/google_cloud_cpp_rest_internal.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ google_cloud_cpp_rest_internal_hdrs = [
4949
"internal/rest_request.h",
5050
"internal/rest_response.h",
5151
"internal/unified_rest_credentials.h",
52+
"rest_options.h",
5253
]
5354

5455
google_cloud_cpp_rest_internal_srcs = [

google/cloud/google_cloud_cpp_rest_internal.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ add_library(
7979
internal/rest_response.cc
8080
internal/rest_response.h
8181
internal/unified_rest_credentials.cc
82-
internal/unified_rest_credentials.h)
82+
internal/unified_rest_credentials.h
83+
rest_options.h)
8384
target_link_libraries(
8485
google_cloud_cpp_rest_internal
8586
PUBLIC absl::span google-cloud-cpp::common CURL::libcurl

google/cloud/internal/curl_rest_client.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "google/cloud/internal/curl_options.h"
2424
#include "google/cloud/internal/curl_rest_response.h"
2525
#include "google/cloud/internal/oauth2_google_credentials.h"
26-
#include "google/cloud/internal/rest_options.h"
2726
#include "google/cloud/internal/unified_rest_credentials.h"
2827
#include "absl/strings/match.h"
2928
#include "absl/strings/strip.h"

google/cloud/internal/curl_rest_client.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "google/cloud/internal/oauth2_credentials.h"
1919
#include "google/cloud/internal/rest_client.h"
20-
#include "google/cloud/internal/rest_options.h"
2120
#include "google/cloud/internal/rest_request.h"
2221
#include "google/cloud/internal/rest_response.h"
2322
#include "google/cloud/options.h"

google/cloud/internal/oauth2_minimal_iam_credentials_rest.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "google/cloud/internal/oauth2_credentials.h"
2222
#include "google/cloud/internal/parse_rfc3339.h"
2323
#include "google/cloud/internal/rest_client.h"
24-
#include "google/cloud/internal/rest_options.h"
2524
#include "google/cloud/internal/rest_response.h"
2625
#include "google/cloud/log.h"
2726
#include "google/cloud/options.h"

google/cloud/internal/rest_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "google/cloud/internal/rest_request.h"
2020
#include "google/cloud/internal/rest_response.h"
2121
#include "google/cloud/options.h"
22+
#include "google/cloud/rest_options.h"
2223
#include "google/cloud/status_or.h"
2324
#include "google/cloud/version.h"
2425
#include <string>

google/cloud/internal/rest_options.h

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ namespace cloud {
2727
namespace rest_internal {
2828
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2929

30-
/**
31-
* Configure the UserIp query parameter.
32-
*
33-
* This can be used to separate quota usage by source IP address.
34-
*
35-
* @deprecated prefer using `google::cloud::QuotaUser`.
36-
*/
37-
struct UserIpOption {
38-
using Type = std::string;
39-
};
40-
4130
/**
4231
* Sets the transfer stall timeout.
4332
*
@@ -96,8 +85,8 @@ struct DownloadStallMinimumRateOption {
9685
};
9786

9887
/// The complete list of options accepted by `CurlRestClient`
99-
using RestOptionList = ::google::cloud::OptionList<
100-
UserIpOption, TransferStallTimeoutOption, TransferStallMinimumRateOption,
88+
using RestInternalOptionList = ::google::cloud::OptionList<
89+
TransferStallTimeoutOption, TransferStallMinimumRateOption,
10190
DownloadStallTimeoutOption, DownloadStallMinimumRateOption>;
10291

10392
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

google/cloud/rest_options.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_REST_OPTIONS_H
16+
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_REST_OPTIONS_H
17+
18+
#include "google/cloud/options.h"
19+
#include "google/cloud/version.h"
20+
#include <chrono>
21+
#include <cstdint>
22+
#include <memory>
23+
#include <string>
24+
25+
namespace google {
26+
namespace cloud {
27+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
28+
29+
/**
30+
* Configure the QuotaUser system parameter.
31+
*
32+
* A pseudo user identifier for charging per-user quotas. If not specified, the
33+
* authenticated principal is used. If there is no authenticated principal, the
34+
* client IP address will be used. When specified, a valid API key with service
35+
* restrictions must be used to identify the quota project. Otherwise, this
36+
* parameter is ignored.
37+
*/
38+
struct QuotaUser {
39+
using Type = std::string;
40+
};
41+
42+
/**
43+
* Configure the UserIp query parameter.
44+
*
45+
* This can be used to separate quota usage by source IP address.
46+
*
47+
* @deprecated prefer using `google::cloud::QuotaUser`.
48+
*/
49+
struct UserIpOption {
50+
using Type = std::string;
51+
};
52+
53+
/**
54+
* Timeout (in seconds) for the server to finish processing the request. This
55+
* system param only applies to REST APIs for which client-side timeout is not
56+
* applicable.
57+
*/
58+
struct ServerTimeout {
59+
using Type = float;
60+
};
61+
62+
/// The complete list of options accepted by `CurlRestClient`
63+
using RestOptionList =
64+
::google::cloud::OptionList<QuotaUser, ServerTimeout, UserIpOption>;
65+
66+
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
67+
} // namespace cloud
68+
} // namespace google
69+
70+
#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_REST_OPTIONS_H

0 commit comments

Comments
 (0)