RedshiftDataAPIService / Client / list_sessions
list_sessions¶
- RedshiftDataAPIService.Client.list_sessions(**kwargs)¶
Lists the sessions that the caller created in the last 24 hours. By default, only sessions with a status of
AVAILABLEorBUSYare 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 theSessionIdparameter. UseNextTokento 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
ClusterIdentifierorWorkgroupNameparameter 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.See also: AWS API Documentation
Request Syntax
response = client.list_sessions( NextToken='string', MaxResults=123, SessionId='string', Status='AVAILABLE'|'BUSY'|'CLOSED', RoleLevel=True|False, ClusterIdentifier='string', WorkgroupName='string', Database='string' )
- Parameters:
NextToken (string) – 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.
MaxResults (integer) – The maximum number of sessions to return in the response. If more sessions exist than fit in one response, the operation returns
NextTokento paginate the results.SessionId (string) – 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 specifyStatus,ClusterIdentifier,WorkgroupName, orDatabase.Status (string) –
The status of the sessions to list. If no status is specified, sessions with a status of
AVAILABLEorBUSYare 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.
RoleLevel (boolean) – 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.
ClusterIdentifier (string) – The cluster identifier. Only sessions on this cluster are returned. When providing
ClusterIdentifier, thenWorkgroupNamecan’t be specified.WorkgroupName (string) – The serverless workgroup name or Amazon Resource Name (ARN). Only sessions on this workgroup are returned. When providing
WorkgroupName, thenClusterIdentifiercan’t be specified.Database (string) – The name of the database. Only sessions connected to this database are returned.
- Return type:
dict
- Returns:
Response Syntax
{ 'Sessions': [ { 'SessionId': 'string', 'Status': 'AVAILABLE'|'BUSY'|'CLOSED', 'CreatedAt': datetime(2015, 1, 1), 'UpdatedAt': datetime(2015, 1, 1), 'Database': 'string', 'DbUser': 'string', 'ClusterIdentifier': 'string', 'WorkgroupName': 'string', 'SessionAliveSeconds': 123, 'SessionTtl': datetime(2015, 1, 1), 'CurrentStatementId': 'string' }, ], 'NextToken': 'string' }
Response Structure
(dict) –
Sessions (list) –
The sessions that match the request.
(dict) –
Contains the metadata for a session returned by
ListSessions, including its status, compute target, database connection, and lifecycle timestamps.SessionId (string) –
The session identifier. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API.
Status (string) –
The status of the session. 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.
CreatedAt (datetime) –
The date and time (UTC) when the session was created.
UpdatedAt (datetime) –
The date and time (UTC) that the session metadata was last updated. An example is the time the status last changed.
Database (string) –
The name of the database that the session is connected to.
DbUser (string) –
The database user name.
ClusterIdentifier (string) –
The cluster identifier. This element is not returned when connecting to a serverless workgroup.
WorkgroupName (string) –
The serverless workgroup name or Amazon Resource Name (ARN). This element is not returned when connecting to a provisioned cluster.
SessionAliveSeconds (integer) –
The number of seconds that the session is kept alive after a query finishes.
SessionTtl (datetime) –
The date and time (UTC) when the session is set to expire and be closed.
CurrentStatementId (string) –
The identifier of the SQL statement currently running in the session. This value is a universally unique identifier (UUID) generated by Amazon Redshift Data API. This element is returned only when the session status is
BUSY.
NextToken (string) –
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.
Exceptions