|
| 1 | +import { |
| 2 | + GetAgentRuntimeCommand, |
| 3 | + GetAgentRuntimeEndpointCommand, |
| 4 | + ListAgentRuntimeEndpointsCommand, |
| 5 | + ListAgentRuntimesCommand, |
| 6 | + ListAgentRuntimeVersionsCommand, |
| 7 | + type GetAgentRuntimeEndpointResponse, |
| 8 | + type GetAgentRuntimeResponse, |
| 9 | + type ListAgentRuntimeEndpointsResponse, |
| 10 | + type ListAgentRuntimesResponse, |
| 11 | + type ListAgentRuntimeVersionsResponse, |
| 12 | +} from "@aws-sdk/client-bedrock-agentcore-control"; |
| 13 | +import type { CoreRuntimeClient } from "../handlers/runtime/types"; |
| 14 | +import type { AwsClients, CoreOptions } from "./types"; |
| 15 | +import { toClientConfig } from "./utils"; |
| 16 | + |
| 17 | +export class RuntimeClient implements CoreRuntimeClient { |
| 18 | + constructor(private readonly clients: AwsClients) {} |
| 19 | + |
| 20 | + async getRuntime(id: string, options: CoreOptions): Promise<GetAgentRuntimeResponse> { |
| 21 | + return this.clients |
| 22 | + .control(toClientConfig(options)) |
| 23 | + .send(new GetAgentRuntimeCommand({ agentRuntimeId: id })); |
| 24 | + } |
| 25 | + |
| 26 | + async getRuntimeVersion( |
| 27 | + id: string, |
| 28 | + version: string, |
| 29 | + options: CoreOptions, |
| 30 | + ): Promise<GetAgentRuntimeResponse> { |
| 31 | + return this.clients.control(toClientConfig(options)).send( |
| 32 | + new GetAgentRuntimeCommand({ |
| 33 | + agentRuntimeId: id, |
| 34 | + agentRuntimeVersion: version, |
| 35 | + }), |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + async getRuntimeEndpoint( |
| 40 | + id: string, |
| 41 | + qualifier: string, |
| 42 | + options: CoreOptions, |
| 43 | + ): Promise<GetAgentRuntimeEndpointResponse> { |
| 44 | + return this.clients.control(toClientConfig(options)).send( |
| 45 | + new GetAgentRuntimeEndpointCommand({ |
| 46 | + agentRuntimeId: id, |
| 47 | + endpointName: qualifier, |
| 48 | + }), |
| 49 | + ); |
| 50 | + } |
| 51 | + |
| 52 | + async listRuntimes( |
| 53 | + nextToken: string | undefined, |
| 54 | + maxResults: number | undefined, |
| 55 | + options: CoreOptions, |
| 56 | + ): Promise<ListAgentRuntimesResponse> { |
| 57 | + return this.clients |
| 58 | + .control(toClientConfig(options)) |
| 59 | + .send(new ListAgentRuntimesCommand({ nextToken, maxResults })); |
| 60 | + } |
| 61 | + |
| 62 | + async listRuntimeVersions( |
| 63 | + id: string, |
| 64 | + nextToken: string | undefined, |
| 65 | + maxResults: number | undefined, |
| 66 | + options: CoreOptions, |
| 67 | + ): Promise<ListAgentRuntimeVersionsResponse> { |
| 68 | + return this.clients.control(toClientConfig(options)).send( |
| 69 | + new ListAgentRuntimeVersionsCommand({ |
| 70 | + agentRuntimeId: id, |
| 71 | + nextToken, |
| 72 | + maxResults, |
| 73 | + }), |
| 74 | + ); |
| 75 | + } |
| 76 | + |
| 77 | + async listRuntimeEndpoints( |
| 78 | + id: string, |
| 79 | + nextToken: string | undefined, |
| 80 | + maxResults: number | undefined, |
| 81 | + options: CoreOptions, |
| 82 | + ): Promise<ListAgentRuntimeEndpointsResponse> { |
| 83 | + return this.clients.control(toClientConfig(options)).send( |
| 84 | + new ListAgentRuntimeEndpointsCommand({ |
| 85 | + agentRuntimeId: id, |
| 86 | + nextToken, |
| 87 | + maxResults, |
| 88 | + }), |
| 89 | + ); |
| 90 | + } |
| 91 | +} |
0 commit comments