forked from aws/agentcore-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgateway-status.ts
More file actions
45 lines (40 loc) · 1.27 KB
/
Copy pathgateway-status.ts
File metadata and controls
45 lines (40 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Query gateway target sync statuses after deployment.
*/
import { createControlClient } from '../../aws/agentcore-control';
import { ListGatewayTargetsCommand } from '@aws-sdk/client-bedrock-agentcore-control';
export interface TargetSyncStatus {
name: string;
status: string;
}
const STATUS_DISPLAY: Record<string, string> = {
READY: '✓ synced',
SYNCHRONIZING: '⟳ syncing...',
SYNCHRONIZE_UNSUCCESSFUL: '⚠ sync failed',
CREATING: '⟳ creating...',
UPDATING: '⟳ updating...',
UPDATE_UNSUCCESSFUL: '⚠ update failed',
FAILED: '✗ failed',
DELETING: '⟳ deleting...',
};
export function formatTargetStatus(status: string): string {
return STATUS_DISPLAY[status] ?? status;
}
/**
* Get sync statuses for all targets in a gateway.
* Returns empty array on error (non-blocking).
*/
export async function getGatewayTargetStatuses(gatewayId: string, region: string): Promise<TargetSyncStatus[]> {
try {
const client = createControlClient(region);
const response = await client.send(
new ListGatewayTargetsCommand({ gatewayIdentifier: gatewayId, maxResults: 100 })
);
return (response.items ?? []).map(target => ({
name: target.name ?? 'unknown',
status: target.status ?? 'UNKNOWN',
}));
} catch {
return [];
}
}