Skip to content

/AWS1/IF_RSD=>LISTSESSIONS()

About ListSessions

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.

Method Signature

METHODS /AWS1/IF_RSD~LISTSESSIONS
  IMPORTING
    !IV_NEXTTOKEN TYPE /AWS1/RSDSTRING OPTIONAL
    !IV_MAXRESULTS TYPE /AWS1/RSDLISTSTATEMENTSLIMIT OPTIONAL
    !IV_SESSIONID TYPE /AWS1/RSDUUID OPTIONAL
    !IV_STATUS TYPE /AWS1/RSDSESSIONSTATUSSTRING OPTIONAL
    !IV_ROLELEVEL TYPE /AWS1/RSDBOOLEAN OPTIONAL
    !IV_CLUSTERIDENTIFIER TYPE /AWS1/RSDCLUSTERIDSTRING OPTIONAL
    !IV_WORKGROUPNAME TYPE /AWS1/RSDWORKGROUPNAMESTRING OPTIONAL
    !IV_DATABASE TYPE /AWS1/RSDSTRING OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_rsdlistsessresponse
  RAISING
    /AWS1/CX_RSDINTERNALSERVEREX
    /AWS1/CX_RSDRESOURCENOTFOUNDEX
    /AWS1/CX_RSDVALIDATIONEX
    /AWS1/CX_RSDCLIENTEXC
    /AWS1/CX_RSDSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Optional arguments:

iv_nexttoken TYPE /AWS1/RSDSTRING /AWS1/RSDSTRING

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.

iv_maxresults TYPE /AWS1/RSDLISTSTATEMENTSLIMIT /AWS1/RSDLISTSTATEMENTSLIMIT

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.

iv_sessionid TYPE /AWS1/RSDUUID /AWS1/RSDUUID

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.

iv_status TYPE /AWS1/RSDSESSIONSTATUSSTRING /AWS1/RSDSESSIONSTATUSSTRING

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.

iv_rolelevel TYPE /AWS1/RSDBOOLEAN /AWS1/RSDBOOLEAN

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.

iv_clusteridentifier TYPE /AWS1/RSDCLUSTERIDSTRING /AWS1/RSDCLUSTERIDSTRING

The cluster identifier. Only sessions on this cluster are returned. When providing ClusterIdentifier, then WorkgroupName can't be specified.

iv_workgroupname TYPE /AWS1/RSDWORKGROUPNAMESTRING /AWS1/RSDWORKGROUPNAMESTRING

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.

iv_database TYPE /AWS1/RSDSTRING /AWS1/RSDSTRING

The name of the database. Only sessions connected to this database are returned.

RETURNING

oo_output TYPE REF TO /aws1/cl_rsdlistsessresponse /AWS1/CL_RSDLISTSESSRESPONSE

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->listsessions(
  iv_clusteridentifier = |string|
  iv_database = |string|
  iv_maxresults = 123
  iv_nexttoken = |string|
  iv_rolelevel = ABAP_TRUE
  iv_sessionid = |string|
  iv_status = |string|
  iv_workgroupname = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  LOOP AT lo_result->get_sessions( ) into lo_row.
    lo_row_1 = lo_row.
    IF lo_row_1 IS NOT INITIAL.
      lv_uuid = lo_row_1->get_sessionid( ).
      lv_sessionstatusstring = lo_row_1->get_status( ).
      lv_timestamp = lo_row_1->get_createdat( ).
      lv_timestamp = lo_row_1->get_updatedat( ).
      lv_string = lo_row_1->get_database( ).
      lv_string = lo_row_1->get_dbuser( ).
      lv_string = lo_row_1->get_clusteridentifier( ).
      lv_workgroupnamestring = lo_row_1->get_workgroupname( ).
      lv_sessionaliveseconds = lo_row_1->get_sessionaliveseconds( ).
      lv_timestamp = lo_row_1->get_sessionttl( ).
      lv_uuid = lo_row_1->get_currentstatementid( ).
    ENDIF.
  ENDLOOP.
  lv_string = lo_result->get_nexttoken( ).
ENDIF.