{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Athena.Types.QueryExecutionStatus
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Athena.Types.QueryExecutionStatus where

import Amazonka.Athena.Types.QueryExecutionState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The completion date, current state, submission time, and state change
-- reason (if applicable) for the query execution.
--
-- /See:/ 'newQueryExecutionStatus' smart constructor.
data QueryExecutionStatus = QueryExecutionStatus'
  { -- | The state of query execution. @QUEUED@ indicates that the query has been
    -- submitted to the service, and Athena will execute the query as soon as
    -- resources are available. @RUNNING@ indicates that the query is in
    -- execution phase. @SUCCEEDED@ indicates that the query completed without
    -- errors. @FAILED@ indicates that the query experienced an error and did
    -- not complete processing. @CANCELLED@ indicates that a user input
    -- interrupted query execution.
    --
    -- Athena automatically retries your queries in cases of certain transient
    -- errors. As a result, you may see the query state transition from
    -- @RUNNING@ or @FAILED@ to @QUEUED@.
    QueryExecutionStatus -> Maybe QueryExecutionState
state :: Prelude.Maybe QueryExecutionState,
    -- | Further detail about the status of the query.
    QueryExecutionStatus -> Maybe Text
stateChangeReason :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the query was submitted.
    QueryExecutionStatus -> Maybe POSIX
submissionDateTime :: Prelude.Maybe Core.POSIX,
    -- | The date and time that the query completed.
    QueryExecutionStatus -> Maybe POSIX
completionDateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (QueryExecutionStatus -> QueryExecutionStatus -> Bool
(QueryExecutionStatus -> QueryExecutionStatus -> Bool)
-> (QueryExecutionStatus -> QueryExecutionStatus -> Bool)
-> Eq QueryExecutionStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueryExecutionStatus -> QueryExecutionStatus -> Bool
$c/= :: QueryExecutionStatus -> QueryExecutionStatus -> Bool
== :: QueryExecutionStatus -> QueryExecutionStatus -> Bool
$c== :: QueryExecutionStatus -> QueryExecutionStatus -> Bool
Prelude.Eq, ReadPrec [QueryExecutionStatus]
ReadPrec QueryExecutionStatus
Int -> ReadS QueryExecutionStatus
ReadS [QueryExecutionStatus]
(Int -> ReadS QueryExecutionStatus)
-> ReadS [QueryExecutionStatus]
-> ReadPrec QueryExecutionStatus
-> ReadPrec [QueryExecutionStatus]
-> Read QueryExecutionStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueryExecutionStatus]
$creadListPrec :: ReadPrec [QueryExecutionStatus]
readPrec :: ReadPrec QueryExecutionStatus
$creadPrec :: ReadPrec QueryExecutionStatus
readList :: ReadS [QueryExecutionStatus]
$creadList :: ReadS [QueryExecutionStatus]
readsPrec :: Int -> ReadS QueryExecutionStatus
$creadsPrec :: Int -> ReadS QueryExecutionStatus
Prelude.Read, Int -> QueryExecutionStatus -> ShowS
[QueryExecutionStatus] -> ShowS
QueryExecutionStatus -> String
(Int -> QueryExecutionStatus -> ShowS)
-> (QueryExecutionStatus -> String)
-> ([QueryExecutionStatus] -> ShowS)
-> Show QueryExecutionStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueryExecutionStatus] -> ShowS
$cshowList :: [QueryExecutionStatus] -> ShowS
show :: QueryExecutionStatus -> String
$cshow :: QueryExecutionStatus -> String
showsPrec :: Int -> QueryExecutionStatus -> ShowS
$cshowsPrec :: Int -> QueryExecutionStatus -> ShowS
Prelude.Show, (forall x. QueryExecutionStatus -> Rep QueryExecutionStatus x)
-> (forall x. Rep QueryExecutionStatus x -> QueryExecutionStatus)
-> Generic QueryExecutionStatus
forall x. Rep QueryExecutionStatus x -> QueryExecutionStatus
forall x. QueryExecutionStatus -> Rep QueryExecutionStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QueryExecutionStatus x -> QueryExecutionStatus
$cfrom :: forall x. QueryExecutionStatus -> Rep QueryExecutionStatus x
Prelude.Generic)

-- |
-- Create a value of 'QueryExecutionStatus' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'state', 'queryExecutionStatus_state' - The state of query execution. @QUEUED@ indicates that the query has been
-- submitted to the service, and Athena will execute the query as soon as
-- resources are available. @RUNNING@ indicates that the query is in
-- execution phase. @SUCCEEDED@ indicates that the query completed without
-- errors. @FAILED@ indicates that the query experienced an error and did
-- not complete processing. @CANCELLED@ indicates that a user input
-- interrupted query execution.
--
-- Athena automatically retries your queries in cases of certain transient
-- errors. As a result, you may see the query state transition from
-- @RUNNING@ or @FAILED@ to @QUEUED@.
--
-- 'stateChangeReason', 'queryExecutionStatus_stateChangeReason' - Further detail about the status of the query.
--
-- 'submissionDateTime', 'queryExecutionStatus_submissionDateTime' - The date and time that the query was submitted.
--
-- 'completionDateTime', 'queryExecutionStatus_completionDateTime' - The date and time that the query completed.
newQueryExecutionStatus ::
  QueryExecutionStatus
newQueryExecutionStatus :: QueryExecutionStatus
newQueryExecutionStatus =
  QueryExecutionStatus' :: Maybe QueryExecutionState
-> Maybe Text -> Maybe POSIX -> Maybe POSIX -> QueryExecutionStatus
QueryExecutionStatus'
    { $sel:state:QueryExecutionStatus' :: Maybe QueryExecutionState
state = Maybe QueryExecutionState
forall a. Maybe a
Prelude.Nothing,
      $sel:stateChangeReason:QueryExecutionStatus' :: Maybe Text
stateChangeReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:submissionDateTime:QueryExecutionStatus' :: Maybe POSIX
submissionDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:completionDateTime:QueryExecutionStatus' :: Maybe POSIX
completionDateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The state of query execution. @QUEUED@ indicates that the query has been
-- submitted to the service, and Athena will execute the query as soon as
-- resources are available. @RUNNING@ indicates that the query is in
-- execution phase. @SUCCEEDED@ indicates that the query completed without
-- errors. @FAILED@ indicates that the query experienced an error and did
-- not complete processing. @CANCELLED@ indicates that a user input
-- interrupted query execution.
--
-- Athena automatically retries your queries in cases of certain transient
-- errors. As a result, you may see the query state transition from
-- @RUNNING@ or @FAILED@ to @QUEUED@.
queryExecutionStatus_state :: Lens.Lens' QueryExecutionStatus (Prelude.Maybe QueryExecutionState)
queryExecutionStatus_state :: (Maybe QueryExecutionState -> f (Maybe QueryExecutionState))
-> QueryExecutionStatus -> f QueryExecutionStatus
queryExecutionStatus_state = (QueryExecutionStatus -> Maybe QueryExecutionState)
-> (QueryExecutionStatus
    -> Maybe QueryExecutionState -> QueryExecutionStatus)
-> Lens
     QueryExecutionStatus
     QueryExecutionStatus
     (Maybe QueryExecutionState)
     (Maybe QueryExecutionState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryExecutionStatus' {Maybe QueryExecutionState
state :: Maybe QueryExecutionState
$sel:state:QueryExecutionStatus' :: QueryExecutionStatus -> Maybe QueryExecutionState
state} -> Maybe QueryExecutionState
state) (\s :: QueryExecutionStatus
s@QueryExecutionStatus' {} Maybe QueryExecutionState
a -> QueryExecutionStatus
s {$sel:state:QueryExecutionStatus' :: Maybe QueryExecutionState
state = Maybe QueryExecutionState
a} :: QueryExecutionStatus)

-- | Further detail about the status of the query.
queryExecutionStatus_stateChangeReason :: Lens.Lens' QueryExecutionStatus (Prelude.Maybe Prelude.Text)
queryExecutionStatus_stateChangeReason :: (Maybe Text -> f (Maybe Text))
-> QueryExecutionStatus -> f QueryExecutionStatus
queryExecutionStatus_stateChangeReason = (QueryExecutionStatus -> Maybe Text)
-> (QueryExecutionStatus -> Maybe Text -> QueryExecutionStatus)
-> Lens
     QueryExecutionStatus QueryExecutionStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryExecutionStatus' {Maybe Text
stateChangeReason :: Maybe Text
$sel:stateChangeReason:QueryExecutionStatus' :: QueryExecutionStatus -> Maybe Text
stateChangeReason} -> Maybe Text
stateChangeReason) (\s :: QueryExecutionStatus
s@QueryExecutionStatus' {} Maybe Text
a -> QueryExecutionStatus
s {$sel:stateChangeReason:QueryExecutionStatus' :: Maybe Text
stateChangeReason = Maybe Text
a} :: QueryExecutionStatus)

-- | The date and time that the query was submitted.
queryExecutionStatus_submissionDateTime :: Lens.Lens' QueryExecutionStatus (Prelude.Maybe Prelude.UTCTime)
queryExecutionStatus_submissionDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> QueryExecutionStatus -> f QueryExecutionStatus
queryExecutionStatus_submissionDateTime = (QueryExecutionStatus -> Maybe POSIX)
-> (QueryExecutionStatus -> Maybe POSIX -> QueryExecutionStatus)
-> Lens
     QueryExecutionStatus
     QueryExecutionStatus
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryExecutionStatus' {Maybe POSIX
submissionDateTime :: Maybe POSIX
$sel:submissionDateTime:QueryExecutionStatus' :: QueryExecutionStatus -> Maybe POSIX
submissionDateTime} -> Maybe POSIX
submissionDateTime) (\s :: QueryExecutionStatus
s@QueryExecutionStatus' {} Maybe POSIX
a -> QueryExecutionStatus
s {$sel:submissionDateTime:QueryExecutionStatus' :: Maybe POSIX
submissionDateTime = Maybe POSIX
a} :: QueryExecutionStatus) ((Maybe POSIX -> f (Maybe POSIX))
 -> QueryExecutionStatus -> f QueryExecutionStatus)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> QueryExecutionStatus
-> f QueryExecutionStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The date and time that the query completed.
queryExecutionStatus_completionDateTime :: Lens.Lens' QueryExecutionStatus (Prelude.Maybe Prelude.UTCTime)
queryExecutionStatus_completionDateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> QueryExecutionStatus -> f QueryExecutionStatus
queryExecutionStatus_completionDateTime = (QueryExecutionStatus -> Maybe POSIX)
-> (QueryExecutionStatus -> Maybe POSIX -> QueryExecutionStatus)
-> Lens
     QueryExecutionStatus
     QueryExecutionStatus
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QueryExecutionStatus' {Maybe POSIX
completionDateTime :: Maybe POSIX
$sel:completionDateTime:QueryExecutionStatus' :: QueryExecutionStatus -> Maybe POSIX
completionDateTime} -> Maybe POSIX
completionDateTime) (\s :: QueryExecutionStatus
s@QueryExecutionStatus' {} Maybe POSIX
a -> QueryExecutionStatus
s {$sel:completionDateTime:QueryExecutionStatus' :: Maybe POSIX
completionDateTime = Maybe POSIX
a} :: QueryExecutionStatus) ((Maybe POSIX -> f (Maybe POSIX))
 -> QueryExecutionStatus -> f QueryExecutionStatus)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> QueryExecutionStatus
-> f QueryExecutionStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON QueryExecutionStatus where
  parseJSON :: Value -> Parser QueryExecutionStatus
parseJSON =
    String
-> (Object -> Parser QueryExecutionStatus)
-> Value
-> Parser QueryExecutionStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"QueryExecutionStatus"
      ( \Object
x ->
          Maybe QueryExecutionState
-> Maybe Text -> Maybe POSIX -> Maybe POSIX -> QueryExecutionStatus
QueryExecutionStatus'
            (Maybe QueryExecutionState
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe POSIX
 -> QueryExecutionStatus)
-> Parser (Maybe QueryExecutionState)
-> Parser
     (Maybe Text -> Maybe POSIX -> Maybe POSIX -> QueryExecutionStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe QueryExecutionState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe Text -> Maybe POSIX -> Maybe POSIX -> QueryExecutionStatus)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe POSIX -> QueryExecutionStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StateChangeReason")
            Parser (Maybe POSIX -> Maybe POSIX -> QueryExecutionStatus)
-> Parser (Maybe POSIX)
-> Parser (Maybe POSIX -> QueryExecutionStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SubmissionDateTime")
            Parser (Maybe POSIX -> QueryExecutionStatus)
-> Parser (Maybe POSIX) -> Parser QueryExecutionStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CompletionDateTime")
      )

instance Prelude.Hashable QueryExecutionStatus

instance Prelude.NFData QueryExecutionStatus