Skip to content

Commit

Permalink
Add support for string array ep context params (#646)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyMusatkin committed Aug 16, 2024
1 parent 52dea44 commit 64aa255
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/aws/crt/endpoints/RuleEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ByteCursor> &value);

/// @private
aws_endpoints_request_context *GetNativeHandle() const noexcept { return m_requestContext; }

Expand Down
6 changes: 6 additions & 0 deletions source/endpoints/RuleEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ByteCursor> &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
Expand Down
18 changes: 18 additions & 0 deletions tests/RuleEngineTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 64aa255

Please sign in to comment.