Skip to content

feat: add gateway client and tests#428

Merged
nborges-aws merged 5 commits into
mainfrom
feat/gatewayClient
Apr 27, 2026
Merged

feat: add gateway client and tests#428
nborges-aws merged 5 commits into
mainfrom
feat/gatewayClient

Conversation

@nborges-aws

Copy link
Copy Markdown
Contributor

Issue #, if available: Issue #390

Description of changes:

  • Add GatewayClient with __getattr__ passthrough
  • Control plane allowlisted methods (16):
    • Gateway CRUD: create_gateway, get_gateway, list_gateways, update_gateway, delete_gateway
    • Gateway target CRUD: create_gateway_target, get_gateway_target, list_gateway_targets, update_gateway_target, delete_gateway_target
    • Gateway rules: create_gateway_rule, get_gateway_rule, list_gateway_rules, update_gateway_rule, delete_gateway_rule
    • Other: synchronize_gateway_targets
  • Add *_and_wait polling methods using shared wait_until/wait_until_deleted utilities:
    • create_gateway_and_wait, update_gateway_and_wait, delete_gateway_and_wait
    • create_gateway_target_and_wait, update_gateway_target_and_wait, delete_gateway_target_and_wait
  • Add name-based lookup methods with per-page pagination and early termination:
    • get_gateway_by_name — paginates through gateways, returns full details on first match
    • get_gateway_target_by_name — paginates through targets for a given gateway, returns full details on first match
  • All *_and_wait methods accept WaitConfig for configurable polling behavior and apply convert_kwargs for snake_case support

Test Plan:

  • Unit tests (11 total, all passing):
    • Init: region, region fallback
    • Passthrough: CP forwarding, snake_case conversion, AttributeError on unknown method
    • Wait methods: create gateway, create gateway failed, create target, delete gateway
    • Name lookup: found, not found
  • Integration tests (15 total):
    • Gateway CRUD lifecycle: create+wait → get (camelCase + snake_case) → name lookup (found + not found) → list → update+wait → delete+wait
    • Target CRUD lifecycle: create+wait → get → name lookup (found + not found) → list → update+wait → delete+wait

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@nborges-aws nborges-aws requested a review from a team April 23, 2026 16:24
@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

✅ No Breaking Changes Detected

No public API breaking changes found in this PR.

@Hweinstock Hweinstock left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Small qs about integ tests.

cls.region = os.environ.get("BEDROCK_TEST_REGION", "us-west-2")
cls.role_arn = os.environ.get("GATEWAY_ROLE_ARN")
if not cls.role_arn:
pytest.skip("GATEWAY_ROLE_ARN not set")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this lead to tests being silently skipped or would the CI action still fail?

authorizerType="NONE",
description="updated by integ test",
)
assert updated["status"] == "READY"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we assert that the gateway was actually updated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep I'll add same assertion that i did for policy to make sure its actually updated

Comment thread src/bedrock_agentcore/gateway/client.py Outdated
)
if not response.get("nextToken"):
return None
kwargs["nextToken"] = response["nextToken"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two questions:

  • why would a user pass in nextToken?
  • should we use a local variable instead to avoid mutating the parameters?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Popping the nextToken was just a defensive guard to make sure if the user passed in a nextToken, it does not conflict with our internal pagination. Maybe not necessary but cheap and harmless imo
  • Good catch. I've changed this to a local var



@pytest.mark.integration
class TestGatewayClient:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could we add one more get_gateway_target_by_name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's tests for get_gateway_target_by_name in the TestGatewayTargetClient class down below. Is there a specific case that you were thinking of missing?

Hweinstock
Hweinstock previously approved these changes Apr 24, 2026
nborges-aws and others added 5 commits April 27, 2026 13:50
get_gateway_target returns AccessDeniedException when called with a
gateway ARN. Extract the gateway ID from the ARN for all target
_and_wait polling methods. Also add missing credentialProviderConfigurations
to the update_gateway_target integ test.
@nborges-aws nborges-aws merged commit 61677ba into main Apr 27, 2026
30 of 31 checks passed
@nborges-aws nborges-aws deleted the feat/gatewayClient branch April 27, 2026 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants