15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_ASYNC_CLIENT_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_ASYNC_CLIENT_H
18#include "google/cloud/storage/internal/async_connection.h"
19#include "google/cloud/storage/internal/object_requests.h"
20#include "google/cloud/storage/version.h"
21#include "google/cloud/background_threads.h"
22#include "google/cloud/internal/group_options.h"
23#include "google/cloud/status_or.h"
28GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132 template <
typename... RequestOptions>
134 std::string
const& bucket_name, std::string
const& object_name,
135 std::int64_t offset, std::int64_t limit, RequestOptions&&... options) {
137 :
public absl::disjunction<
139 struct HasReadFromOffset
140 :
public absl::disjunction<
143 :
public absl::disjunction<
146 static_assert(!HasReadRange::value,
147 "Cannot use `ReadRange()` as a request option in "
148 "`AsyncClient::ReadObject()`, use the `offset` and `limit` "
149 "parameters instead.");
150 static_assert(!HasReadFromOffset::value,
151 "Cannot use `ReadFromOffset()` as a request option in "
152 "`AsyncClient::ReadObject()`, use the `offset` and `limit` "
153 "parameters instead.");
154 static_assert(!HasReadLast::value,
155 "Cannot use `ReadLast()` as a request option in "
156 "`AsyncClient::ReadObject()`, use the `offset` and `limit` "
157 "parameters instead.");
160 SpanOptions(std::forward<
Options>(options)...));
161 storage::internal::ReadObjectRangeRequest request(bucket_name, object_name);
162 request.set_multiple_options(std::forward<
Options>(options)...,
164 return connection_->AsyncReadObjectRange(std::move(request));
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 template <
typename... Options>
186 std::string bucket_name,
188 std::string destination_object_name, Options&&... options) {
190 SpanOptions(std::forward<Options>(options)...));
191 storage::internal::ComposeObjectRequest request(
192 std::move(bucket_name), std::move(source_objects),
193 std::move(destination_object_name));
194 request.set_multiple_options(std::forward<Options>(options)...);
195 return connection_->AsyncComposeObject(request);
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214 template <
typename... RequestOptions>
216 std::string
const& object_name,
217 RequestOptions&&... options) {
219 SpanOptions(std::forward<RequestOptions>(options)...));
220 storage::internal::DeleteObjectRequest request(bucket_name, object_name);
221 request.set_multiple_options(std::forward<RequestOptions>(options)...);
222 return connection_->AsyncDeleteObject(std::move(request));
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262 template <
typename... RequestOptions>
264 std::string
const& bucket_name, std::string
const& object_name,
265 RequestOptions&&... options) {
266 struct HasUseResumableUploadSession
267 :
public absl::disjunction<std::is_same<
269 static_assert(!HasUseResumableUploadSession::value,
270 "Cannot use `UseResumableUploadSession` as a request option "
271 "in `AsyncClient::StartResumableUpload()`. If you want to "
272 "resume the upload, simply use the existing upload id.");
275 SpanOptions(std::forward<
Options>(options)...));
276 storage::internal::ResumableUploadRequest request(bucket_name, object_name);
277 request.set_multiple_options(std::forward<
Options>(options)...);
278 return connection_->AsyncStartResumableWrite(std::move(request));
283 explicit AsyncClient(
285 std::shared_ptr<storage_internal::AsyncConnection> connection);
287 template <
typename... RequestOptions>
290 connection_->options(), std::forward<RequestOptions>(o)...);
294 std::shared_ptr<storage_internal::AsyncConnection> connection_;
302GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
friend friend class future
A client for Google Cloud Storage offering asynchronous operations.
Definition: async_client.h:105
future< Status > DeleteObject(std::string const &bucket_name, std::string const &object_name, RequestOptions &&... options)
Deletes an object.
Definition: async_client.h:215
future< AsyncReadObjectRangeResponse > ReadObject(std::string const &bucket_name, std::string const &object_name, std::int64_t offset, std::int64_t limit, RequestOptions &&... options)
Reads the contents of an object.
Definition: async_client.h:133
future< StatusOr< std::string > > StartResumableUpload(std::string const &bucket_name, std::string const &object_name, RequestOptions &&... options)
Starts a resumable upload.
Definition: async_client.h:263
friend AsyncClient MakeAsyncClient(Options opts)
Creates a new GCS client exposing asynchronous APIs.
future< StatusOr< storage::ObjectMetadata > > ComposeObject(std::string bucket_name, std::vector< storage::ComposeSourceObject > source_objects, std::string destination_object_name, Options &&... options)
Composes existing objects into a new object in the same bucket.
Definition: async_client.h:185
Contains experimental features for the GCS C++ Client Library.
Definition: async_client.h:27
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24
Defines one of the source objects for a compose operation.
Definition: object_metadata.h:44
Download all the data from the GCS object starting at the given offset.
Definition: download_options.h:54
Read last N bytes from the GCS object.
Definition: download_options.h:65
Request only a portion of the GCS object in a ReadObject operation.
Definition: download_options.h:38
ReadRange(std::int64_t begin, std::int64_t end)
Definition: download_options.h:40
Request a resumable upload, restoring a previous session if necessary.
Definition: upload_options.h:38
Represents the response from reading a subset of an object.
Definition: async_object_responses.h:32