15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_POLICY_DOCUMENT_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_POLICY_DOCUMENT_H
18#include "google/cloud/storage/version.h"
28GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
30
31
37 : elements_(std::move(elements)) {}
39 std::vector<std::string>
const&
elements()
const {
return elements_; }
43
44
47 static std::vector<std::string>
ExactMatch(std::string
const& field,
48 std::string
const& value) {
49 std::vector<std::string> result;
50 result.emplace_back(
"eq");
51 result.emplace_back(std::string(
"$") + field);
52 result.emplace_back(value);
58 std::string
const& value) {
59 std::vector<std::string> result;
60 result.emplace_back(field);
61 result.emplace_back(value);
65 static std::vector<std::string>
StartsWith(std::string
const& field,
66 std::string
const& value) {
67 std::vector<std::string> result;
68 result.emplace_back(
"starts-with");
69 result.emplace_back(std::string(
"$") + field);
70 result.emplace_back(value);
75 std::int32_t max_range) {
76 std::vector<std::string> result;
77 result.emplace_back(
"content-length-range");
78 result.emplace_back(std::to_string(min_range));
79 result.emplace_back(std::to_string(max_range));
85 std::vector<std::string> elements_;
100 return std::rel_ops::operator!=(lhs, rhs);
105 return std::rel_ops::operator>(lhs, rhs);
110 return std::rel_ops::operator<=(lhs, rhs);
115 return std::rel_ops::operator>=(lhs, rhs);
121
122
123
124
125
126
127
128
129
131 std::chrono::system_clock::time_point
expiration;
135std::ostream& operator<<(std::ostream& os,
PolicyDocument const& rhs);
138
139
140
141
142
143
144
145
146
150 std::chrono::seconds expiration,
151 std::chrono::system_clock::time_point timestamp =
152 std::chrono::system_clock::now(),
154 :
bucket(std::move(bucket)),
155 object(std::move(object)),
163 std::chrono::system_clock::time_point
timestamp;
170
171
172
173
174
175
178 std::chrono::system_clock::time_point
expiration;
186
187
188
189
190
191
195 std::chrono::system_clock::time_point
expiration;
207GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
Define a condition for a policy document.
Definition: policy_document.h:32
PolicyDocumentCondition(std::vector< std::string > elements)
Definition: policy_document.h:36
static std::vector< std::string > ExactMatchObject(std::string const &field, std::string const &value)
Creates an exact match condition, but in object form syntax.
Definition: policy_document.h:57
static std::vector< std::string > ContentLengthRange(std::int32_t min_range, std::int32_t max_range)
Creates an exact match condition, in the list form syntax.
Definition: policy_document.h:74
static std::vector< std::string > StartsWith(std::string const &field, std::string const &value)
Creates an exact match condition, in the list form syntax.
Definition: policy_document.h:65
std::vector< std::string > const & elements() const
Definition: policy_document.h:39
PolicyDocumentCondition()=default
static std::vector< std::string > ExactMatch(std::string const &field, std::string const &value)
Creates an exact match condition, in the list form syntax.
Definition: policy_document.h:47
Contains all the Google Cloud Storage C++ client APIs.
Definition: auto_finalize.h:24
bool operator<(PolicyDocumentCondition const &lhs, PolicyDocumentCondition const &rhs)
Definition: policy_document.h:93
bool operator>(PolicyDocumentCondition const &lhs, PolicyDocumentCondition const &rhs)
Definition: policy_document.h:103
bool operator>=(PolicyDocumentCondition const &lhs, PolicyDocumentCondition const &rhs)
Definition: policy_document.h:113
std::string FormatDateForForm(PolicyDocumentV4Result const &)
Format the current date in the format expected by a POST form.
bool operator!=(PolicyDocumentCondition const &lhs, PolicyDocumentCondition const &rhs)
Definition: policy_document.h:98
bool operator<=(PolicyDocumentCondition const &lhs, PolicyDocumentCondition const &rhs)
Definition: policy_document.h:108
bool operator==(PolicyDocumentCondition const &lhs, PolicyDocumentCondition const &rhs)
Definition: policy_document.h:88
Define a policy document result.
Definition: policy_document.h:176
std::string access_id
Definition: policy_document.h:177
std::string signature
Definition: policy_document.h:180
std::string policy
Definition: policy_document.h:179
std::chrono::system_clock::time_point expiration
Definition: policy_document.h:178
Define a policy document result V4.
Definition: policy_document.h:192
std::string policy
Definition: policy_document.h:196
std::string access_id
Definition: policy_document.h:194
std::map< std::string, std::string > required_form_fields
Definition: policy_document.h:199
std::string signing_algorithm
Definition: policy_document.h:198
std::string url
Definition: policy_document.h:193
std::chrono::system_clock::time_point expiration
Definition: policy_document.h:195
std::string signature
Definition: policy_document.h:197
Define a policy document V4.
Definition: policy_document.h:147
std::vector< PolicyDocumentCondition > conditions
Definition: policy_document.h:164
PolicyDocumentV4(std::string bucket, std::string object, std::chrono::seconds expiration, std::chrono::system_clock::time_point timestamp=std::chrono::system_clock::now(), std::vector< PolicyDocumentCondition > conditions={})
Definition: policy_document.h:149
std::string bucket
Definition: policy_document.h:160
std::chrono::system_clock::time_point timestamp
Definition: policy_document.h:163
PolicyDocumentV4()=default
std::chrono::seconds expiration
Definition: policy_document.h:162
std::string object
Definition: policy_document.h:161
Define a policy document.
Definition: policy_document.h:130
std::chrono::system_clock::time_point expiration
Definition: policy_document.h:131
std::vector< PolicyDocumentCondition > conditions
Definition: policy_document.h:132