stopCodeInterpreterSession method
Terminates an active code interpreter session in Amazon Bedrock AgentCore. This operation stops the session, releases associated resources, and makes the session unavailable for further use.
To stop a code interpreter session, you must specify both the code
interpreter identifier and the session ID. Once stopped, a session cannot
be restarted; you must create a new session using
StartCodeInterpreterSession.
The following operations are related to
StopCodeInterpreterSession:
May throw AccessDeniedException.
May throw ConflictException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter codeInterpreterIdentifier :
The unique identifier of the code interpreter associated with the session.
Parameter sessionId :
The unique identifier of the code interpreter session to stop.
Parameter clientToken :
A unique, case-sensitive identifier to ensure that the API request
completes no more than one time. If this token matches a previous request,
Amazon Bedrock AgentCore ignores the request, but does not return an
error.
Parameter traceId :
The trace identifier for request tracking.
Parameter traceParent :
The parent trace information for distributed tracing.
Implementation
Future<StopCodeInterpreterSessionResponse> stopCodeInterpreterSession({
required String codeInterpreterIdentifier,
required String sessionId,
String? clientToken,
String? traceId,
String? traceParent,
}) async {
final headers = <String, String>{
if (traceId != null) 'X-Amzn-Trace-Id': traceId.toString(),
if (traceParent != null) 'traceparent': traceParent.toString(),
};
final $query = <String, List<String>>{
'sessionId': [sessionId],
};
final $payload = <String, dynamic>{
'clientToken': clientToken ?? _s.generateIdempotencyToken(),
};
final response = await _protocol.send(
payload: $payload,
method: 'PUT',
requestUri:
'/code-interpreters/${Uri.encodeComponent(codeInterpreterIdentifier)}/sessions/stop',
queryParams: $query,
headers: headers,
exceptionFnMap: _exceptionFns,
);
return StopCodeInterpreterSessionResponse.fromJson(response);
}