{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Amazonka.RedshiftData.DescribeStatement -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Describes the details about a specific instance when a query was run by -- the Amazon Redshift Data API. The information includes when the query -- started, when it finished, the query status, the number of rows -- returned, and the SQL statement. -- -- For more information about the Amazon Redshift Data API and CLI usage -- examples, see -- -- in the /Amazon Redshift Management Guide/. module Amazonka.RedshiftData.DescribeStatement ( -- * Creating a Request DescribeStatement (..), newDescribeStatement, -- * Request Lenses describeStatement_id, -- * Destructuring the Response DescribeStatementResponse (..), newDescribeStatementResponse, -- * Response Lenses describeStatementResponse_clusterIdentifier, describeStatementResponse_createdAt, describeStatementResponse_database, describeStatementResponse_dbUser, describeStatementResponse_duration, describeStatementResponse_error, describeStatementResponse_hasResultSet, describeStatementResponse_queryParameters, describeStatementResponse_queryString, describeStatementResponse_redshiftPid, describeStatementResponse_redshiftQueryId, describeStatementResponse_resultRows, describeStatementResponse_resultSize, describeStatementResponse_secretArn, describeStatementResponse_status, describeStatementResponse_subStatements, describeStatementResponse_updatedAt, describeStatementResponse_workgroupName, describeStatementResponse_httpStatus, describeStatementResponse_id, ) where import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import qualified Amazonka.Prelude as Prelude import Amazonka.RedshiftData.Types import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newDescribeStatement' smart constructor. data DescribeStatement = DescribeStatement' { -- | The identifier of the SQL statement to describe. This value is a -- universally unique identifier (UUID) generated by Amazon Redshift Data -- API. A suffix indicates the number of the SQL statement. For example, -- @d9b6c0c9-0747-4bf4-b142-e8883122f766:2@ has a suffix of @:2@ that -- indicates the second SQL statement of a batch query. This identifier is -- returned by @BatchExecuteStatment@, @ExecuteStatement@, and -- @ListStatements@. id :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'DescribeStatement' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'id', 'describeStatement_id' - The identifier of the SQL statement to describe. This value is a -- universally unique identifier (UUID) generated by Amazon Redshift Data -- API. A suffix indicates the number of the SQL statement. For example, -- @d9b6c0c9-0747-4bf4-b142-e8883122f766:2@ has a suffix of @:2@ that -- indicates the second SQL statement of a batch query. This identifier is -- returned by @BatchExecuteStatment@, @ExecuteStatement@, and -- @ListStatements@. newDescribeStatement :: -- | 'id' Prelude.Text -> DescribeStatement newDescribeStatement pId_ = DescribeStatement' {id = pId_} -- | The identifier of the SQL statement to describe. This value is a -- universally unique identifier (UUID) generated by Amazon Redshift Data -- API. A suffix indicates the number of the SQL statement. For example, -- @d9b6c0c9-0747-4bf4-b142-e8883122f766:2@ has a suffix of @:2@ that -- indicates the second SQL statement of a batch query. This identifier is -- returned by @BatchExecuteStatment@, @ExecuteStatement@, and -- @ListStatements@. describeStatement_id :: Lens.Lens' DescribeStatement Prelude.Text describeStatement_id = Lens.lens (\DescribeStatement' {id} -> id) (\s@DescribeStatement' {} a -> s {id = a} :: DescribeStatement) instance Core.AWSRequest DescribeStatement where type AWSResponse DescribeStatement = DescribeStatementResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveJSON ( \s h x -> DescribeStatementResponse' Prelude.<$> (x Data..?> "ClusterIdentifier") Prelude.<*> (x Data..?> "CreatedAt") Prelude.<*> (x Data..?> "Database") Prelude.<*> (x Data..?> "DbUser") Prelude.<*> (x Data..?> "Duration") Prelude.<*> (x Data..?> "Error") Prelude.<*> (x Data..?> "HasResultSet") Prelude.<*> (x Data..?> "QueryParameters") Prelude.<*> (x Data..?> "QueryString") Prelude.<*> (x Data..?> "RedshiftPid") Prelude.<*> (x Data..?> "RedshiftQueryId") Prelude.<*> (x Data..?> "ResultRows") Prelude.<*> (x Data..?> "ResultSize") Prelude.<*> (x Data..?> "SecretArn") Prelude.<*> (x Data..?> "Status") Prelude.<*> (x Data..?> "SubStatements" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "UpdatedAt") Prelude.<*> (x Data..?> "WorkgroupName") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) Prelude.<*> (x Data..:> "Id") ) instance Prelude.Hashable DescribeStatement where hashWithSalt _salt DescribeStatement' {..} = _salt `Prelude.hashWithSalt` id instance Prelude.NFData DescribeStatement where rnf DescribeStatement' {..} = Prelude.rnf id instance Data.ToHeaders DescribeStatement where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "RedshiftData.DescribeStatement" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON DescribeStatement where toJSON DescribeStatement' {..} = Data.object (Prelude.catMaybes [Prelude.Just ("Id" Data..= id)]) instance Data.ToPath DescribeStatement where toPath = Prelude.const "/" instance Data.ToQuery DescribeStatement where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newDescribeStatementResponse' smart constructor. data DescribeStatementResponse = DescribeStatementResponse' { -- | The cluster identifier. clusterIdentifier :: Prelude.Maybe Prelude.Text, -- | The date and time (UTC) when the SQL statement was submitted to run. createdAt :: Prelude.Maybe Data.POSIX, -- | The name of the database. database :: Prelude.Maybe Prelude.Text, -- | The database user name. dbUser :: Prelude.Maybe Prelude.Text, -- | The amount of time in nanoseconds that the statement ran. duration :: Prelude.Maybe Prelude.Integer, -- | The error message from the cluster if the SQL statement encountered an -- error while running. error :: Prelude.Maybe Prelude.Text, -- | A value that indicates whether the statement has a result set. The -- result set can be empty. The value is true for an empty result set. The -- value is true if any substatement returns a result set. hasResultSet :: Prelude.Maybe Prelude.Bool, -- | The parameters for the SQL statement. queryParameters :: Prelude.Maybe (Prelude.NonEmpty SqlParameter), -- | The SQL statement text. queryString :: Prelude.Maybe Prelude.Text, -- | The process identifier from Amazon Redshift. redshiftPid :: Prelude.Maybe Prelude.Integer, -- | The identifier of the query generated by Amazon Redshift. These -- identifiers are also available in the @query@ column of the @STL_QUERY@ -- system view. redshiftQueryId :: Prelude.Maybe Prelude.Integer, -- | Either the number of rows returned from the SQL statement or the number -- of rows affected. If result size is greater than zero, the result rows -- can be the number of rows affected by SQL statements such as INSERT, -- UPDATE, DELETE, COPY, and others. A @-1@ indicates the value is null. resultRows :: Prelude.Maybe Prelude.Integer, -- | The size in bytes of the returned results. A @-1@ indicates the value is -- null. resultSize :: Prelude.Maybe Prelude.Integer, -- | The name or Amazon Resource Name (ARN) of the secret that enables access -- to the database. secretArn :: Prelude.Maybe Prelude.Text, -- | The status of the SQL statement being described. 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. status :: Prelude.Maybe StatusString, -- | The SQL statements from a multiple statement run. subStatements :: Prelude.Maybe [SubStatementData], -- | The date and time (UTC) that the metadata for the SQL statement was last -- updated. An example is the time the status last changed. updatedAt :: Prelude.Maybe Data.POSIX, -- | The serverless workgroup name. workgroupName :: Prelude.Maybe Prelude.Text, -- | The response's http status code. httpStatus :: Prelude.Int, -- | The identifier of the SQL statement described. This value is a -- universally unique identifier (UUID) generated by Amazon Redshift Data -- API. id :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'DescribeStatementResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'clusterIdentifier', 'describeStatementResponse_clusterIdentifier' - The cluster identifier. -- -- 'createdAt', 'describeStatementResponse_createdAt' - The date and time (UTC) when the SQL statement was submitted to run. -- -- 'database', 'describeStatementResponse_database' - The name of the database. -- -- 'dbUser', 'describeStatementResponse_dbUser' - The database user name. -- -- 'duration', 'describeStatementResponse_duration' - The amount of time in nanoseconds that the statement ran. -- -- 'error', 'describeStatementResponse_error' - The error message from the cluster if the SQL statement encountered an -- error while running. -- -- 'hasResultSet', 'describeStatementResponse_hasResultSet' - A value that indicates whether the statement has a result set. The -- result set can be empty. The value is true for an empty result set. The -- value is true if any substatement returns a result set. -- -- 'queryParameters', 'describeStatementResponse_queryParameters' - The parameters for the SQL statement. -- -- 'queryString', 'describeStatementResponse_queryString' - The SQL statement text. -- -- 'redshiftPid', 'describeStatementResponse_redshiftPid' - The process identifier from Amazon Redshift. -- -- 'redshiftQueryId', 'describeStatementResponse_redshiftQueryId' - The identifier of the query generated by Amazon Redshift. These -- identifiers are also available in the @query@ column of the @STL_QUERY@ -- system view. -- -- 'resultRows', 'describeStatementResponse_resultRows' - Either the number of rows returned from the SQL statement or the number -- of rows affected. If result size is greater than zero, the result rows -- can be the number of rows affected by SQL statements such as INSERT, -- UPDATE, DELETE, COPY, and others. A @-1@ indicates the value is null. -- -- 'resultSize', 'describeStatementResponse_resultSize' - The size in bytes of the returned results. A @-1@ indicates the value is -- null. -- -- 'secretArn', 'describeStatementResponse_secretArn' - The name or Amazon Resource Name (ARN) of the secret that enables access -- to the database. -- -- 'status', 'describeStatementResponse_status' - The status of the SQL statement being described. 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. -- -- 'subStatements', 'describeStatementResponse_subStatements' - The SQL statements from a multiple statement run. -- -- 'updatedAt', 'describeStatementResponse_updatedAt' - The date and time (UTC) that the metadata for the SQL statement was last -- updated. An example is the time the status last changed. -- -- 'workgroupName', 'describeStatementResponse_workgroupName' - The serverless workgroup name. -- -- 'httpStatus', 'describeStatementResponse_httpStatus' - The response's http status code. -- -- 'id', 'describeStatementResponse_id' - The identifier of the SQL statement described. This value is a -- universally unique identifier (UUID) generated by Amazon Redshift Data -- API. newDescribeStatementResponse :: -- | 'httpStatus' Prelude.Int -> -- | 'id' Prelude.Text -> DescribeStatementResponse newDescribeStatementResponse pHttpStatus_ pId_ = DescribeStatementResponse' { clusterIdentifier = Prelude.Nothing, createdAt = Prelude.Nothing, database = Prelude.Nothing, dbUser = Prelude.Nothing, duration = Prelude.Nothing, error = Prelude.Nothing, hasResultSet = Prelude.Nothing, queryParameters = Prelude.Nothing, queryString = Prelude.Nothing, redshiftPid = Prelude.Nothing, redshiftQueryId = Prelude.Nothing, resultRows = Prelude.Nothing, resultSize = Prelude.Nothing, secretArn = Prelude.Nothing, status = Prelude.Nothing, subStatements = Prelude.Nothing, updatedAt = Prelude.Nothing, workgroupName = Prelude.Nothing, httpStatus = pHttpStatus_, id = pId_ } -- | The cluster identifier. describeStatementResponse_clusterIdentifier :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Text) describeStatementResponse_clusterIdentifier = Lens.lens (\DescribeStatementResponse' {clusterIdentifier} -> clusterIdentifier) (\s@DescribeStatementResponse' {} a -> s {clusterIdentifier = a} :: DescribeStatementResponse) -- | The date and time (UTC) when the SQL statement was submitted to run. describeStatementResponse_createdAt :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.UTCTime) describeStatementResponse_createdAt = Lens.lens (\DescribeStatementResponse' {createdAt} -> createdAt) (\s@DescribeStatementResponse' {} a -> s {createdAt = a} :: DescribeStatementResponse) Prelude.. Lens.mapping Data._Time -- | The name of the database. describeStatementResponse_database :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Text) describeStatementResponse_database = Lens.lens (\DescribeStatementResponse' {database} -> database) (\s@DescribeStatementResponse' {} a -> s {database = a} :: DescribeStatementResponse) -- | The database user name. describeStatementResponse_dbUser :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Text) describeStatementResponse_dbUser = Lens.lens (\DescribeStatementResponse' {dbUser} -> dbUser) (\s@DescribeStatementResponse' {} a -> s {dbUser = a} :: DescribeStatementResponse) -- | The amount of time in nanoseconds that the statement ran. describeStatementResponse_duration :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Integer) describeStatementResponse_duration = Lens.lens (\DescribeStatementResponse' {duration} -> duration) (\s@DescribeStatementResponse' {} a -> s {duration = a} :: DescribeStatementResponse) -- | The error message from the cluster if the SQL statement encountered an -- error while running. describeStatementResponse_error :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Text) describeStatementResponse_error = Lens.lens (\DescribeStatementResponse' {error} -> error) (\s@DescribeStatementResponse' {} a -> s {error = a} :: DescribeStatementResponse) -- | A value that indicates whether the statement has a result set. The -- result set can be empty. The value is true for an empty result set. The -- value is true if any substatement returns a result set. describeStatementResponse_hasResultSet :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Bool) describeStatementResponse_hasResultSet = Lens.lens (\DescribeStatementResponse' {hasResultSet} -> hasResultSet) (\s@DescribeStatementResponse' {} a -> s {hasResultSet = a} :: DescribeStatementResponse) -- | The parameters for the SQL statement. describeStatementResponse_queryParameters :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe (Prelude.NonEmpty SqlParameter)) describeStatementResponse_queryParameters = Lens.lens (\DescribeStatementResponse' {queryParameters} -> queryParameters) (\s@DescribeStatementResponse' {} a -> s {queryParameters = a} :: DescribeStatementResponse) Prelude.. Lens.mapping Lens.coerced -- | The SQL statement text. describeStatementResponse_queryString :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Text) describeStatementResponse_queryString = Lens.lens (\DescribeStatementResponse' {queryString} -> queryString) (\s@DescribeStatementResponse' {} a -> s {queryString = a} :: DescribeStatementResponse) -- | The process identifier from Amazon Redshift. describeStatementResponse_redshiftPid :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Integer) describeStatementResponse_redshiftPid = Lens.lens (\DescribeStatementResponse' {redshiftPid} -> redshiftPid) (\s@DescribeStatementResponse' {} a -> s {redshiftPid = a} :: DescribeStatementResponse) -- | The identifier of the query generated by Amazon Redshift. These -- identifiers are also available in the @query@ column of the @STL_QUERY@ -- system view. describeStatementResponse_redshiftQueryId :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Integer) describeStatementResponse_redshiftQueryId = Lens.lens (\DescribeStatementResponse' {redshiftQueryId} -> redshiftQueryId) (\s@DescribeStatementResponse' {} a -> s {redshiftQueryId = a} :: DescribeStatementResponse) -- | Either the number of rows returned from the SQL statement or the number -- of rows affected. If result size is greater than zero, the result rows -- can be the number of rows affected by SQL statements such as INSERT, -- UPDATE, DELETE, COPY, and others. A @-1@ indicates the value is null. describeStatementResponse_resultRows :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Integer) describeStatementResponse_resultRows = Lens.lens (\DescribeStatementResponse' {resultRows} -> resultRows) (\s@DescribeStatementResponse' {} a -> s {resultRows = a} :: DescribeStatementResponse) -- | The size in bytes of the returned results. A @-1@ indicates the value is -- null. describeStatementResponse_resultSize :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Integer) describeStatementResponse_resultSize = Lens.lens (\DescribeStatementResponse' {resultSize} -> resultSize) (\s@DescribeStatementResponse' {} a -> s {resultSize = a} :: DescribeStatementResponse) -- | The name or Amazon Resource Name (ARN) of the secret that enables access -- to the database. describeStatementResponse_secretArn :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Text) describeStatementResponse_secretArn = Lens.lens (\DescribeStatementResponse' {secretArn} -> secretArn) (\s@DescribeStatementResponse' {} a -> s {secretArn = a} :: DescribeStatementResponse) -- | The status of the SQL statement being described. 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. describeStatementResponse_status :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe StatusString) describeStatementResponse_status = Lens.lens (\DescribeStatementResponse' {status} -> status) (\s@DescribeStatementResponse' {} a -> s {status = a} :: DescribeStatementResponse) -- | The SQL statements from a multiple statement run. describeStatementResponse_subStatements :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe [SubStatementData]) describeStatementResponse_subStatements = Lens.lens (\DescribeStatementResponse' {subStatements} -> subStatements) (\s@DescribeStatementResponse' {} a -> s {subStatements = a} :: DescribeStatementResponse) Prelude.. Lens.mapping Lens.coerced -- | The date and time (UTC) that the metadata for the SQL statement was last -- updated. An example is the time the status last changed. describeStatementResponse_updatedAt :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.UTCTime) describeStatementResponse_updatedAt = Lens.lens (\DescribeStatementResponse' {updatedAt} -> updatedAt) (\s@DescribeStatementResponse' {} a -> s {updatedAt = a} :: DescribeStatementResponse) Prelude.. Lens.mapping Data._Time -- | The serverless workgroup name. describeStatementResponse_workgroupName :: Lens.Lens' DescribeStatementResponse (Prelude.Maybe Prelude.Text) describeStatementResponse_workgroupName = Lens.lens (\DescribeStatementResponse' {workgroupName} -> workgroupName) (\s@DescribeStatementResponse' {} a -> s {workgroupName = a} :: DescribeStatementResponse) -- | The response's http status code. describeStatementResponse_httpStatus :: Lens.Lens' DescribeStatementResponse Prelude.Int describeStatementResponse_httpStatus = Lens.lens (\DescribeStatementResponse' {httpStatus} -> httpStatus) (\s@DescribeStatementResponse' {} a -> s {httpStatus = a} :: DescribeStatementResponse) -- | The identifier of the SQL statement described. This value is a -- universally unique identifier (UUID) generated by Amazon Redshift Data -- API. describeStatementResponse_id :: Lens.Lens' DescribeStatementResponse Prelude.Text describeStatementResponse_id = Lens.lens (\DescribeStatementResponse' {id} -> id) (\s@DescribeStatementResponse' {} a -> s {id = a} :: DescribeStatementResponse) instance Prelude.NFData DescribeStatementResponse where rnf DescribeStatementResponse' {..} = Prelude.rnf clusterIdentifier `Prelude.seq` Prelude.rnf createdAt `Prelude.seq` Prelude.rnf database `Prelude.seq` Prelude.rnf dbUser `Prelude.seq` Prelude.rnf duration `Prelude.seq` Prelude.rnf error `Prelude.seq` Prelude.rnf hasResultSet `Prelude.seq` Prelude.rnf queryParameters `Prelude.seq` Prelude.rnf queryString `Prelude.seq` Prelude.rnf redshiftPid `Prelude.seq` Prelude.rnf redshiftQueryId `Prelude.seq` Prelude.rnf resultRows `Prelude.seq` Prelude.rnf resultSize `Prelude.seq` Prelude.rnf secretArn `Prelude.seq` Prelude.rnf status `Prelude.seq` Prelude.rnf subStatements `Prelude.seq` Prelude.rnf updatedAt `Prelude.seq` Prelude.rnf workgroupName `Prelude.seq` Prelude.rnf httpStatus `Prelude.seq` Prelude.rnf id