listSessions method
Lists the sessions that the caller created in the last 24 hours. By
default, only sessions with a status of AVAILABLE or
BUSY are returned. You can filter the results by session
status, compute target (cluster or serverless workgroup), or database. To
retrieve the metadata for a single session, provide the
SessionId parameter. Use NextToken to page
through the session list.
Returns only the sessions that the caller created. When identity-enhanced
role sessions are used, you must provide either the
ClusterIdentifier or WorkgroupName parameter to
ensure that the AWS IAM Identity Center user can only access the Amazon
Redshift IAM Identity Center applications they are assigned. For more
information, see
Trusted identity propagation overview.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ValidationException.
Parameter clusterIdentifier :
The cluster identifier. Only sessions on this cluster are returned. When
providing ClusterIdentifier, then WorkgroupName
can't be specified.
Parameter database :
The name of the database. Only sessions connected to this database are
returned.
Parameter maxResults :
The maximum number of sessions to return in the response. If more sessions
exist than fit in one response, the operation returns
NextToken to paginate the results.
Parameter nextToken :
A value that indicates the starting point for the next set of response
records in a subsequent request. If a value is returned in a response, you
can retrieve the next set of records by providing this returned NextToken
value in the next NextToken parameter and retrying the command. If the
NextToken field is empty, all response records have been retrieved for the
request.
Parameter roleLevel :
Specifies whether to return all sessions created by the caller's IAM role,
including sessions from previous IAM sessions. If false, only sessions
created in the current IAM session are returned. The default is true.
Parameter sessionId :
The identifier of a specific session to return metadata for. This value is
a universally unique identifier (UUID) generated by Amazon Redshift Data
API. When you provide SessionId, you can't specify
Status, ClusterIdentifier,
WorkgroupName, or Database.
Parameter status :
The status of the sessions to list. If no status is specified, sessions
with a status of AVAILABLE or BUSY are returned.
Status values are defined as follows:
- AVAILABLE – The session is open and ready to run a SQL statement.
- BUSY – The session is currently running a SQL statement.
- CLOSED – The session is closed and can no longer run SQL statements.
Parameter workgroupName :
The serverless workgroup name or Amazon Resource Name (ARN). Only sessions
on this workgroup are returned. When providing WorkgroupName,
then ClusterIdentifier can't be specified.
Implementation
Future<ListSessionsResponse> listSessions({
String? clusterIdentifier,
String? database,
int? maxResults,
String? nextToken,
bool? roleLevel,
String? sessionId,
SessionStatusString? status,
String? workgroupName,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
0,
100,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'RedshiftData.ListSessions'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
if (clusterIdentifier != null) 'ClusterIdentifier': clusterIdentifier,
if (database != null) 'Database': database,
if (maxResults != null) 'MaxResults': maxResults,
if (nextToken != null) 'NextToken': nextToken,
if (roleLevel != null) 'RoleLevel': roleLevel,
if (sessionId != null) 'SessionId': sessionId,
if (status != null) 'Status': status.value,
if (workgroupName != null) 'WorkgroupName': workgroupName,
},
);
return ListSessionsResponse.fromJson(jsonResponse.body);
}