Skip to content

Commit 64aa255

Browse files
Add support for string array ep context params (#646)
1 parent 52dea44 commit 64aa255

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

include/aws/crt/endpoints/RuleEngine.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ namespace Aws
5353
*/
5454
bool AddBoolean(const ByteCursor &name, bool value);
5555

56+
/*
57+
* Add string array parameter.
58+
* True if added successfully and false if failed.
59+
* Aws::Crt::LastError() can be used to retrieve failure error code.
60+
*/
61+
bool AddStringArray(const ByteCursor &name, const Vector<ByteCursor> &value);
62+
5663
/// @private
5764
aws_endpoints_request_context *GetNativeHandle() const noexcept { return m_requestContext; }
5865

source/endpoints/RuleEngine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ namespace Aws
3737
aws_endpoints_request_context_add_boolean(m_allocator, m_requestContext, name, value);
3838
}
3939

40+
bool RequestContext::AddStringArray(const ByteCursor &name, const Vector<ByteCursor> &value)
41+
{
42+
return AWS_OP_SUCCESS != aws_endpoints_request_context_add_string_array(
43+
m_allocator, m_requestContext, name, value.data(), value.size());
44+
}
45+
4046
ResolutionOutcome::ResolutionOutcome(aws_endpoints_resolved_endpoint *impl) : m_resolvedEndpoint(impl) {}
4147

4248
ResolutionOutcome::ResolutionOutcome(ResolutionOutcome &&toMove) noexcept

tests/RuleEngineTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,3 +173,21 @@ static int s_TestRuleEngine(struct aws_allocator *allocator, void *ctx)
173173
}
174174

175175
AWS_TEST_CASE(RuleEngine, s_TestRuleEngine)
176+
177+
static int s_TestRuleEngineContextParams(struct aws_allocator *allocator, void *ctx)
178+
{
179+
(void)ctx;
180+
181+
Aws::Crt::ApiHandle apiHandle(allocator);
182+
183+
Aws::Crt::Endpoints::RequestContext context(allocator);
184+
context.AddString(ByteCursorFromCString("Region"), ByteCursorFromCString("us-west-2"));
185+
context.AddBoolean(ByteCursorFromCString("AValidBoolParam"), false);
186+
context.AddStringArray(ByteCursorFromCString("StringArray1"), {});
187+
context.AddStringArray(
188+
ByteCursorFromCString("StringArray2"), {ByteCursorFromCString("a"), ByteCursorFromCString("b")});
189+
190+
return AWS_OP_SUCCESS;
191+
}
192+
193+
AWS_TEST_CASE(RuleEngineContextParams, s_TestRuleEngineContextParams)

0 commit comments

Comments
 (0)