Skip to content

list_tables async

list_tables(
    database: String,
    *,
    config_overrides: Optional[AsyncRedshiftDataClientConfig] = None,
    cluster_identifier: Optional[ClusterIdentifierString] = None,
    secret_arn: Optional[SecretArn] = None,
    db_user: Optional[String] = None,
    connected_database: Optional[String] = None,
    schema_pattern: Optional[String] = None,
    table_pattern: Optional[String] = None,
    next_token: Optional[String] = None,
    max_results: Optional[PageSize] = None,
    workgroup_name: Optional[WorkgroupNameString] = None,
) -> ListTablesResponse

List the tables in a database. If neither SchemaPattern nor TablePattern are specified, then all tables in the database are returned. A token is returned to page through the table list. Depending on the authorization method, use one of the following combinations of request parameters:

  • Secrets Manager - when connecting to a cluster, provide the secret-arn of a secret stored in Secrets Manager which has username and password. The specified secret contains credentials to connect to the database you specify. When you are connecting to a cluster, you also supply the database name, If you provide a cluster identifier (dbClusterIdentifier), it must match the cluster identifier stored in the secret. When you are connecting to a serverless workgroup, you also supply the database name.

  • Temporary credentials - when connecting to your data warehouse, choose one of the following options:

    • When connecting to a serverless workgroup, specify the workgroup name and database name. The database user name is derived from the IAM identity. For example, arn:iam::123456789012:user:foo has the database user name IAM:foo. Also, permission to call the redshift-serverless:GetCredentials operation is required.

    • When connecting to a cluster as an IAM identity, specify the cluster identifier and the database name. The database user name is derived from the IAM identity. For example, arn:iam::123456789012:user:foo has the database user name IAM:foo. Also, permission to call the redshift:GetClusterCredentialsWithIAM operation is required.

    • When connecting to a cluster as a database user, specify the cluster identifier, the database name, and the database user name. Also, permission to call the redshift:GetClusterCredentials operation is required.

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:

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

    The cluster identifier. This parameter is required when connecting to a cluster and authenticating using either Secrets Manager or temporary credentials.

  • secret_arn (Optional[SecretArn], default: None ) –

    The name or ARN of the secret that enables access to the database. This parameter is required when authenticating using Secrets Manager.

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

    The database user name. This parameter is required when connecting to a cluster as a database user and authenticating using temporary credentials.

  • database (String) –

    The name of the database that contains the tables to list. If ConnectedDatabase is not specified, this is also the database to connect to with your authentication credentials.

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

    A database name. The connected database is specified when you connect with your authentication credentials.

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

    A pattern to filter results by schema name. Within a schema pattern, "%" means match any substring of 0 or more characters and "_" means match any one character. Only schema name entries matching the search pattern are returned. If SchemaPattern is not specified, then all tables that match TablePattern are returned. If neither SchemaPattern or TablePattern are specified, then all tables are returned.

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

    A pattern to filter results by table name. Within a table pattern, "%" means match any substring of 0 or more characters and "_" means match any one character. Only table name entries matching the search pattern are returned. If TablePattern is not specified, then all tables that match SchemaPatternare returned. If neither SchemaPattern or TablePattern are specified, then all tables are returned.

  • 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[PageSize], default: None ) –

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

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

    The serverless workgroup name or Amazon Resource Name (ARN). This parameter is required when connecting to a serverless workgroup and authenticating using either Secrets Manager or temporary credentials.

Raises:

Source code in docs_src/capo_redshift_data/_services/async_redshift_data.py
async def list_tables(
    self,
    database: "capo_redshift_data.types.string.String",
    *,
    config_overrides: Optional[AsyncRedshiftDataClientConfig] = None,
    cluster_identifier: Optional[
        "capo_redshift_data.types.cluster_identifier_string.ClusterIdentifierString"
    ] = None,
    secret_arn: Optional["capo_redshift_data.types.secret_arn.SecretArn"] = None,
    db_user: Optional["capo_redshift_data.types.string.String"] = None,
    connected_database: Optional["capo_redshift_data.types.string.String"] = None,
    schema_pattern: Optional["capo_redshift_data.types.string.String"] = None,
    table_pattern: Optional["capo_redshift_data.types.string.String"] = None,
    next_token: Optional["capo_redshift_data.types.string.String"] = None,
    max_results: Optional["capo_redshift_data.types.page_size.PageSize"] = None,
    workgroup_name: Optional[
        "capo_redshift_data.types.workgroup_name_string.WorkgroupNameString"
    ] = None,
) -> "capo_redshift_data.types.list_tables_response.ListTablesResponse":
    """<p>List the tables in a database. If neither <code>SchemaPattern</code> nor <code>TablePattern</code> are specified, then all tables in the database are returned. A token is returned to page through the table list. Depending on the authorization method, use one of the following combinations of request parameters: </p> <ul> <li> <p>Secrets Manager - when connecting to a cluster, provide the <code>secret-arn</code> of a secret stored in Secrets Manager which has <code>username</code> and <code>password</code>. The specified secret contains credentials to connect to the <code>database</code> you specify. When you are connecting to a cluster, you also supply the database name, If you provide a cluster identifier (<code>dbClusterIdentifier</code>), it must match the cluster identifier stored in the secret. When you are connecting to a serverless workgroup, you also supply the database name.</p> </li> <li> <p>Temporary credentials - when connecting to your data warehouse, choose one of the following options:</p> <ul> <li> <p>When connecting to a serverless workgroup, specify the workgroup name and database name. The database user name is derived from the IAM identity. For example, <code>arn:iam::123456789012:user:foo</code> has the database user name <code>IAM:foo</code>. Also, permission to call the <code>redshift-serverless:GetCredentials</code> operation is required.</p> </li> <li> <p>When connecting to a cluster as an IAM identity, specify the cluster identifier and the database name. The database user name is derived from the IAM identity. For example, <code>arn:iam::123456789012:user:foo</code> has the database user name <code>IAM:foo</code>. Also, permission to call the <code>redshift:GetClusterCredentialsWithIAM</code> operation is required.</p> </li> <li> <p>When connecting to a cluster as a database user, specify the cluster identifier, the database name, and the database user name. Also, permission to call the <code>redshift:GetClusterCredentials</code> operation is required.</p> </li> </ul> </li> </ul> <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:
        cluster_identifier: <p>The cluster identifier. This parameter is required when connecting to a cluster and authenticating using either Secrets Manager or temporary credentials. </p>
        secret_arn: <p>The name or ARN of the secret that enables access to the database. This parameter is required when authenticating using Secrets Manager. </p>
        db_user: <p>The database user name. This parameter is required when connecting to a cluster as a database user and authenticating using temporary credentials. </p>
        database: <p>The name of the database that contains the tables to list. If <code>ConnectedDatabase</code> is not specified, this is also the database to connect to with your authentication credentials.</p>
        connected_database: <p>A database name. The connected database is specified when you connect with your authentication credentials. </p>
        schema_pattern: <p>A pattern to filter results by schema name. Within a schema pattern, "%" means match any substring of 0 or more characters and "_" means match any one character. Only schema name entries matching the search pattern are returned. If <code>SchemaPattern</code> is not specified, then all tables that match <code>TablePattern</code> are returned. If neither <code>SchemaPattern</code> or <code>TablePattern</code> are specified, then all tables are returned. </p>
        table_pattern: <p>A pattern to filter results by table name. Within a table pattern, "%" means match any substring of 0 or more characters and "_" means match any one character. Only table name entries matching the search pattern are returned. If <code>TablePattern</code> is not specified, then all tables that match <code>SchemaPattern</code>are returned. If neither <code>SchemaPattern</code> or <code>TablePattern</code> are specified, then all tables are returned. </p>
        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 tables to return in the response. If more tables exist than fit in one response, then <code>NextToken</code> is returned to page through the results. </p>
        workgroup_name: <p>The serverless workgroup name or Amazon Resource Name (ARN). This parameter is required when connecting to a serverless workgroup and authenticating using either Secrets Manager or temporary credentials.</p>

    Raises:
        capo_redshift_data.errors.database_connection_exception.DatabaseConnectionException: <p>Connection to a database failed.</p>
        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.query_timeout_exception.QueryTimeoutException: <p>The Amazon Redshift Data API operation failed due to timeout.</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_tables_request.ListTablesRequest]",
    ) -> AsyncOperationResponse[
        "capo_redshift_data.types.list_tables_response.ListTablesResponse"
    ]:
        import capo_redshift_data._operations.redshift_data.list_tables

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListTables")
    )
    input_: capo_redshift_data.types.list_tables_request.ListTablesRequest = {
        "database": database
    }
    if cluster_identifier is not None:
        input_["cluster_identifier"] = cluster_identifier
    if secret_arn is not None:
        input_["secret_arn"] = secret_arn
    if db_user is not None:
        input_["db_user"] = db_user
    if connected_database is not None:
        input_["connected_database"] = connected_database
    if schema_pattern is not None:
        input_["schema_pattern"] = schema_pattern
    if table_pattern is not None:
        input_["table_pattern"] = table_pattern
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    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