{-# 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.Glue.Types.Statement
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.Statement where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.StatementOutput
import Amazonka.Glue.Types.StatementState
import qualified Amazonka.Prelude as Prelude

-- | The statement or request for a particular action to occur in a session.
--
-- /See:/ 'newStatement' smart constructor.
data Statement = Statement'
  { -- | The execution code of the statement.
    Statement -> Maybe Text
code :: Prelude.Maybe Prelude.Text,
    -- | The unix time and date that the job definition was completed.
    Statement -> Maybe Integer
completedOn :: Prelude.Maybe Prelude.Integer,
    -- | The ID of the statement.
    Statement -> Maybe Int
id :: Prelude.Maybe Prelude.Int,
    -- | The output in JSON.
    Statement -> Maybe StatementOutput
output :: Prelude.Maybe StatementOutput,
    -- | The code execution progress.
    Statement -> Maybe Double
progress :: Prelude.Maybe Prelude.Double,
    -- | The unix time and date that the job definition was started.
    Statement -> Maybe Integer
startedOn :: Prelude.Maybe Prelude.Integer,
    -- | The state while request is actioned.
    Statement -> Maybe StatementState
state :: Prelude.Maybe StatementState
  }
  deriving (Statement -> Statement -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Statement -> Statement -> Bool
$c/= :: Statement -> Statement -> Bool
== :: Statement -> Statement -> Bool
$c== :: Statement -> Statement -> Bool
Prelude.Eq, ReadPrec [Statement]
ReadPrec Statement
Int -> ReadS Statement
ReadS [Statement]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Statement]
$creadListPrec :: ReadPrec [Statement]
readPrec :: ReadPrec Statement
$creadPrec :: ReadPrec Statement
readList :: ReadS [Statement]
$creadList :: ReadS [Statement]
readsPrec :: Int -> ReadS Statement
$creadsPrec :: Int -> ReadS Statement
Prelude.Read, Int -> Statement -> ShowS
[Statement] -> ShowS
Statement -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Statement] -> ShowS
$cshowList :: [Statement] -> ShowS
show :: Statement -> String
$cshow :: Statement -> String
showsPrec :: Int -> Statement -> ShowS
$cshowsPrec :: Int -> Statement -> ShowS
Prelude.Show, forall x. Rep Statement x -> Statement
forall x. Statement -> Rep Statement x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Statement x -> Statement
$cfrom :: forall x. Statement -> Rep Statement x
Prelude.Generic)

-- |
-- Create a value of 'Statement' 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:
--
-- 'code', 'statement_code' - The execution code of the statement.
--
-- 'completedOn', 'statement_completedOn' - The unix time and date that the job definition was completed.
--
-- 'id', 'statement_id' - The ID of the statement.
--
-- 'output', 'statement_output' - The output in JSON.
--
-- 'progress', 'statement_progress' - The code execution progress.
--
-- 'startedOn', 'statement_startedOn' - The unix time and date that the job definition was started.
--
-- 'state', 'statement_state' - The state while request is actioned.
newStatement ::
  Statement
newStatement :: Statement
newStatement =
  Statement'
    { $sel:code:Statement' :: Maybe Text
code = forall a. Maybe a
Prelude.Nothing,
      $sel:completedOn:Statement' :: Maybe Integer
completedOn = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Statement' :: Maybe Int
id = forall a. Maybe a
Prelude.Nothing,
      $sel:output:Statement' :: Maybe StatementOutput
output = forall a. Maybe a
Prelude.Nothing,
      $sel:progress:Statement' :: Maybe Double
progress = forall a. Maybe a
Prelude.Nothing,
      $sel:startedOn:Statement' :: Maybe Integer
startedOn = forall a. Maybe a
Prelude.Nothing,
      $sel:state:Statement' :: Maybe StatementState
state = forall a. Maybe a
Prelude.Nothing
    }

-- | The execution code of the statement.
statement_code :: Lens.Lens' Statement (Prelude.Maybe Prelude.Text)
statement_code :: Lens' Statement (Maybe Text)
statement_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Text
code :: Maybe Text
$sel:code:Statement' :: Statement -> Maybe Text
code} -> Maybe Text
code) (\s :: Statement
s@Statement' {} Maybe Text
a -> Statement
s {$sel:code:Statement' :: Maybe Text
code = Maybe Text
a} :: Statement)

-- | The unix time and date that the job definition was completed.
statement_completedOn :: Lens.Lens' Statement (Prelude.Maybe Prelude.Integer)
statement_completedOn :: Lens' Statement (Maybe Integer)
statement_completedOn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Integer
completedOn :: Maybe Integer
$sel:completedOn:Statement' :: Statement -> Maybe Integer
completedOn} -> Maybe Integer
completedOn) (\s :: Statement
s@Statement' {} Maybe Integer
a -> Statement
s {$sel:completedOn:Statement' :: Maybe Integer
completedOn = Maybe Integer
a} :: Statement)

-- | The ID of the statement.
statement_id :: Lens.Lens' Statement (Prelude.Maybe Prelude.Int)
statement_id :: Lens' Statement (Maybe Int)
statement_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Int
id :: Maybe Int
$sel:id:Statement' :: Statement -> Maybe Int
id} -> Maybe Int
id) (\s :: Statement
s@Statement' {} Maybe Int
a -> Statement
s {$sel:id:Statement' :: Maybe Int
id = Maybe Int
a} :: Statement)

-- | The output in JSON.
statement_output :: Lens.Lens' Statement (Prelude.Maybe StatementOutput)
statement_output :: Lens' Statement (Maybe StatementOutput)
statement_output = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe StatementOutput
output :: Maybe StatementOutput
$sel:output:Statement' :: Statement -> Maybe StatementOutput
output} -> Maybe StatementOutput
output) (\s :: Statement
s@Statement' {} Maybe StatementOutput
a -> Statement
s {$sel:output:Statement' :: Maybe StatementOutput
output = Maybe StatementOutput
a} :: Statement)

-- | The code execution progress.
statement_progress :: Lens.Lens' Statement (Prelude.Maybe Prelude.Double)
statement_progress :: Lens' Statement (Maybe Double)
statement_progress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Double
progress :: Maybe Double
$sel:progress:Statement' :: Statement -> Maybe Double
progress} -> Maybe Double
progress) (\s :: Statement
s@Statement' {} Maybe Double
a -> Statement
s {$sel:progress:Statement' :: Maybe Double
progress = Maybe Double
a} :: Statement)

-- | The unix time and date that the job definition was started.
statement_startedOn :: Lens.Lens' Statement (Prelude.Maybe Prelude.Integer)
statement_startedOn :: Lens' Statement (Maybe Integer)
statement_startedOn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe Integer
startedOn :: Maybe Integer
$sel:startedOn:Statement' :: Statement -> Maybe Integer
startedOn} -> Maybe Integer
startedOn) (\s :: Statement
s@Statement' {} Maybe Integer
a -> Statement
s {$sel:startedOn:Statement' :: Maybe Integer
startedOn = Maybe Integer
a} :: Statement)

-- | The state while request is actioned.
statement_state :: Lens.Lens' Statement (Prelude.Maybe StatementState)
statement_state :: Lens' Statement (Maybe StatementState)
statement_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Statement' {Maybe StatementState
state :: Maybe StatementState
$sel:state:Statement' :: Statement -> Maybe StatementState
state} -> Maybe StatementState
state) (\s :: Statement
s@Statement' {} Maybe StatementState
a -> Statement
s {$sel:state:Statement' :: Maybe StatementState
state = Maybe StatementState
a} :: Statement)

instance Data.FromJSON Statement where
  parseJSON :: Value -> Parser Statement
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Statement"
      ( \Object
x ->
          Maybe Text
-> Maybe Integer
-> Maybe Int
-> Maybe StatementOutput
-> Maybe Double
-> Maybe Integer
-> Maybe StatementState
-> Statement
Statement'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Code")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"CompletedOn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Output")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Progress")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StartedOn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"State")
      )

instance Prelude.Hashable Statement where
  hashWithSalt :: Int -> Statement -> Int
hashWithSalt Int
_salt Statement' {Maybe Double
Maybe Int
Maybe Integer
Maybe Text
Maybe StatementState
Maybe StatementOutput
state :: Maybe StatementState
startedOn :: Maybe Integer
progress :: Maybe Double
output :: Maybe StatementOutput
id :: Maybe Int
completedOn :: Maybe Integer
code :: Maybe Text
$sel:state:Statement' :: Statement -> Maybe StatementState
$sel:startedOn:Statement' :: Statement -> Maybe Integer
$sel:progress:Statement' :: Statement -> Maybe Double
$sel:output:Statement' :: Statement -> Maybe StatementOutput
$sel:id:Statement' :: Statement -> Maybe Int
$sel:completedOn:Statement' :: Statement -> Maybe Integer
$sel:code:Statement' :: Statement -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
completedOn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StatementOutput
output
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
progress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
startedOn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StatementState
state

instance Prelude.NFData Statement where
  rnf :: Statement -> ()
rnf Statement' {Maybe Double
Maybe Int
Maybe Integer
Maybe Text
Maybe StatementState
Maybe StatementOutput
state :: Maybe StatementState
startedOn :: Maybe Integer
progress :: Maybe Double
output :: Maybe StatementOutput
id :: Maybe Int
completedOn :: Maybe Integer
code :: Maybe Text
$sel:state:Statement' :: Statement -> Maybe StatementState
$sel:startedOn:Statement' :: Statement -> Maybe Integer
$sel:progress:Statement' :: Statement -> Maybe Double
$sel:output:Statement' :: Statement -> Maybe StatementOutput
$sel:id:Statement' :: Statement -> Maybe Int
$sel:completedOn:Statement' :: Statement -> Maybe Integer
$sel:code:Statement' :: Statement -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
completedOn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StatementOutput
output
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
progress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
startedOn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StatementState
state