From 64aa255ea5b42ada86f75b5200dc6903dea8e493 Mon Sep 17 00:00:00 2001 From: Dmitriy Musatkin <63878209+DmitriyMusatkin@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:04:32 -0700 Subject: [PATCH] Add support for string array ep context params (#646) --- include/aws/crt/endpoints/RuleEngine.h | 7 +++++++ source/endpoints/RuleEngine.cpp | 6 ++++++ tests/RuleEngineTest.cpp | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/include/aws/crt/endpoints/RuleEngine.h b/include/aws/crt/endpoints/RuleEngine.h index 1472492c0..558b43b3e 100644 --- a/include/aws/crt/endpoints/RuleEngine.h +++ b/include/aws/crt/endpoints/RuleEngine.h @@ -53,6 +53,13 @@ namespace Aws */ bool AddBoolean(const ByteCursor &name, bool value); + /* + * Add string array parameter. + * True if added successfully and false if failed. + * Aws::Crt::LastError() can be used to retrieve failure error code. + */ + bool AddStringArray(const ByteCursor &name, const Vector &value); + /// @private aws_endpoints_request_context *GetNativeHandle() const noexcept { return m_requestContext; } diff --git a/source/endpoints/RuleEngine.cpp b/source/endpoints/RuleEngine.cpp index 681eb5267..906ccb787 100644 --- a/source/endpoints/RuleEngine.cpp +++ b/source/endpoints/RuleEngine.cpp @@ -37,6 +37,12 @@ namespace Aws aws_endpoints_request_context_add_boolean(m_allocator, m_requestContext, name, value); } + bool RequestContext::AddStringArray(const ByteCursor &name, const Vector &value) + { + return AWS_OP_SUCCESS != aws_endpoints_request_context_add_string_array( + m_allocator, m_requestContext, name, value.data(), value.size()); + } + ResolutionOutcome::ResolutionOutcome(aws_endpoints_resolved_endpoint *impl) : m_resolvedEndpoint(impl) {} ResolutionOutcome::ResolutionOutcome(ResolutionOutcome &&toMove) noexcept diff --git a/tests/RuleEngineTest.cpp b/tests/RuleEngineTest.cpp index 42cbf094a..7388029e4 100644 --- a/tests/RuleEngineTest.cpp +++ b/tests/RuleEngineTest.cpp @@ -173,3 +173,21 @@ static int s_TestRuleEngine(struct aws_allocator *allocator, void *ctx) } AWS_TEST_CASE(RuleEngine, s_TestRuleEngine) + +static int s_TestRuleEngineContextParams(struct aws_allocator *allocator, void *ctx) +{ + (void)ctx; + + Aws::Crt::ApiHandle apiHandle(allocator); + + Aws::Crt::Endpoints::RequestContext context(allocator); + context.AddString(ByteCursorFromCString("Region"), ByteCursorFromCString("us-west-2")); + context.AddBoolean(ByteCursorFromCString("AValidBoolParam"), false); + context.AddStringArray(ByteCursorFromCString("StringArray1"), {}); + context.AddStringArray( + ByteCursorFromCString("StringArray2"), {ByteCursorFromCString("a"), ByteCursorFromCString("b")}); + + return AWS_OP_SUCCESS; +} + +AWS_TEST_CASE(RuleEngineContextParams, s_TestRuleEngineContextParams) \ No newline at end of file