AWS SDK for C++  1.8.98
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 
142  Aws::String GeneratePresignedUrl(Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName, const Aws::Http::HeaderValueCollection& customizedHeaders, long long expirationInSeconds = 0);
143 
144  Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method,
145  const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const;
146 
147  Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region, const char* serviceName,
148  const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const;
149 
150  Aws::String GeneratePresignedUrl(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri, Aws::Http::HttpMethod method, const char* region,
151  const Aws::Http::QueryStringParameterCollection& extraParams = Aws::Http::QueryStringParameterCollection(), long long expirationInSeconds = 0) const;
152 
157  void DisableRequestProcessing();
158 
162  void EnableRequestProcessing();
163 
164  inline virtual const char* GetServiceClientName() const { return m_serviceName.c_str(); }
170  virtual void SetServiceClientName(const Aws::String& name);
171 
172  protected:
177  HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri,
178  const Aws::AmazonWebServiceRequest& request,
179  Http::HttpMethod httpMethod,
180  const char* signerName,
181  const char* signerRegionOverride = nullptr,
182  const char* signerServiceNameOverride = nullptr) const;
183 
191  HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri,
192  Http::HttpMethod httpMethod,
193  const char* signerName,
194  const char* requestName = "",
195  const char* signerRegionOverride = nullptr,
196  const char* signerServiceNameOverride = nullptr) const;
197 
202  HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest,
203  const Aws::AmazonWebServiceRequest& request,
204  const char* signerName,
205  const char* signerRegionOverride = nullptr,
206  const char* signerServiceNameOverride = nullptr) const;
207 
215  HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest,
216  const char* signerName,
217  const char* requestName = "",
218  const char* signerRegionOverride = nullptr,
219  const char* signerServiceNameOverride = nullptr) const;
220 
225  StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri,
226  const Aws::AmazonWebServiceRequest& request,
228  const char* signerName = Aws::Auth::SIGV4_SIGNER,
229  const char* signerRegionOverride = nullptr,
230  const char* signerServiceNameOverride = nullptr) const;
231 
239  StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri,
241  const char* signerName = Aws::Auth::SIGV4_SIGNER,
242  const char* requestName = "",
243  const char* signerRegionOverride = nullptr,
244  const char* signerServiceNameOverride = nullptr) const;
245 
249  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const = 0;
250 
254  virtual void BuildHttpRequest(const Aws::AmazonWebServiceRequest& request,
255  const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest) const;
256 
260  const std::shared_ptr<AWSErrorMarshaller>& GetErrorMarshaller() const
261  {
262  return m_errorMarshaller;
263  }
264 
268  Aws::Client::AWSAuthSigner* GetSignerByName(const char* name) const;
269  protected:
270 
278  std::shared_ptr<Aws::Http::HttpRequest> BuildAndSignHttpRequest(const Aws::Http::URI& uri,
279  const Aws::AmazonWebServiceRequest& request,
280  Http::HttpMethod method, const char* signerName) const;
281 
285  std::shared_ptr<Aws::Http::HttpResponse> MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const;
287  private:
292  bool AdjustClockSkew(HttpResponseOutcome& outcome, const char* signerName) const;
293  void AddHeadersToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const Http::HeaderValueCollection& headerValues) const;
294  void AddContentBodyToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const std::shared_ptr<Aws::IOStream>& body,
295  bool needsContentMd5 = false, bool isChunked = false) const;
296  void AddCommonHeaders(Aws::Http::HttpRequest& httpRequest) const;
297  void InitializeGlobalStatics();
298  std::shared_ptr<Aws::Http::HttpRequest> ConvertToRequestForPresigning(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri,
299  Aws::Http::HttpMethod method, const Aws::Http::QueryStringParameterCollection& extraParams) const;
300 
301  std::shared_ptr<Aws::Http::HttpClient> m_httpClient;
302  std::shared_ptr<Aws::Auth::AWSAuthSignerProvider> m_signerProvider;
303  std::shared_ptr<AWSErrorMarshaller> m_errorMarshaller;
304  std::shared_ptr<RetryStrategy> m_retryStrategy;
305  std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> m_writeRateLimiter;
306  std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> m_readRateLimiter;
307  Aws::String m_userAgent;
308  bool m_customizedUserAgent;
309  std::shared_ptr<Aws::Utils::Crypto::Hash> m_hash;
310  long m_requestTimeoutMs;
311  bool m_enableClockSkewAdjustment;
312  Aws::String m_serviceName;
313  };
314 
317 
323  {
324  public:
326 
330  AWSJsonClient(const Aws::Client::ClientConfiguration& configuration,
331  const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer,
332  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
333 
337  AWSJsonClient(const Aws::Client::ClientConfiguration& configuration,
338  const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
339  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
340 
341  virtual ~AWSJsonClient() = default;
342 
343  protected:
347  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override;
348 
355  JsonOutcome MakeRequest(const Aws::Http::URI& uri,
356  const Aws::AmazonWebServiceRequest& request,
358  const char* signerName = Aws::Auth::SIGV4_SIGNER,
359  const char* signerRegionOverride = nullptr,
360  const char* signerServiceNameOverride = nullptr) const;
361 
371  JsonOutcome MakeRequest(const Aws::Http::URI& uri,
373  const char* signerName = Aws::Auth::SIGV4_SIGNER,
374  const char* requestName = "",
375  const char* signerRegionOverride = nullptr,
376  const char* signerServiceNameOverride = nullptr) const;
377 
378  JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const;
379  };
380 
382 
388  {
389  public:
390 
392 
393  AWSXMLClient(const Aws::Client::ClientConfiguration& configuration,
394  const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer,
395  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
396 
397  AWSXMLClient(const Aws::Client::ClientConfiguration& configuration,
398  const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
399  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
400 
401  virtual ~AWSXMLClient() = default;
402 
403  protected:
407  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override;
408 
415  XmlOutcome MakeRequest(const Aws::Http::URI& uri,
416  const Aws::AmazonWebServiceRequest& request,
418  const char* signerName = Aws::Auth::SIGV4_SIGNER,
419  const char* signerRegionOverride = nullptr,
420  const char* signerServiceNameOverride = nullptr) const;
421 
422 
432  XmlOutcome MakeRequest(const Aws::Http::URI& uri,
434  const char* signerName = Aws::Auth::SIGV4_SIGNER,
435  const char* requestName = "",
436  const char* signerRegionOverride = nullptr,
437  const char* signerServiceNameOverride = nullptr) const;
438 
442  XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri,
443  const Aws::AmazonWebServiceRequest& request,
445  const char* singerName = Aws::Auth::SIGV4_SIGNER,
446  const char* signerRegionOverride = nullptr,
447  const char* signerServiceNameOverride = nullptr) const;
448 
454  XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri,
456  const char* signerName = Aws::Auth::SIGV4_SIGNER,
457  const char* requestName = "",
458  const char* signerRegionOverride = nullptr,
459  const char* signerServiceNameOverride = nullptr) const;
460  };
461 
462  } // namespace Client
463 } // 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:164
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:262
Utils::Outcome< AmazonWebServiceResult< Utils::Json::JsonValue >, AWSError< CoreErrors > > JsonOutcome
Definition: AWSClient.h:315
Aws::String m_region
Definition: AWSClient.h:286
Aws::MultiMap< Aws::String, Aws::String > QueryStringParameterCollection
Definition: URI.h:26
const std::shared_ptr< AWSErrorMarshaller > & GetErrorMarshaller() const
Definition: AWSClient.h:260
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:381
AWS_CORE_API const char NULL_SIGNER[]
Definition: AWSClient.h:64
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25