AWS SDK for C++  1.8.2
AWS SDK for C++
AWSClient.h
Go to the documentation of this file.
1 
6 #pragma once
7 
15 #include <memory>
16 #include <atomic>
17 
18 struct aws_array_list;
19 
20 namespace Aws
21 {
22  namespace Utils
23  {
24  template<typename R, typename E>
25  class Outcome;
26 
27  namespace Xml
28  {
29  class XmlDocument;
30  } // namespace Xml
31 
32  namespace Json
33  {
34  class JsonValue;
35  } // namespace Json
36 
37  namespace RateLimits
38  {
40  } // namespace RateLimits
41 
42  namespace Crypto
43  {
44  class MD5;
45  } // namespace Crypto
46  } // namespace Utils
47 
48  namespace Http
49  {
50  class HttpClient;
51 
52  class HttpClientFactory;
53 
54  class HttpRequest;
55 
56  class HttpResponse;
57 
58  class URI;
59  } // namespace Http
60 
61  namespace Auth
62  {
63  AWS_CORE_API extern const char SIGV4_SIGNER[];
64  AWS_CORE_API extern const char NULL_SIGNER[];
65  }
66 
68 
69  namespace Client
70  {
71  template<typename ERROR_TYPE>
72  class AWSError;
73  class AWSErrorMarshaller;
74  class AWSRestfulJsonErrorMarshaller;
75  class AWSAuthSigner;
76  struct ClientConfiguration;
78 
81 
86  {
87  public:
93  AWSClient(const Aws::Client::ClientConfiguration& configuration,
94  const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer,
95  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
96 
102  AWSClient(const Aws::Client::ClientConfiguration& configuration,
103  const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
104  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
105 
106  virtual ~AWSClient() { };
107 
112  Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, long long expirationInSeconds = 0);
113 
118  Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0);
119 
124  Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, long long expirationInSeconds = 0) const;
125 
130  Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0);
131 
136  Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, long long expirationInSeconds = 0) const;
137 
138  Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method,
139  const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const;
140 
141  Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName,
142  const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const;
143 
144  Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region,
145  const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const;
146 
151  void DisableRequestProcessing();
152 
156  void EnableRequestProcessing();
157 
158  inline virtual const char* GetServiceClientName() const { return nullptr; }
159 
160  protected:
165  HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri,
166  const Aws::AmazonWebServiceRequest& request,
167  Http::HttpMethod httpMethod,
168  const char* signerName,
169  const char* signerRegionOverride = nullptr) const;
170 
178  HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri,
179  Http::HttpMethod httpMethod,
180  const char* signerName,
181  const char* requestName = "",
182  const char* signerRegionOverride = nullptr) const;
183 
188  HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest,
189  const Aws::AmazonWebServiceRequest& request,
190  const char* signerName,
191  const char* signerRegionOverride = nullptr) const;
192 
200  HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest,
201  const char* signerName,
202  const char* requestName = "",
203  const char* signerRegionOverride = nullptr) const;
204 
209  StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri,
210  const Aws::AmazonWebServiceRequest& request,
212  const char* signerName = Aws::Auth::SIGV4_SIGNER,
213  const char* signerRegionOverride = nullptr) const;
214 
222  StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri,
224  const char* signerName = Aws::Auth::SIGV4_SIGNER,
225  const char* requestName = "",
226  const char* signerRegionOverride = nullptr) const;
227 
231  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const = 0;
232 
236  virtual void BuildHttpRequest(const Aws::AmazonWebServiceRequest& request,
237  const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest) const;
238 
242  const std::shared_ptr<AWSErrorMarshaller>& GetErrorMarshaller() const
243  {
244  return m_errorMarshaller;
245  }
246 
250  Aws::Client::AWSAuthSigner* GetSignerByName(const char* name) const;
251  protected:
252 
260  std::shared_ptr<Aws::Http::HttpRequest> BuildAndSignHttpRequest(const Aws::Http::URI& uri,
261  const Aws::AmazonWebServiceRequest& request,
262  Http::HttpMethod method, const char* signerName) const;
263 
267  std::shared_ptr<Aws::Http::HttpResponse> MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const;
269  private:
274  bool AdjustClockSkew(HttpResponseOutcome& outcome, const char* signerName) const;
275  void AddHeadersToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const Http::HeaderValueCollection& headerValues) const;
276  void AddContentBodyToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const std::shared_ptr<Aws::IOStream>& body,
277  bool needsContentMd5 = false, bool isChunked = false) const;
278  void AddCommonHeaders(Aws::Http::HttpRequest& httpRequest) const;
279  void InitializeGlobalStatics();
280  std::shared_ptr<Aws::Http::HttpRequest> ConvertToRequestForPresigning(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri,
281  Aws::Http::HttpMethod method, const Aws::Http::QueryStringParameterCollection& extraParams) const;
282 
283  std::shared_ptr<Aws::Http::HttpClient> m_httpClient;
284  std::shared_ptr<Aws::Auth::AWSAuthSignerProvider> m_signerProvider;
285  std::shared_ptr<AWSErrorMarshaller> m_errorMarshaller;
286  std::shared_ptr<RetryStrategy> m_retryStrategy;
287  std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> m_writeRateLimiter;
288  std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> m_readRateLimiter;
289  Aws::String m_userAgent;
290  std::shared_ptr<Aws::Utils::Crypto::Hash> m_hash;
291  long m_requestTimeoutMs;
292  bool m_enableClockSkewAdjustment;
293  };
294 
297 
303  {
304  public:
306 
310  AWSJsonClient(const Aws::Client::ClientConfiguration& configuration,
311  const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer,
312  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
313 
317  AWSJsonClient(const Aws::Client::ClientConfiguration& configuration,
318  const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
319  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
320 
321  virtual ~AWSJsonClient() = default;
322 
323  protected:
327  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override;
328 
335  JsonOutcome MakeRequest(const Aws::Http::URI& uri,
336  const Aws::AmazonWebServiceRequest& request,
338  const char* signerName = Aws::Auth::SIGV4_SIGNER,
339  const char* signerRegionOverride = nullptr) const;
340 
350  JsonOutcome MakeRequest(const Aws::Http::URI& uri,
352  const char* signerName = Aws::Auth::SIGV4_SIGNER,
353  const char* requestName = "",
354  const char* signerRegionOverride = nullptr) const;
355 
356  JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const;
357  };
358 
360 
366  {
367  public:
368 
370 
371  AWSXMLClient(const Aws::Client::ClientConfiguration& configuration,
372  const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer,
373  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
374 
375  AWSXMLClient(const Aws::Client::ClientConfiguration& configuration,
376  const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
377  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
378 
379  virtual ~AWSXMLClient() = default;
380 
381  protected:
385  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override;
386 
393  XmlOutcome MakeRequest(const Aws::Http::URI& uri,
394  const Aws::AmazonWebServiceRequest& request,
396  const char* signerName = Aws::Auth::SIGV4_SIGNER,
397  const char* signerRegionOverride = nullptr) const;
398 
399 
409  XmlOutcome MakeRequest(const Aws::Http::URI& uri,
411  const char* signerName = Aws::Auth::SIGV4_SIGNER,
412  const char* requestName = "",
413  const char* signerRegionOverride = nullptr) const;
414 
418  XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri,
419  const Aws::AmazonWebServiceRequest& request,
421  const char* singerName = Aws::Auth::SIGV4_SIGNER,
422  const char* signerRegionOverride = nullptr) const;
423 
429  XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri,
431  const char* signerName = Aws::Auth::SIGV4_SIGNER,
432  const char* requestName = "",
433  const char* signerRegionOverride = nullptr) const;
434  };
435 
436  } // namespace Client
437 } // namespace Aws
Utils::Outcome< AmazonWebServiceResult< Utils::Stream::ResponseStream >, AWSError< CoreErrors > > StreamOutcome
Definition: AWSClient.h:80
AWS_CORE_API const char SIGV4_SIGNER[]
Definition: AWSClient.h:63
virtual const char * GetServiceClientName() const
Definition: AWSClient.h:158
Aws::Map< Aws::String, Aws::String > HeaderValueCollection
Definition: HttpTypes.h:53
AWS_CORE_API Aws::String GetAuthorizationHeader(const Aws::Http::HttpRequest &httpRequest)
const char *const name
Definition: cJSON.h:261
Utils::Outcome< AmazonWebServiceResult< Utils::Json::JsonValue >, AWSError< CoreErrors > > JsonOutcome
Definition: AWSClient.h:295
Aws::String m_region
Definition: AWSClient.h:268
Aws::MultiMap< Aws::String, Aws::String > QueryStringParameterCollection
Definition: URI.h:26
const std::shared_ptr< AWSErrorMarshaller > & GetErrorMarshaller() const
Definition: AWSClient.h:242
Utils::Outcome< std::shared_ptr< Aws::Http::HttpResponse >, AWSError< CoreErrors > > HttpResponseOutcome
Definition: AWSClient.h:77
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition: AWSString.h:97
Utils::Outcome< AmazonWebServiceResult< Utils::Xml::XmlDocument >, AWSError< CoreErrors > > XmlOutcome
Definition: AWSClient.h:359
AWS_CORE_API const char NULL_SIGNER[]
Definition: AWSClient.h:64
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25