closeTunnel method

Future<void> closeTunnel({
  1. required String tunnelId,
  2. bool? delete,
})

Closes a tunnel identified by the unique tunnel id. When a CloseTunnel request is received, we close the WebSocket connections between the client and proxy server so no data can be transmitted.

May throw ResourceNotFoundException.

Parameter tunnelId : The ID of the tunnel to close.

Parameter delete : When set to true, AWS IoT Secure Tunneling deletes the tunnel data immediately.

Implementation

Future<void> closeTunnel({
  required String tunnelId,
  bool? delete,
}) async {
  ArgumentError.checkNotNull(tunnelId, 'tunnelId');
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'IoTSecuredTunneling.CloseTunnel'
  };
  await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'tunnelId': tunnelId,
      if (delete != null) 'delete': delete,
    },
  );
}