userver: userver/s3api/models/multipart_upload/responses.hpp Source File
Loading...
Searching...
No Matches
responses.hpp
1#pragma once
2
3#include <chrono>
4#include <optional>
5#include <string>
6#include <vector>
7
8#include <userver/utils/zstring_view.hpp>
9
10USERVER_NAMESPACE_BEGIN
11
12namespace s3api::multipart_upload {
13
14/// For some unclear reasons almost all fields in S3 API are optional
15/// including even those fields which are clearly stated to be required
16/// in S3 documentation.
17/// There are some unconvincing explanations for this at
18/// https://github.com/boto/botocore/issues/1069#issuecomment-259255047, but that's it!
19/// This implementation of the API in this library is a bit stricter than it is in S3 API
20/// specifciation, intentionally making some `optional` fields to be `required non-empty`.
21
22/// The response body content of CreateMultipartUpload action request
23/// @see
24/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateMultipartUpload.html#API_CreateMultipartUpload_ResponseSyntax
25/// NOTE: `bucket`, `key`, `upload_id` are allowed to be empty string values by the S3 specification.
27 std::string bucket;
28 std::string key;
29 std::string upload_id;
30
31 static InitiateMultipartUploadResult Parse(utils::zstring_view http_s3_respose_body);
32};
33
34/// The response body content of CompleteMultipartUpload action request
35/// @see
36/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_CompleteMultipartUpload.html#API_CompleteMultipartUpload_ResponseSyntax
37/// May also include ETag, Checksum*, etc.
38/// NOTE: `bucket`, `key`, `location` are allowed to be empty string values by the S3 specification.
40 std::string bucket;
41 std::string key;
42 std::string location;
43
44 static CompleteMultipartUploadResult Parse(utils::zstring_view http_s3_respose_body);
45};
46
47/// The response body content of CompleteMultipartUpload action request
48/// @see
49/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListMultipartUploads.html#API_ListMultipartUploads_ResponseSyntax
50/// NOTE:
51/// Do not use the result of this listing when sending a complete multipart upload request.
52/// Instead, maintain your own list of the part numbers that you specified when uploading parts
53/// and the corresponding ETag values that Amazon S3 returns.
54/// (details in https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html)
57 std::string key;
58 std::string upload_id;
59 std::optional<std::chrono::system_clock::time_point> initiated_ts;
60 };
61
62 std::string bucket;
63 std::optional<std::string> key_marker;
64 std::optional<std::string> upload_id_marker;
65 std::optional<std::string> next_key_marker;
66 std::optional<std::string> next_upload_id_marker;
67 std::optional<std::string> delimiter;
68 bool is_truncated{false};
69 std::optional<unsigned> max_uploads;
70 std::vector<MultipartUpload> uploads;
71 std::vector<std::string> common_prefixes;
72
73 static ListMultipartUploadsResult Parse(utils::zstring_view http_s3_respose_body);
74};
75
76/// The response body content of ListParts action request
77/// @see
78/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListParts.html#API_ListParts_ResponseSyntax
79/// May also include Initiator, Owner, Checksum*, StorageClass and etc.
81 struct Part {
82 std::string etag;
83 unsigned part_number;
84 std::optional<std::chrono::system_clock::time_point> last_modified_ts;
85 std::optional<unsigned long> byte_size;
86 };
87
88 std::string bucket;
89 std::string key;
90 std::string upload_id;
91 std::optional<unsigned> max_parts;
92 std::optional<unsigned> part_number_marker;
93 std::optional<unsigned> next_part_number_marker;
94 bool is_truncated{false};
95 std::vector<Part> parts;
96
97 static ListPartsResult Parse(utils::zstring_view http_s3_respose_body);
98};
99
100/// The response struct containing response header values for UploadPart action request
101/// @see
102/// https://docs.aws.amazon.com/AmazonS3/latest/API/API_UploadPart.html#API_UploadPart_ResponseSyntax
103/// May also include checksum headers and etc.
105 std::string etag;
106};
107
108} // namespace s3api::multipart_upload
109
110USERVER_NAMESPACE_END