Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for string array ep context params #646

Merged
merged 5 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading