stopBrowserSession method

Future<StopBrowserSessionResponse> stopBrowserSession({
  1. required String browserIdentifier,
  2. required String sessionId,
  3. String? clientToken,
  4. String? traceId,
  5. String? traceParent,
})

Terminates an active browser session in Amazon Bedrock AgentCore. This operation stops the session, releases associated resources, and makes the session unavailable for further use.

To stop a browser session, you must specify both the browser identifier and the session ID. Once stopped, a session cannot be restarted; you must create a new session using StartBrowserSession.

The following operations are related to StopBrowserSession:

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter browserIdentifier : The unique identifier of the browser associated with the session.

Parameter sessionId : The unique identifier of the browser 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<StopBrowserSessionResponse> stopBrowserSession({
  required String browserIdentifier,
  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:
        '/browsers/${Uri.encodeComponent(browserIdentifier)}/sessions/stop',
    queryParams: $query,
    headers: headers,
    exceptionFnMap: _exceptionFns,
  );
  return StopBrowserSessionResponse.fromJson(response);
}