Google Cloud Storage C++ Client  1.25.0
A C++ Client Library for Google Cloud Storage
signed_url_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_SIGNED_URL_OPTIONS_H
16 #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_SIGNED_URL_OPTIONS_H
17 
18 #include "google/cloud/storage/internal/complex_option.h"
20 #include <chrono>
21 #include <string>
22 #include <vector>
23 
24 namespace google {
25 namespace cloud {
26 namespace storage {
27 inline namespace STORAGE_CLIENT_NS {
32  : public internal::ComplexOption<ExpirationTime,
33  std::chrono::system_clock::time_point> {
34  using ComplexOption<ExpirationTime,
35  std::chrono::system_clock::time_point>::ComplexOption;
36  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
37  // explicitly
38  ExpirationTime() = default;
39  static char const* name() { return "expiration_time"; }
40 };
41 
46  : public internal::ComplexOption<AddExtensionHeaderOption,
47  std::pair<std::string, std::string>> {
48  using ComplexOption<AddExtensionHeaderOption,
49  std::pair<std::string, std::string>>::ComplexOption;
50  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
51  // explicitly
53  AddExtensionHeaderOption(std::string header, std::string value)
54  : ComplexOption(std::make_pair(std::move(header), std::move(value))) {}
55  static char const* name() { return "expiration_time"; }
56 };
57 
58 inline AddExtensionHeaderOption AddExtensionHeader(std::string header,
59  std::string value) {
60  return AddExtensionHeaderOption(std::move(header), std::move(value));
61 }
62 
67  : public internal::ComplexOption<AddQueryParameterOption,
68  std::pair<std::string, std::string>> {
69  using ComplexOption<AddQueryParameterOption,
70  std::pair<std::string, std::string>>::ComplexOption;
71  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
72  // explicitly
74  AddQueryParameterOption(std::string key, std::string value)
75  : ComplexOption(std::make_pair(std::move(key), std::move(value))) {}
76  AddQueryParameterOption(char const* key, std::string value)
77  : ComplexOption(std::make_pair(std::string(key), std::move(value))) {}
78  static char const* name() { return "query-parameter"; }
79 };
80 
81 inline AddQueryParameterOption WithGeneration(std::uint64_t generation) {
82  return AddQueryParameterOption("generation", std::to_string(generation));
83 }
84 
85 inline AddQueryParameterOption WithGenerationMarker(std::uint64_t generation) {
86  return AddQueryParameterOption("generation-marker",
87  std::to_string(generation));
88 }
89 
90 inline AddQueryParameterOption WithUserProject(std::string user_project) {
91  return AddQueryParameterOption("userProject", std::move(user_project));
92 }
93 
94 inline AddQueryParameterOption WithMarker(std::string marker) {
95  return AddQueryParameterOption("marker", std::move(marker));
96 }
97 
99  std::string disposition) {
100  return AddQueryParameterOption("response-content-disposition",
101  std::move(disposition));
102 }
103 
105  std::string const& type) {
106  return AddQueryParameterOption("response-content-type", type);
107 }
108 
113  : public internal::ComplexOption<SubResourceOption, std::string> {
114  using ComplexOption<SubResourceOption, std::string>::ComplexOption;
115  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
116  // explicitly
117  SubResourceOption() = default;
118  static char const* name() { return "query-parameter"; }
119 };
120 
121 inline SubResourceOption WithAcl() { return SubResourceOption("acl"); }
122 
123 inline SubResourceOption WithBilling() { return SubResourceOption("billing"); }
124 
125 inline SubResourceOption WithCompose() { return SubResourceOption("compose"); }
126 
127 inline SubResourceOption WithCors() { return SubResourceOption("cors"); }
128 
130  return SubResourceOption("encryption");
131 }
132 
134  return SubResourceOption("encryptionConfig");
135 }
136 
138  return SubResourceOption("lifecycle");
139 }
140 
142  return SubResourceOption("location");
143 }
144 
145 inline SubResourceOption WithLogging() { return SubResourceOption("logging"); }
146 
148  return SubResourceOption("storageClass");
149 }
150 
151 inline SubResourceOption WithTagging() { return SubResourceOption("tagging"); }
152 
157  : public internal::ComplexOption<SignedUrlTimestamp,
158  std::chrono::system_clock::time_point> {
159  using ComplexOption<SignedUrlTimestamp,
160  std::chrono::system_clock::time_point>::ComplexOption;
161  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
162  // explicitly
163  SignedUrlTimestamp() = default;
164  static char const* name() { return "x-goog-date"; }
165 };
166 
171  : public internal::ComplexOption<SignedUrlDuration, std::chrono::seconds> {
172  using ComplexOption<SignedUrlDuration, std::chrono::seconds>::ComplexOption;
173  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
174  // explicitly
175  SignedUrlDuration() = default;
176  static char const* name() { return "x-goog-expires"; }
177 };
178 
186  : public internal::ComplexOption<SigningAccount, std::string> {
187  using ComplexOption<SigningAccount, std::string>::ComplexOption;
188  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
189  // explicitly
190  SigningAccount() = default;
191  static char const* name() { return "signing-account"; }
192 };
193 
202  : public internal::ComplexOption<SigningAccountDelegates,
203  std::vector<std::string>> {
204  using ComplexOption<SigningAccountDelegates,
205  std::vector<std::string>>::ComplexOption;
206  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
207  // explicitly
209  static char const* name() { return "signing-account-delegates"; }
210 };
211 
219 struct VirtualHostname : public internal::ComplexOption<VirtualHostname, bool> {
220  using ComplexOption<VirtualHostname, bool>::ComplexOption;
221  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
222  // explicitly
223  VirtualHostname() = default;
224  static char const* option_name() { return "virtual-hostname"; }
225 };
226 
234  : public internal::ComplexOption<BucketBoundHostname, std::string> {
235  using ComplexOption<BucketBoundHostname, std::string>::ComplexOption;
236  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
237  // explicitly
238  BucketBoundHostname() = default;
239  static char const* option_name() { return "domain-named-bucket"; }
240 };
241 
243 struct Scheme : public internal::ComplexOption<Scheme, std::string> {
244  using ComplexOption<Scheme, std::string>::ComplexOption;
245  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
246  // explicitly
247  Scheme() = default;
248  static char const* option_name() { return "scheme"; }
249 };
250 
255  : public internal::ComplexOption<AddExtensionFieldOption,
256  std::pair<std::string, std::string>> {
257  using ComplexOption<AddExtensionFieldOption,
258  std::pair<std::string, std::string>>::ComplexOption;
259  // GCC <= 7.0 does not use the inherited default constructor, redeclare it
260  // explicitly
262  AddExtensionFieldOption(std::string field, std::string value)
263  : ComplexOption(std::make_pair(std::move(field), std::move(value))) {}
264  static char const* name() { return "extension_field"; }
265 };
266 
268  std::string value) {
269  return AddExtensionFieldOption(std::move(field), std::move(value));
270 }
271 
272 } // namespace STORAGE_CLIENT_NS
273 } // namespace storage
274 } // namespace cloud
275 } // namespace google
276 
277 #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_STORAGE_SIGNED_URL_OPTIONS_H
google::cloud::storage::v1::SigningAccountDelegates
Specify the sequence of delegates used to sign a blob.
Definition: signed_url_options.h:203
google::cloud::storage::v1::SignedUrlDuration::name
static char const * name()
Definition: signed_url_options.h:176
google::cloud::storage::v1::AddExtensionField
AddExtensionFieldOption AddExtensionField(std::string field, std::string value)
Definition: signed_url_options.h:267
google::cloud::storage::v1::AddQueryParameterOption::AddQueryParameterOption
AddQueryParameterOption(std::string key, std::string value)
Definition: signed_url_options.h:74
google::cloud::storage::v1::AddExtensionFieldOption::AddExtensionFieldOption
AddExtensionFieldOption(std::string field, std::string value)
Definition: signed_url_options.h:262
google::cloud::storage::v1::VirtualHostname::VirtualHostname
VirtualHostname()=default
google::cloud::storage::v1::SigningAccountDelegates::name
static char const * name()
Definition: signed_url_options.h:209
google::cloud::storage::v1::AddExtensionFieldOption
Add a extension header to a POST policy.
Definition: signed_url_options.h:256
google::cloud::storage::v1::WithStorageClass
SubResourceOption WithStorageClass()
Definition: signed_url_options.h:147
google::cloud::storage::v1::SubResourceOption::SubResourceOption
SubResourceOption()=default
google::cloud::storage::v1::AddExtensionHeaderOption::name
static char const * name()
Definition: signed_url_options.h:55
google::cloud::storage::v1::WithLocation
SubResourceOption WithLocation()
Definition: signed_url_options.h:141
google::cloud::storage::v1::WithCors
SubResourceOption WithCors()
Definition: signed_url_options.h:127
google::cloud::storage::v1::AddExtensionFieldOption::name
static char const * name()
Definition: signed_url_options.h:264
google::cloud::storage::v1::ExpirationTime::ExpirationTime
ExpirationTime()=default
google::cloud::storage::v1::BucketBoundHostname
Use domain-named bucket in a V4 signed URL.
Definition: signed_url_options.h:234
google::cloud::storage::v1::Scheme
Use the specified scheme (e.g. "http") in a V4 signed URL.
Definition: signed_url_options.h:243
google::cloud::storage::v1::AddQueryParameterOption::AddQueryParameterOption
AddQueryParameterOption()=default
google::cloud::storage::v1::WithEncryptionConfig
SubResourceOption WithEncryptionConfig()
Definition: signed_url_options.h:133
google::cloud::storage::v1::Scheme::option_name
static char const * option_name()
Definition: signed_url_options.h:248
google::cloud::storage::v1::AddExtensionHeaderOption
Add a extension header to a signed URL.
Definition: signed_url_options.h:47
google::cloud::storage::v1::AddQueryParameterOption::AddQueryParameterOption
AddQueryParameterOption(char const *key, std::string value)
Definition: signed_url_options.h:76
version.h
google::cloud::storage::v1::ExpirationTime::name
static char const * name()
Definition: signed_url_options.h:39
google::cloud::storage::v1::AddQueryParameterOption
Add a extension header to a signed URL.
Definition: signed_url_options.h:68
google::cloud::storage::v1::WithLogging
SubResourceOption WithLogging()
Definition: signed_url_options.h:145
google::cloud::storage::v1::WithMarker
AddQueryParameterOption WithMarker(std::string marker)
Definition: signed_url_options.h:94
google::cloud::storage::v1::WithResponseContentDisposition
AddQueryParameterOption WithResponseContentDisposition(std::string disposition)
Definition: signed_url_options.h:98
google::cloud::storage::v1::SigningAccount::name
static char const * name()
Definition: signed_url_options.h:191
google::cloud::storage::v1::WithLifecycle
SubResourceOption WithLifecycle()
Definition: signed_url_options.h:137
google::cloud::storage::v1::AddExtensionFieldOption::AddExtensionFieldOption
AddExtensionFieldOption()=default
google::cloud::storage::v1::VirtualHostname
Indicate that the bucket should be a part of hostname in the URL.
Definition: signed_url_options.h:219
google::cloud::storage::v1::SignedUrlTimestamp
Define the timestamp duration for a V4 signed URL.
Definition: signed_url_options.h:158
google::cloud::storage::v1::WithGeneration
AddQueryParameterOption WithGeneration(std::uint64_t generation)
Definition: signed_url_options.h:81
google::cloud::storage::v1::SigningAccount::SigningAccount
SigningAccount()=default
google::cloud::storage::v1::AddExtensionHeaderOption::AddExtensionHeaderOption
AddExtensionHeaderOption(std::string header, std::string value)
Definition: signed_url_options.h:53
google::cloud::storage::v1::BucketBoundHostname::option_name
static char const * option_name()
Definition: signed_url_options.h:239
google::cloud::storage::v1::WithResponseContentType
AddQueryParameterOption WithResponseContentType(std::string const &type)
Definition: signed_url_options.h:104
google::cloud::storage::v1::WithUserProject
AddQueryParameterOption WithUserProject(std::string user_project)
Definition: signed_url_options.h:90
google::cloud::storage::v1::AddQueryParameterOption::name
static char const * name()
Definition: signed_url_options.h:78
google::cloud::storage::v1::SignedUrlDuration::SignedUrlDuration
SignedUrlDuration()=default
google::cloud::storage::v1::SignedUrlTimestamp::SignedUrlTimestamp
SignedUrlTimestamp()=default
google::cloud::storage::v1::WithTagging
SubResourceOption WithTagging()
Definition: signed_url_options.h:151
google::cloud::storage::v1::Scheme::Scheme
Scheme()=default
google::cloud::storage::v1::SubResourceOption::name
static char const * name()
Definition: signed_url_options.h:118
STORAGE_CLIENT_NS
#define STORAGE_CLIENT_NS
Definition: version.h:30
google::cloud::storage::v1::WithCompose
SubResourceOption WithCompose()
Definition: signed_url_options.h:125
google::cloud::storage::v1::SigningAccountDelegates::SigningAccountDelegates
SigningAccountDelegates()=default
google::cloud::storage::v1::SubResourceOption
Specify a sub-resource in a signed URL.
Definition: signed_url_options.h:113
google::cloud::storage::v1::VirtualHostname::option_name
static char const * option_name()
Definition: signed_url_options.h:224
google::cloud::storage::v1::WithBilling
SubResourceOption WithBilling()
Definition: signed_url_options.h:123
google::cloud::storage::v1::SignedUrlTimestamp::name
static char const * name()
Definition: signed_url_options.h:164
google::cloud::storage::v1::SigningAccount
Specify the service account used to sign a blob.
Definition: signed_url_options.h:186
google::cloud::storage::v1::WithGenerationMarker
AddQueryParameterOption WithGenerationMarker(std::uint64_t generation)
Definition: signed_url_options.h:85
google::cloud::storage::v1::SignedUrlDuration
Define the duration for a V4 signed URL.
Definition: signed_url_options.h:171
google::cloud::storage::v1::AddExtensionHeaderOption::AddExtensionHeaderOption
AddExtensionHeaderOption()=default
google::cloud::storage::v1::WithAcl
SubResourceOption WithAcl()
Definition: signed_url_options.h:121
google
google::cloud::storage::v1::BucketBoundHostname::BucketBoundHostname
BucketBoundHostname()=default
google::cloud::storage::v1::AddExtensionHeader
AddExtensionHeaderOption AddExtensionHeader(std::string header, std::string value)
Definition: signed_url_options.h:58
google::cloud::storage::v1::WithEncryption
SubResourceOption WithEncryption()
Definition: signed_url_options.h:129
google::cloud::storage::v1::ExpirationTime
Define the expiration time for a signed URL.
Definition: signed_url_options.h:33