stopRuntimeSession method

Future<StopRuntimeSessionResponse> stopRuntimeSession({
  1. required String agentRuntimeArn,
  2. required String runtimeSessionId,
  3. String? clientToken,
  4. String? qualifier,
})

Stops a session that is running in an running AgentCore Runtime agent.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw RetryableConflictException. May throw RuntimeClientError. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw UnauthorizedException. May throw ValidationException.

Parameter agentRuntimeArn : The ARN of the agent that contains the session that you want to stop.

Parameter runtimeSessionId : The ID of the session that you want to stop.

Parameter clientToken : Idempotent token used to identify the request. If you use the same token with multiple requests, the same response is returned. Use ClientToken to prevent the same request from being processed more than once.

Parameter qualifier : Optional qualifier to specify an agent alias, such as prodcode> or dev. If you don't provide a value, the DEFAULT alias is used.

Implementation

Future<StopRuntimeSessionResponse> stopRuntimeSession({
  required String agentRuntimeArn,
  required String runtimeSessionId,
  String? clientToken,
  String? qualifier,
}) async {
  final headers = <String, String>{
    'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id':
        runtimeSessionId.toString(),
  };
  final $query = <String, List<String>>{
    if (qualifier != null) 'qualifier': [qualifier],
  };
  final $payload = <String, dynamic>{
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
  };
  final response = await _protocol.sendRaw(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/runtimes/${Uri.encodeComponent(agentRuntimeArn)}/stopruntimesession',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  final $json = await _s.jsonFromResponse(response);
  return StopRuntimeSessionResponse(
    runtimeSessionId: _s.extractHeaderStringValue(
        response.headers, 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id'),
    statusCode: response.statusCode,
  );
}