Skip to content

list_statements async

list_statements(
    *,
    config_overrides: Optional[AsyncRedshiftDataClientConfig] = None,
    next_token: Optional[String] = None,
    max_results: Optional[ListStatementsLimit] = None,
    statement_name: Optional[StatementNameString] = None,
    status: Optional[StatusString] = None,
    role_level: Optional[bool] = None,
    database: Optional[String] = None,
    cluster_identifier: Optional[ClusterIdentifierString] = None,
    workgroup_name: Optional[WorkgroupNameString] = None,
) -> ListStatementsResponse

List of SQL statements. By default, only finished statements are shown. A token is returned to page through the statement list.

When you use identity-enhanced role sessions to list statements, you must provide either the cluster-identifier or workgroup-name parameter. This ensures that the IdC user can only access the Amazon Redshift IdC applications they are assigned. For more information, see Trusted identity propagation overview.

For more information about the Amazon Redshift Data API and CLI usage examples, see Using the Amazon Redshift Data API in the Amazon Redshift Management Guide.

Parameters:

  • next_token (Optional[String], default: None ) –

    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.

  • max_results (Optional[ListStatementsLimit], default: None ) –

    The maximum number of SQL statements to return in the response. If more SQL statements exist than fit in one response, then NextToken is returned to page through the results.

  • statement_name (Optional[StatementNameString], default: None ) –

    The name of the SQL statement specified as input to BatchExecuteStatement or ExecuteStatement to identify the query. You can list multiple statements by providing a prefix that matches the beginning of the statement name. For example, to list myStatement1, myStatement2, myStatement3, and so on, then provide the a value of myStatement. Data API does a case-sensitive match of SQL statement names to the prefix value you provide.

  • status (Optional[StatusString], default: None ) –

    The status of the SQL statement to list. Status values are defined as follows:

    • ABORTED - The query run was stopped by the user.

    • ALL - A status value that includes all query statuses. This value can be used to filter results.

    • FAILED - The query run failed.

    • FINISHED - The query has finished running.

    • PICKED - The query has been chosen to be run.

    • STARTED - The query run has started.

    • SUBMITTED - The query was submitted, but not yet processed.

  • role_level (Optional[bool], default: None ) –

    A value that filters which statements to return in the response. If true, all statements run by the caller's IAM role are returned. If false, only statements run by the caller's IAM role in the current IAM session are returned. The default is true.

  • database (Optional[String], default: None ) –

    The name of the database when listing statements run against a ClusterIdentifier or WorkgroupName.

  • cluster_identifier (Optional[ClusterIdentifierString], default: None ) –

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

  • workgroup_name (Optional[WorkgroupNameString], default: None ) –

    The serverless workgroup name or Amazon Resource Name (ARN). Only statements that ran on this workgroup are returned. When providing WorkgroupName, then ClusterIdentifier can't be specified.

Raises:

Source code in docs_src/capo_redshift_data/_services/async_redshift_data.py
async def list_statements(
    self,
    *,
    config_overrides: Optional[AsyncRedshiftDataClientConfig] = None,
    next_token: Optional["capo_redshift_data.types.string.String"] = None,
    max_results: Optional[
        "capo_redshift_data.types.list_statements_limit.ListStatementsLimit"
    ] = None,
    statement_name: Optional[
        "capo_redshift_data.types.statement_name_string.StatementNameString"
    ] = None,
    status: Optional["capo_redshift_data.types.status_string.StatusString"] = None,
    role_level: Optional[bool] = None,
    database: Optional["capo_redshift_data.types.string.String"] = None,
    cluster_identifier: Optional[
        "capo_redshift_data.types.cluster_identifier_string.ClusterIdentifierString"
    ] = None,
    workgroup_name: Optional[
        "capo_redshift_data.types.workgroup_name_string.WorkgroupNameString"
    ] = None,
) -> "capo_redshift_data.types.list_statements_response.ListStatementsResponse":
    """<p>List of SQL statements. By default, only finished statements are shown. A token is returned to page through the statement list. </p> <p>When you use identity-enhanced role sessions to list statements, you must provide either the <code>cluster-identifier</code> or <code>workgroup-name</code> parameter. This ensures that the IdC user can only access the Amazon Redshift IdC applications they are assigned. For more information, see <a href="https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overview.html"> Trusted identity propagation overview</a>.</p> <p>For more information about the Amazon Redshift Data API and CLI usage examples, see <a href="https://docs.aws.amazon.com/redshift/latest/mgmt/data-api.html">Using the Amazon Redshift Data API</a> in the <i>Amazon Redshift Management Guide</i>. </p>

    Args:
        next_token: <p>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. </p>
        max_results: <p>The maximum number of SQL statements to return in the response. If more SQL statements exist than fit in one response, then <code>NextToken</code> is returned to page through the results. </p>
        statement_name: <p>The name of the SQL statement specified as input to <code>BatchExecuteStatement</code> or <code>ExecuteStatement</code> to identify the query. You can list multiple statements by providing a prefix that matches the beginning of the statement name. For example, to list myStatement1, myStatement2, myStatement3, and so on, then provide the a value of <code>myStatement</code>. Data API does a case-sensitive match of SQL statement names to the prefix value you provide. </p>
        status: <p>The status of the SQL statement to list. Status values are defined as follows: </p> <ul> <li> <p>ABORTED - The query run was stopped by the user. </p> </li> <li> <p>ALL - A status value that includes all query statuses. This value can be used to filter results. </p> </li> <li> <p>FAILED - The query run failed. </p> </li> <li> <p>FINISHED - The query has finished running. </p> </li> <li> <p>PICKED - The query has been chosen to be run. </p> </li> <li> <p>STARTED - The query run has started. </p> </li> <li> <p>SUBMITTED - The query was submitted, but not yet processed. </p> </li> </ul>
        role_level: <p>A value that filters which statements to return in the response. If true, all statements run by the caller's IAM role are returned. If false, only statements run by the caller's IAM role in the current IAM session are returned. The default is true. </p>
        database: <p>The name of the database when listing statements run against a <code>ClusterIdentifier</code> or <code>WorkgroupName</code>. </p>
        cluster_identifier: <p>The cluster identifier. Only statements that ran on this cluster are returned. When providing <code>ClusterIdentifier</code>, then <code>WorkgroupName</code> can't be specified.</p>
        workgroup_name: <p>The serverless workgroup name or Amazon Resource Name (ARN). Only statements that ran on this workgroup are returned. When providing <code>WorkgroupName</code>, then <code>ClusterIdentifier</code> can't be specified.</p>

    Raises:
        capo_redshift_data.errors.internal_server_exception.InternalServerException: <p>The Amazon Redshift Data API operation failed due to invalid input. </p>
        capo_redshift_data.errors.resource_not_found_exception.ResourceNotFoundException: <p>The Amazon Redshift Data API operation failed due to a missing resource. </p>
        capo_redshift_data.errors.validation_exception.ValidationException: <p>The Amazon Redshift Data API operation failed due to invalid input. </p>
        capo_redshift_data.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_redshift_data.types.list_statements_request.ListStatementsRequest]",
    ) -> AsyncOperationResponse[
        "capo_redshift_data.types.list_statements_response.ListStatementsResponse"
    ]:
        import capo_redshift_data._operations.redshift_data.list_statements

        (
            output,
            http_response,
        ) = await capo_redshift_data._operations.redshift_data.list_statements.async_list_statements(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListStatements")
    )
    input_: capo_redshift_data.types.list_statements_request.ListStatementsRequest = {}
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if statement_name is not None:
        input_["statement_name"] = statement_name
    if status is not None:
        input_["status"] = status
    if role_level is not None:
        input_["role_level"] = role_level
    if database is not None:
        input_["database"] = database
    if cluster_identifier is not None:
        input_["cluster_identifier"] = cluster_identifier
    if workgroup_name is not None:
        input_["workgroup_name"] = workgroup_name

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output