Skip to content

Commit 9d63f5b

Browse files
authored
feat(gateway): add delete commands (#1901)
* feat(gateway): add delete commands * feat(gateway): complete delete command surface * test(gateway): record delete fixtures with e2e profile * test(gateway): clean up partial delete fixtures * test(gateway): inject logs client in delete fixtures
1 parent 25d59fb commit 9d63f5b

24 files changed

Lines changed: 916 additions & 3 deletions

src/core/gateway.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { describe, expect, mock, test } from "bun:test";
22
import {
3+
DeleteGatewayCommand,
4+
DeleteGatewayRuleCommand,
5+
DeleteGatewayTargetCommand,
36
GetGatewayCommand,
47
GetGatewayTargetCommand,
58
ListGatewayTargetsCommand,
@@ -269,6 +272,30 @@ function target(): GetGatewayTargetResponse {
269272
} as unknown as GetGatewayTargetResponse;
270273
}
271274

275+
test("maps Gateway, Target, and Rule selectors to their delete commands", async () => {
276+
const { client, commands } = recordingGatewayClient([{}, {}, {}]);
277+
278+
await client.deleteGateway("gateway-1", OPTIONS);
279+
await client.deleteGatewayTarget("gateway-1", "target-1", OPTIONS);
280+
await client.deleteGatewayRule("gateway-1", "rule-1", OPTIONS);
281+
282+
expect(commands).toHaveLength(3);
283+
expect(commands[0]).toBeInstanceOf(DeleteGatewayCommand);
284+
expect((commands[0] as DeleteGatewayCommand).input).toEqual({
285+
gatewayIdentifier: "gateway-1",
286+
});
287+
expect(commands[1]).toBeInstanceOf(DeleteGatewayTargetCommand);
288+
expect((commands[1] as DeleteGatewayTargetCommand).input).toEqual({
289+
gatewayIdentifier: "gateway-1",
290+
targetId: "target-1",
291+
});
292+
expect(commands[2]).toBeInstanceOf(DeleteGatewayRuleCommand);
293+
expect((commands[2] as DeleteGatewayRuleCommand).input).toEqual({
294+
gatewayIdentifier: "gateway-1",
295+
ruleId: "rule-1",
296+
});
297+
});
298+
272299
function recordingGatewayClient(responses: unknown[]): {
273300
client: GatewayClient;
274301
commands: unknown[];

src/core/gateway.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import {
22
CreateGatewayCommand,
33
CreateGatewayRuleCommand,
44
CreateGatewayTargetCommand,
5+
DeleteGatewayCommand,
6+
DeleteGatewayRuleCommand,
7+
DeleteGatewayTargetCommand,
58
GetGatewayCommand,
69
GetGatewayRuleCommand,
710
GetGatewayTargetCommand,
@@ -15,6 +18,9 @@ import {
1518
type CreateGatewayResponse,
1619
type CreateGatewayRuleResponse,
1720
type CreateGatewayTargetResponse,
21+
type DeleteGatewayResponse,
22+
type DeleteGatewayRuleResponse,
23+
type DeleteGatewayTargetResponse,
1824
type GetGatewayResponse,
1925
type GetGatewayRuleResponse,
2026
type GetGatewayTargetResponse,
@@ -155,6 +161,12 @@ export class GatewayClient implements CoreGatewayClient {
155161
.send(new ListGatewaysCommand({ nextToken, maxResults }));
156162
}
157163

164+
async deleteGateway(id: string, options: CoreOptions): Promise<DeleteGatewayResponse> {
165+
return this.clients
166+
.control(toClientConfig(options))
167+
.send(new DeleteGatewayCommand({ gatewayIdentifier: id }));
168+
}
169+
158170
async getGatewayTarget(
159171
gatewayId: string,
160172
targetId: string,
@@ -255,6 +267,19 @@ export class GatewayClient implements CoreGatewayClient {
255267
return this.updateTarget(patch, options, true);
256268
}
257269

270+
async deleteGatewayTarget(
271+
gatewayId: string,
272+
targetId: string,
273+
options: CoreOptions,
274+
): Promise<DeleteGatewayTargetResponse> {
275+
return this.clients.control(toClientConfig(options)).send(
276+
new DeleteGatewayTargetCommand({
277+
gatewayIdentifier: gatewayId,
278+
targetId,
279+
}),
280+
);
281+
}
282+
258283
async getGatewayRule(
259284
gatewayId: string,
260285
ruleId: string,
@@ -297,6 +322,19 @@ export class GatewayClient implements CoreGatewayClient {
297322
return this.clients.control(toClientConfig(options)).send(new UpdateGatewayRuleCommand(input));
298323
}
299324

325+
async deleteGatewayRule(
326+
gatewayId: string,
327+
ruleId: string,
328+
options: CoreOptions,
329+
): Promise<DeleteGatewayRuleResponse> {
330+
return this.clients.control(toClientConfig(options)).send(
331+
new DeleteGatewayRuleCommand({
332+
gatewayIdentifier: gatewayId,
333+
ruleId,
334+
}),
335+
);
336+
}
337+
300338
private async updateTarget(
301339
patch: GatewayTargetUpdatePatch,
302340
options: CoreOptions,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"gatewayId": "agentcore-cli-gateway-delete-fixture-oiemu02wfc",
3+
"status": "DELETING"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ruleId": "80e073e4-eb05-4371-8e6a-f4bde522699c",
3+
"status": "DELETING"
4+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"gatewayArn": "arn:aws:bedrock-agentcore:us-east-1:685197708687:gateway/agentcore-cli-gateway-delete-fixture-oiemu02wfc",
3+
"targetId": "U9OM2R9I8Q",
4+
"status": "DELETING"
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"gatewayArn": "arn:aws:bedrock-agentcore:us-east-1:685197708687:gateway/agentcore-cli-gateway-delete-fixture-oiemu02wfc",
3+
"targetId": "JYNNGDZ42F",
4+
"status": "DELETING"
5+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"gatewayArn": "arn:aws:bedrock-agentcore:us-east-1:685197708687:gateway/agentcore-cli-gateway-delete-fixture-oiemu02wfc",
3+
"targetId": "U9OM2R9I8Q",
4+
"createdAt": {
5+
"$date": "2026-08-07T17:54:45.522Z"
6+
},
7+
"updatedAt": {
8+
"$date": "2026-08-07T17:54:46.453Z"
9+
},
10+
"status": "READY",
11+
"name": "web-search-delete-fixture",
12+
"targetConfiguration": {
13+
"mcp": {
14+
"connector": {
15+
"source": {
16+
"connectorId": "web-search"
17+
},
18+
"configurations": [
19+
{
20+
"name": "WebSearch",
21+
"parameterValues": {
22+
"maxResults": 10
23+
}
24+
}
25+
]
26+
}
27+
}
28+
},
29+
"credentialProviderConfigurations": [
30+
{
31+
"credentialProviderType": "GATEWAY_IAM_ROLE"
32+
}
33+
]
34+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"gatewayArn": "arn:aws:bedrock-agentcore:us-east-1:685197708687:gateway/agentcore-cli-gateway-delete-fixture-oiemu02wfc",
3+
"targetId": "U9OM2R9I8Q",
4+
"status": "DELETING"
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"gatewayId": "agentcore-cli-gateway-delete-fixture-oiemu02wfc",
3+
"status": "DELETING"
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"gatewayId": "agentcore-cli-gateway-delete-fixture-oiemu02wfc",
3+
"gatewayArn": "arn:aws:bedrock-agentcore:us-east-1:685197708687:gateway/agentcore-cli-gateway-delete-fixture-oiemu02wfc",
4+
"targetId": "JYNNGDZ42F",
5+
"connectorId": "U9OM2R9I8Q",
6+
"ruleId": "80e073e4-eb05-4371-8e6a-f4bde522699c"
7+
}

0 commit comments

Comments
 (0)