AWS SDK for C++  1.8.51
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 m_serviceName.c_str(); }
159  inline virtual void SetServiceClientName(const Aws::String& name) { m_serviceName = name; }
160 
161  protected:
166  HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri,
167  const Aws::AmazonWebServiceRequest& request,
168  Http::HttpMethod httpMethod,
169  const char* signerName,
170  const char* signerRegionOverride = nullptr) const;
171 
179  HttpResponseOutcome AttemptExhaustively(const Aws::Http::URI& uri,
180  Http::HttpMethod httpMethod,
181  const char* signerName,
182  const char* requestName = "",
183  const char* signerRegionOverride = nullptr) const;
184 
189  HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest,
190  const Aws::AmazonWebServiceRequest& request,
191  const char* signerName,
192  const char* signerRegionOverride = nullptr) const;
193 
201  HttpResponseOutcome AttemptOneRequest(const std::shared_ptr<Http::HttpRequest>& httpRequest,
202  const char* signerName,
203  const char* requestName = "",
204  const char* signerRegionOverride = nullptr) const;
205 
210  StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri,
211  const Aws::AmazonWebServiceRequest& request,
213  const char* signerName = Aws::Auth::SIGV4_SIGNER,
214  const char* signerRegionOverride = nullptr) const;
215 
223  StreamOutcome MakeRequestWithUnparsedResponse(const Aws::Http::URI& uri,
225  const char* signerName = Aws::Auth::SIGV4_SIGNER,
226  const char* requestName = "",
227  const char* signerRegionOverride = nullptr) const;
228 
232  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const = 0;
233 
237  virtual void BuildHttpRequest(const Aws::AmazonWebServiceRequest& request,
238  const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest) const;
239 
243  const std::shared_ptr<AWSErrorMarshaller>& GetErrorMarshaller() const
244  {
245  return m_errorMarshaller;
246  }
247 
251  Aws::Client::AWSAuthSigner* GetSignerByName(const char* name) const;
252  protected:
253 
261  std::shared_ptr<Aws::Http::HttpRequest> BuildAndSignHttpRequest(const Aws::Http::URI& uri,
262  const Aws::AmazonWebServiceRequest& request,
263  Http::HttpMethod method, const char* signerName) const;
264 
268  std::shared_ptr<Aws::Http::HttpResponse> MakeHttpRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const;
270  private:
275  bool AdjustClockSkew(HttpResponseOutcome& outcome, const char* signerName) const;
276  void AddHeadersToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const Http::HeaderValueCollection& headerValues) const;
277  void AddContentBodyToRequest(const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest, const std::shared_ptr<Aws::IOStream>& body,
278  bool needsContentMd5 = false, bool isChunked = false) const;
279  void AddCommonHeaders(Aws::Http::HttpRequest& httpRequest) const;
280  void InitializeGlobalStatics();
281  std::shared_ptr<Aws::Http::HttpRequest> ConvertToRequestForPresigning(const Aws::AmazonWebServiceRequest& request, Aws::Http::URI& uri,
282  Aws::Http::HttpMethod method, const Aws::Http::QueryStringParameterCollection& extraParams) const;
283 
284  std::shared_ptr<Aws::Http::HttpClient> m_httpClient;
285  std::shared_ptr<Aws::Auth::AWSAuthSignerProvider> m_signerProvider;
286  std::shared_ptr<AWSErrorMarshaller> m_errorMarshaller;
287  std::shared_ptr<RetryStrategy> m_retryStrategy;
288  std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> m_writeRateLimiter;
289  std::shared_ptr<Aws::Utils::RateLimits::RateLimiterInterface> m_readRateLimiter;
290  mutable Aws::String m_userAgent;
291  std::shared_ptr<Aws::Utils::Crypto::Hash> m_hash;
292  long m_requestTimeoutMs;
293  bool m_enableClockSkewAdjustment;
294  Aws::String m_serviceName;
295  };
296 
299 
305  {
306  public:
308 
312  AWSJsonClient(const Aws::Client::ClientConfiguration& configuration,
313  const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer,
314  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
315 
319  AWSJsonClient(const Aws::Client::ClientConfiguration& configuration,
320  const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
321  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
322 
323  virtual ~AWSJsonClient() = default;
324 
325  protected:
329  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override;
330 
337  JsonOutcome MakeRequest(const Aws::Http::URI& uri,
338  const Aws::AmazonWebServiceRequest& request,
340  const char* signerName = Aws::Auth::SIGV4_SIGNER,
341  const char* signerRegionOverride = nullptr) const;
342 
352  JsonOutcome MakeRequest(const Aws::Http::URI& uri,
354  const char* signerName = Aws::Auth::SIGV4_SIGNER,
355  const char* requestName = "",
356  const char* signerRegionOverride = nullptr) const;
357 
358  JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const;
359  };
360 
362 
368  {
369  public:
370 
372 
373  AWSXMLClient(const Aws::Client::ClientConfiguration& configuration,
374  const std::shared_ptr<Aws::Client::AWSAuthSigner>& signer,
375  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
376 
377  AWSXMLClient(const Aws::Client::ClientConfiguration& configuration,
378  const std::shared_ptr<Aws::Auth::AWSAuthSignerProvider>& signerProvider,
379  const std::shared_ptr<AWSErrorMarshaller>& errorMarshaller);
380 
381  virtual ~AWSXMLClient() = default;
382 
383  protected:
387  virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override;
388 
395  XmlOutcome MakeRequest(const Aws::Http::URI& uri,
396  const Aws::AmazonWebServiceRequest& request,
398  const char* signerName = Aws::Auth::SIGV4_SIGNER,
399  const char* signerRegionOverride = nullptr) const;
400 
401 
411  XmlOutcome MakeRequest(const Aws::Http::URI& uri,
413  const char* signerName = Aws::Auth::SIGV4_SIGNER,
414  const char* requestName = "",
415  const char* signerRegionOverride = nullptr) const;
416 
420  XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri,
421  const Aws::AmazonWebServiceRequest& request,
423  const char* singerName = Aws::Auth::SIGV4_SIGNER,
424  const char* signerRegionOverride = nullptr) const;
425 
431  XmlOutcome MakeRequestWithEventStream(const Aws::Http::URI& uri,
433  const char* signerName = Aws::Auth::SIGV4_SIGNER,
434  const char* requestName = "",
435  const char* signerRegionOverride = nullptr) const;
436  };
437 
438  } // namespace Client
439 } // 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:262
Utils::Outcome< AmazonWebServiceResult< Utils::Json::JsonValue >, AWSError< CoreErrors > > JsonOutcome
Definition: AWSClient.h:297
Aws::String m_region
Definition: AWSClient.h:269
Aws::MultiMap< Aws::String, Aws::String > QueryStringParameterCollection
Definition: URI.h:26
const std::shared_ptr< AWSErrorMarshaller > & GetErrorMarshaller() const
Definition: AWSClient.h:243
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
virtual void SetServiceClientName(const Aws::String &name)
Definition: AWSClient.h:159
Utils::Outcome< AmazonWebServiceResult< Utils::Xml::XmlDocument >, AWSError< CoreErrors > > XmlOutcome
Definition: AWSClient.h:361
AWS_CORE_API const char NULL_SIGNER[]
Definition: AWSClient.h:64
#define AWS_CORE_API
Definition: Core_EXPORTS.h:25