Google Cloud Storage C++ Client  1.24.0
A C++ Client Library for Google Cloud Storage
client_options.h
Go to the documentation of this file.
1 // Copyright 2018 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 // http://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_STORAGE_CLIENT_OPTIONS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_CLIENT_OPTIONS_H
17 
20 #include <memory>
21 
22 namespace google {
23 namespace cloud {
24 namespace storage {
25 inline namespace STORAGE_CLIENT_NS {
26 class ClientOptions;
27 namespace internal {
28 std::string JsonEndpoint(ClientOptions const&);
29 std::string JsonUploadEndpoint(ClientOptions const&);
30 std::string XmlEndpoint(ClientOptions const&);
31 std::string IamEndpoint(ClientOptions const&);
32 } // namespace internal
33 
46  public:
47  std::string ssl_root_path() const { return ssl_root_path_; }
48 
49  ChannelOptions& set_ssl_root_path(std::string ssl_root_path) {
50  ssl_root_path_ = std::move(ssl_root_path);
51  return *this;
52  }
53 
54  private:
55  std::string ssl_root_path_;
56 };
57 
75  public:
76  explicit ClientOptions(std::shared_ptr<oauth2::Credentials> credentials)
77  : ClientOptions(std::move(credentials), {}) {}
78  ClientOptions(std::shared_ptr<oauth2::Credentials> credentials,
79  ChannelOptions channel_options);
80 
89  static StatusOr<ClientOptions> CreateDefaultClientOptions();
90  static StatusOr<ClientOptions> CreateDefaultClientOptions(
91  ChannelOptions const& channel_options);
92 
93  std::shared_ptr<oauth2::Credentials> credentials() const {
94  return credentials_;
95  }
97  std::shared_ptr<oauth2::Credentials> credentials) {
98  credentials_ = std::move(credentials);
99  return *this;
100  }
101 
102  std::string const& endpoint() const { return endpoint_; }
103  ClientOptions& set_endpoint(std::string endpoint) {
104  endpoint_ = std::move(endpoint);
105  return *this;
106  }
107 
108  std::string const& iam_endpoint() const { return iam_endpoint_; }
109  ClientOptions& set_iam_endpoint(std::string endpoint) {
110  iam_endpoint_ = std::move(endpoint);
111  return *this;
112  }
113 
114  std::string const& version() const { return version_; }
116  version_ = std::move(version);
117  return *this;
118  }
119 
120  bool enable_http_tracing() const { return enable_http_tracing_; }
122  enable_http_tracing_ = enable;
123  return *this;
124  }
125 
126  bool enable_raw_client_tracing() const { return enable_raw_client_tracing_; }
128  enable_raw_client_tracing_ = enable;
129  return *this;
130  }
131 
132  std::string const& project_id() const { return project_id_; }
133  ClientOptions& set_project_id(std::string v) {
134  project_id_ = std::move(v);
135  return *this;
136  }
137 
138  std::size_t connection_pool_size() const { return connection_pool_size_; }
140  connection_pool_size_ = size;
141  return *this;
142  }
143 
144  std::size_t download_buffer_size() const { return download_buffer_size_; }
145  ClientOptions& SetDownloadBufferSize(std::size_t size);
146 
147  std::size_t upload_buffer_size() const { return upload_buffer_size_; }
148  ClientOptions& SetUploadBufferSize(std::size_t size);
149 
150  std::string const& user_agent_prefix() const { return user_agent_prefix_; }
151  ClientOptions& add_user_agent_prefix(std::string prefix) {
152  if (!user_agent_prefix_.empty()) {
153  prefix += '/';
154  prefix += user_agent_prefix_;
155  }
156  user_agent_prefix_ = std::move(prefix);
157  return *this;
158  }
160  ClientOptions& add_user_agent_prefx(std::string const& v) {
161  return add_user_agent_prefix(v);
162  }
163 
164  std::size_t maximum_simple_upload_size() const {
165  return maximum_simple_upload_size_;
166  }
168  maximum_simple_upload_size_ = v;
169  return *this;
170  }
171 
177  return enable_ssl_locking_callbacks_;
178  }
180  enable_ssl_locking_callbacks_ = v;
181  return *this;
182  }
183 
184  bool enable_sigpipe_handler() const { return enable_sigpipe_handler_; }
186  enable_sigpipe_handler_ = v;
187  return *this;
188  }
189 
190  std::size_t maximum_socket_recv_size() const {
191  return maximum_socket_recv_size_;
192  }
194  maximum_socket_recv_size_ = v;
195  return *this;
196  }
197 
198  std::size_t maximum_socket_send_size() const {
199  return maximum_socket_send_size_;
200  }
202  maximum_socket_send_size_ = v;
203  return *this;
204  }
205 
206  ChannelOptions& channel_options() { return channel_options_; }
207  ChannelOptions const& channel_options() const { return channel_options_; }
208 
210 
219  std::chrono::seconds download_stall_timeout() const {
220  return download_stall_timeout_;
221  }
222  ClientOptions& set_download_stall_timeout(std::chrono::seconds v) {
223  download_stall_timeout_ = v;
224  return *this;
225  }
227 
228  private:
229  friend std::string internal::JsonEndpoint(ClientOptions const&);
230  friend std::string internal::JsonUploadEndpoint(ClientOptions const&);
231  friend std::string internal::XmlEndpoint(ClientOptions const&);
232  friend std::string internal::IamEndpoint(ClientOptions const&);
233 
234  void SetupFromEnvironment();
235 
236  std::shared_ptr<oauth2::Credentials> credentials_;
237  std::string endpoint_;
238  std::string iam_endpoint_;
239  std::string version_;
240  bool enable_http_tracing_;
241  bool enable_raw_client_tracing_;
242  std::string project_id_;
243  std::size_t connection_pool_size_;
244  std::size_t download_buffer_size_;
245  std::size_t upload_buffer_size_;
246  std::string user_agent_prefix_;
247  std::size_t maximum_simple_upload_size_;
248  bool enable_ssl_locking_callbacks_ = true;
249  bool enable_sigpipe_handler_ = true;
250  std::size_t maximum_socket_recv_size_ = 0;
251  std::size_t maximum_socket_send_size_ = 0;
252  std::chrono::seconds download_stall_timeout_;
253  ChannelOptions channel_options_;
254 };
255 
256 } // namespace STORAGE_CLIENT_NS
257 } // namespace storage
258 } // namespace cloud
259 } // namespace google
260 
261 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_CLIENT_OPTIONS_H
google::cloud::storage::v1::ClientOptions::maximum_socket_recv_size
std::size_t maximum_socket_recv_size() const
Definition: client_options.h:190
google::cloud::storage::v1::ClientOptions::iam_endpoint
std::string const & iam_endpoint() const
Definition: client_options.h:108
google::cloud::storage::v1::ClientOptions::add_user_agent_prefx
ClientOptions & add_user_agent_prefx(std::string const &v)
Definition: client_options.h:160
google::cloud::storage::v1::ClientOptions::ClientOptions
ClientOptions(std::shared_ptr< oauth2::Credentials > credentials)
Definition: client_options.h:76
google::cloud::storage::v1::ClientOptions::set_maximum_simple_upload_size
ClientOptions & set_maximum_simple_upload_size(std::size_t v)
Definition: client_options.h:167
google::cloud::storage::v1::ClientOptions::download_stall_timeout
std::chrono::seconds download_stall_timeout() const
Control the maximum amount of time allowed for "stalls" during a download.
Definition: client_options.h:219
google::cloud::storage::v1::ClientOptions::maximum_socket_send_size
std::size_t maximum_socket_send_size() const
Definition: client_options.h:198
google::cloud::storage::v1::ClientOptions
Describes the configuration for a storage::Client object.
Definition: client_options.h:74
google::cloud::storage::v1::ClientOptions::download_buffer_size
std::size_t download_buffer_size() const
Definition: client_options.h:144
version.h
google::cloud::storage::v1::ClientOptions::enable_sigpipe_handler
bool enable_sigpipe_handler() const
Definition: client_options.h:184
google::cloud::storage::v1::ClientOptions::add_user_agent_prefix
ClientOptions & add_user_agent_prefix(std::string prefix)
Definition: client_options.h:151
google::cloud::storage::v1::ClientOptions::set_version
ClientOptions & set_version(std::string version)
Definition: client_options.h:115
google::cloud::storage::v1::ClientOptions::set_enable_ssl_locking_callbacks
ClientOptions & set_enable_ssl_locking_callbacks(bool v)
Definition: client_options.h:179
google::cloud::storage::v1::ClientOptions::project_id
std::string const & project_id() const
Definition: client_options.h:132
google::cloud::storage::v1::ClientOptions::set_maximum_socket_recv_size
ClientOptions & set_maximum_socket_recv_size(std::size_t v)
Definition: client_options.h:193
google::cloud::storage::v1::ChannelOptions::ssl_root_path
std::string ssl_root_path() const
Definition: client_options.h:47
google::cloud::storage::v1::ClientOptions::version
std::string const & version() const
Definition: client_options.h:114
google::cloud::storage::v1::ClientOptions::set_download_stall_timeout
ClientOptions & set_download_stall_timeout(std::chrono::seconds v)
Definition: client_options.h:222
google::cloud::storage::v1::ClientOptions::set_maximum_socket_send_size
ClientOptions & set_maximum_socket_send_size(std::size_t v)
Definition: client_options.h:201
google::cloud::storage::v1::ClientOptions::endpoint
std::string const & endpoint() const
Definition: client_options.h:102
credentials.h
google::cloud::storage::v1::ClientOptions::set_endpoint
ClientOptions & set_endpoint(std::string endpoint)
Definition: client_options.h:103
google::cloud::storage::v1::ChannelOptions::set_ssl_root_path
ChannelOptions & set_ssl_root_path(std::string ssl_root_path)
Definition: client_options.h:49
google::cloud::storage::v1::ClientOptions::enable_raw_client_tracing
bool enable_raw_client_tracing() const
Definition: client_options.h:126
google::cloud::storage::v1::ClientOptions::channel_options
ChannelOptions & channel_options()
Definition: client_options.h:206
google::cloud::storage::v1::ClientOptions::credentials
std::shared_ptr< oauth2::Credentials > credentials() const
Definition: client_options.h:93
google::cloud::storage::v1::ClientOptions::connection_pool_size
std::size_t connection_pool_size() const
Definition: client_options.h:138
STORAGE_CLIENT_NS
#define STORAGE_CLIENT_NS
Definition: version.h:22
google::cloud::storage::v1::ClientOptions::maximum_simple_upload_size
std::size_t maximum_simple_upload_size() const
Definition: client_options.h:164
google::cloud::storage::v1::version
constexpr int version()
Returns a single integer representing the Major/Minor/Patch version.
Definition: version.h:67
google::cloud::storage::v1::ClientOptions::enable_ssl_locking_callbacks
bool enable_ssl_locking_callbacks() const
If true and using OpenSSL 1.0.2 the library configures the OpenSSL callbacks for locking.
Definition: client_options.h:176
google::cloud::storage::v1::ClientOptions::upload_buffer_size
std::size_t upload_buffer_size() const
Definition: client_options.h:147
google::cloud::storage::v1::ClientOptions::set_enable_http_tracing
ClientOptions & set_enable_http_tracing(bool enable)
Definition: client_options.h:121
google::cloud::storage::v1::ClientOptions::channel_options
ChannelOptions const & channel_options() const
Definition: client_options.h:207
google::cloud::storage::v1::ClientOptions::set_credentials
ClientOptions & set_credentials(std::shared_ptr< oauth2::Credentials > credentials)
Definition: client_options.h:96
google::cloud::storage::v1::ClientOptions::set_connection_pool_size
ClientOptions & set_connection_pool_size(std::size_t size)
Definition: client_options.h:139
google::cloud::storage::v1::ChannelOptions
Describes the configuration for low-level connection features.
Definition: client_options.h:45
google
google::cloud::storage::v1::ClientOptions::set_enable_sigpipe_handler
ClientOptions & set_enable_sigpipe_handler(bool v)
Definition: client_options.h:185
google::cloud::storage::v1::ClientOptions::enable_http_tracing
bool enable_http_tracing() const
Definition: client_options.h:120
google::cloud::storage::v1::ClientOptions::set_iam_endpoint
ClientOptions & set_iam_endpoint(std::string endpoint)
Definition: client_options.h:109
google::cloud::storage::v1::ClientOptions::set_project_id
ClientOptions & set_project_id(std::string v)
Definition: client_options.h:133
google::cloud::storage::v1::ClientOptions::user_agent_prefix
std::string const & user_agent_prefix() const
Definition: client_options.h:150
google::cloud::storage::v1::ClientOptions::set_enable_raw_client_tracing
ClientOptions & set_enable_raw_client_tracing(bool enable)
Definition: client_options.h:127