Skip to content

Commit ea08340

Browse files
authored
Initial implementation of AWSRpcV2CborClient (#3515)
* Initial implementation of AWSRpcV2CborClient * AWSRpcV2CborClient - Remove unused import and use correct allocation tags * Refactor AWSJsonClient and AWSRpcV2CborClient to use a common template (AWSProtocolClient) * Include default values for all MakeRequest overloads in AWSProtocolClient * AWSJsonClient.cpp include full namepsace for Aws::Utils::JsonValue * AWSProtocolClient move BuildAWSError function into template class * Add CborValue class for AWSRpcV2CborClient. Refactor template AWSProtocolClient with new changes. * CborValue - Follow rule of 5 and change m_decoder to std::shared_ptr * CborValue - Update move constructors to create a new decoder each time * CborValue - Add noexcept to move constructor and operator
1 parent 81be549 commit ea08340

File tree

9 files changed

+489
-267
lines changed

9 files changed

+489
-267
lines changed

src/aws-cpp-sdk-core/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ file(GLOB UTILS_EVENT_HEADERS "include/aws/core/utils/event/*.h")
6262
file(GLOB UTILS_BASE64_HEADERS "include/aws/core/utils/base64/*.h")
6363
file(GLOB UTILS_CRYPTO_HEADERS "include/aws/core/utils/crypto/*.h")
6464
file(GLOB UTILS_JSON_HEADERS "include/aws/core/utils/json/*.h")
65+
file(GLOB UTILS_CBOR_HEADERS "include/aws/core/utils/cbor/*.h")
6566
file(GLOB UTILS_THREADING_HEADERS "include/aws/core/utils/threading/*.h")
6667
file(GLOB UTILS_XML_HEADERS "include/aws/core/utils/xml/*.h")
6768
file(GLOB UTILS_MEMORY_HEADERS "include/aws/core/utils/memory/*.h")
@@ -115,6 +116,7 @@ file(GLOB UTILS_EVENT_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/event/*.c
115116
file(GLOB UTILS_BASE64_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/base64/*.cpp")
116117
file(GLOB UTILS_CRYPTO_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/crypto/*.cpp")
117118
file(GLOB UTILS_JSON_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/json/*.cpp")
119+
file(GLOB UTILS_CBOR_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/cbor/*.cpp")
118120
file(GLOB UTILS_THREADING_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/threading/*.cpp")
119121
file(GLOB UTILS_XML_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/xml/*.cpp")
120122
file(GLOB UTILS_LOGGING_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/utils/logging/*.cpp")
@@ -268,6 +270,7 @@ file(GLOB AWS_NATIVE_SDK_COMMON_HEADERS
268270
${UTILS_BASE64_HEADERS}
269271
${UTILS_CRYPTO_HEADERS}
270272
${UTILS_JSON_HEADERS}
273+
${UTILS_CBOR_HEADERS}
271274
${UTILS_THREADING_HEADERS}
272275
${UTILS_RETRY_HEADERS}
273276
${UTILS_XML_HEADERS}
@@ -348,6 +351,7 @@ file(GLOB AWS_NATIVE_SDK_NON_UNITY_SRC
348351
${MONITORING_SOURCE}
349352
${UTILS_CRYPTO_FACTORY_SOURCE}
350353
${UTILS_JSON_SOURCE}
354+
${UTILS_CBOR_SOURCE}
351355
${UTILS_EVENT_SOURCE}
352356
${UTILS_SOURCE}
353357
${NET_SOURCE}
@@ -406,6 +410,7 @@ if(MSVC)
406410
source_group("Header Files\\aws\\core\\utils\\event" FILES ${UTILS_EVENT_HEADERS})
407411
source_group("Header Files\\aws\\core\\utils\\exceptions" FILES ${UTILS_EXCEPTIONS_HEADERS})
408412
source_group("Header Files\\aws\\core\\utils\\json" FILES ${UTILS_JSON_HEADERS})
413+
source_group("Header Files\\aws\\core\\utils\\cbor" FILES ${UTILS_CBOR_HEADERS})
409414
source_group("Header Files\\aws\\core\\utils\\threading" FILES ${UTILS_THREADING_HEADERS})
410415
source_group("Header Files\\aws\\core\\utils\\xml" FILES ${UTILS_XML_HEADERS})
411416
source_group("Header Files\\aws\\core\\utils\\logging" FILES ${UTILS_LOGGING_HEADERS})
@@ -473,6 +478,7 @@ if(MSVC)
473478
source_group("Source Files\\utils\\event" FILES ${UTILS_EVENT_SOURCE})
474479
source_group("Source Files\\utils\\exceptions" FILES ${UTILS_EXCEPTIONS_SOURCE})
475480
source_group("Source Files\\utils\\json" FILES ${UTILS_JSON_SOURCE})
481+
source_group("Source Files\\utils\\cbor" FILES ${UTILS_CBOR_SOURCE})
476482
source_group("Source Files\\utils\\threading" FILES ${UTILS_THREADING_SOURCE})
477483
source_group("Source Files\\utils\\xml" FILES ${UTILS_XML_SOURCE})
478484
source_group("Source Files\\utils\\stream" FILES ${UTILS_STREAM_SOURCE})
@@ -684,6 +690,7 @@ install (FILES ${UTILS_EVENT_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/
684690
install (FILES ${UTILS_BASE64_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/base64)
685691
install (FILES ${UTILS_CRYPTO_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/crypto)
686692
install (FILES ${UTILS_JSON_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/json)
693+
install (FILES ${UTILS_CBOR_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/cbor)
687694
install (FILES ${UTILS_RETRY_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/retry)
688695
install (FILES ${UTILS_XML_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/xml)
689696
install (FILES ${UTILS_LOGGING_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/utils/logging)

src/aws-cpp-sdk-core/include/aws/core/client/AWSClient.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,10 @@ namespace Aws
369369
} // namespace Client
370370
} // namespace Aws
371371

372-
#if !defined(AWS_JSON_CLIENT_H) && !defined(AWS_XML_CLIENT_H)
372+
#if !defined(AWS_JSON_CLIENT_H) && !defined(AWS_XML_CLIENT_H) && !defined(AWS_CBOR_CLIENT_H)
373373
/* Legacy backward compatibility macros to not break the build for ones including just AWSClient.h */
374374
#include <aws/core/client/AWSJsonClient.h>
375+
#include <aws/core/client/AWSRpcV2CborClient.h>
375376
#include <aws/core/client/AWSXmlClient.h>
376-
#endif // !defined(AWS_JSON_CLIENT_H) && !defined(AWS_XML_CLIENT_H)
377+
#endif // !defined(AWS_JSON_CLIENT_H) && !defined(AWS_XML_CLIENT_H) && !defined(AWS_CBOR_CLIENT_H)
377378
#endif // !defined(AWS_CLIENT_H)

src/aws-cpp-sdk-core/include/aws/core/client/AWSJsonClient.h

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define AWS_JSON_CLIENT_H
99

1010
#include <aws/core/Core_EXPORTS.h>
11-
#include <aws/core/client/AWSClient.h>
11+
#include <aws/core/client/AWSProtocolClient.h>
1212

1313
namespace Aws
1414
{
@@ -31,10 +31,10 @@ namespace Aws
3131
* AWSClient that handles marshalling json response bodies. You would inherit from this class
3232
* to create a client that uses Json as its payload format.
3333
*/
34-
class AWS_CORE_API AWSJsonClient : public AWSClient
34+
class AWS_CORE_API AWSJsonClient : public AWSProtocolClient<JsonOutcome, Utils::Json::JsonValue>
3535
{
3636
public:
37-
typedef AWSClient BASECLASS;
37+
typedef AWSProtocolClient<JsonOutcome, Utils::Json::JsonValue> BASECLASS;
3838

3939
/**
4040
* Simply calls AWSClient constructor.
@@ -55,60 +55,10 @@ namespace Aws
5555
protected:
5656
template <typename OutcomeT, typename ClientT, typename AWSEndpointT, typename RequestT, typename HandlerT>
5757
friend class BidirectionalEventStreamingTask; // allow BidirectionalEventStreamingTask to MakeRequests
58-
/**
59-
* Converts/Parses an http response into a meaningful AWSError object using the json message structure.
60-
*/
61-
virtual AWSError<CoreErrors> BuildAWSError(const std::shared_ptr<Aws::Http::HttpResponse>& response) const override;
62-
63-
/**
64-
* Returns a Json document or an error from the request. Does some marshalling json and raw streams,
65-
* then just calls AttemptExhaustively.
66-
*
67-
* method defaults to POST
68-
*/
69-
JsonOutcome MakeRequest(const Aws::AmazonWebServiceRequest& request,
70-
const Aws::Endpoint::AWSEndpoint& endpoint,
71-
Http::HttpMethod method = Http::HttpMethod::HTTP_POST,
72-
const char* signerName = Aws::Auth::SIGV4_SIGNER,
73-
const char* signerRegionOverride = nullptr,
74-
const char* signerServiceNameOverride = nullptr) const;
75-
76-
JsonOutcome MakeRequest(const Aws::Endpoint::AWSEndpoint& endpoint,
77-
Http::HttpMethod method = Http::HttpMethod::HTTP_POST,
78-
const char* signerName = Aws::Auth::SIGV4_SIGNER,
79-
const char* signerRegionOverride = nullptr,
80-
const char* signerServiceNameOverride = nullptr) const;
81-
82-
/**
83-
* Returns a Json document or an error from the request. Does some marshalling json and raw streams,
84-
* then just calls AttemptExhaustively.
85-
*
86-
* method defaults to POST
87-
*/
88-
JsonOutcome MakeRequest(const Aws::Http::URI& uri,
89-
const Aws::AmazonWebServiceRequest& request,
90-
Http::HttpMethod method = Http::HttpMethod::HTTP_POST,
91-
const char* signerName = Aws::Auth::SIGV4_SIGNER,
92-
const char* signerRegionOverride = nullptr,
93-
const char* signerServiceNameOverride = nullptr) const;
94-
95-
/**
96-
* Returns a Json document or an error from the request. Does some marshalling json and raw streams,
97-
* then just calls AttemptExhaustively.
98-
*
99-
* requestName is used for metrics and defaults to empty string, to avoid empty names in metrics provide a valid
100-
* name.
101-
*
102-
* method defaults to POST
103-
*/
104-
JsonOutcome MakeRequest(const Aws::Http::URI& uri,
105-
Http::HttpMethod method = Http::HttpMethod::HTTP_POST,
106-
const char* signerName = Aws::Auth::SIGV4_SIGNER,
107-
const char* requestName = "",
108-
const char* signerRegionOverride = nullptr,
109-
const char* signerServiceNameOverride = nullptr) const;
11058

111-
JsonOutcome MakeEventStreamRequest(std::shared_ptr<Aws::Http::HttpRequest>& request) const;
59+
private:
60+
AWSError<CoreErrors> CreateParseError() const override;
61+
const char* GetClientLogTag() const override;
11262
};
11363
} // namespace Client
11464
} // namespace Aws

0 commit comments

Comments
 (0)