{-# 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.StatementOutput
-- 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.StatementOutput 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.StatementOutputData
import Amazonka.Glue.Types.StatementState
import qualified Amazonka.Prelude as Prelude

-- | The code execution output in JSON format.
--
-- /See:/ 'newStatementOutput' smart constructor.
data StatementOutput = StatementOutput'
  { -- | The code execution output.
    StatementOutput -> Maybe StatementOutputData
data' :: Prelude.Maybe StatementOutputData,
    -- | The name of the error in the output.
    StatementOutput -> Maybe Text
errorName :: Prelude.Maybe Prelude.Text,
    -- | The error value of the output.
    StatementOutput -> Maybe Text
errorValue :: Prelude.Maybe Prelude.Text,
    -- | The execution count of the output.
    StatementOutput -> Maybe Int
executionCount :: Prelude.Maybe Prelude.Int,
    -- | The status of the code execution output.
    StatementOutput -> Maybe StatementState
status :: Prelude.Maybe StatementState,
    -- | The traceback of the output.
    StatementOutput -> Maybe [Text]
traceback :: Prelude.Maybe [Prelude.Text]
  }
  deriving (StatementOutput -> StatementOutput -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatementOutput -> StatementOutput -> Bool
$c/= :: StatementOutput -> StatementOutput -> Bool
== :: StatementOutput -> StatementOutput -> Bool
$c== :: StatementOutput -> StatementOutput -> Bool
Prelude.Eq, ReadPrec [StatementOutput]
ReadPrec StatementOutput
Int -> ReadS StatementOutput
ReadS [StatementOutput]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatementOutput]
$creadListPrec :: ReadPrec [StatementOutput]
readPrec :: ReadPrec StatementOutput
$creadPrec :: ReadPrec StatementOutput
readList :: ReadS [StatementOutput]
$creadList :: ReadS [StatementOutput]
readsPrec :: Int -> ReadS StatementOutput
$creadsPrec :: Int -> ReadS StatementOutput
Prelude.Read, Int -> StatementOutput -> ShowS
[StatementOutput] -> ShowS
StatementOutput -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatementOutput] -> ShowS
$cshowList :: [StatementOutput] -> ShowS
show :: StatementOutput -> String
$cshow :: StatementOutput -> String
showsPrec :: Int -> StatementOutput -> ShowS
$cshowsPrec :: Int -> StatementOutput -> ShowS
Prelude.Show, forall x. Rep StatementOutput x -> StatementOutput
forall x. StatementOutput -> Rep StatementOutput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatementOutput x -> StatementOutput
$cfrom :: forall x. StatementOutput -> Rep StatementOutput x
Prelude.Generic)

-- |
-- Create a value of 'StatementOutput' 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:
--
-- 'data'', 'statementOutput_data' - The code execution output.
--
-- 'errorName', 'statementOutput_errorName' - The name of the error in the output.
--
-- 'errorValue', 'statementOutput_errorValue' - The error value of the output.
--
-- 'executionCount', 'statementOutput_executionCount' - The execution count of the output.
--
-- 'status', 'statementOutput_status' - The status of the code execution output.
--
-- 'traceback', 'statementOutput_traceback' - The traceback of the output.
newStatementOutput ::
  StatementOutput
newStatementOutput :: StatementOutput
newStatementOutput =
  StatementOutput'
    { $sel:data':StatementOutput' :: Maybe StatementOutputData
data' = forall a. Maybe a
Prelude.Nothing,
      $sel:errorName:StatementOutput' :: Maybe Text
errorName = forall a. Maybe a
Prelude.Nothing,
      $sel:errorValue:StatementOutput' :: Maybe Text
errorValue = forall a. Maybe a
Prelude.Nothing,
      $sel:executionCount:StatementOutput' :: Maybe Int
executionCount = forall a. Maybe a
Prelude.Nothing,
      $sel:status:StatementOutput' :: Maybe StatementState
status = forall a. Maybe a
Prelude.Nothing,
      $sel:traceback:StatementOutput' :: Maybe [Text]
traceback = forall a. Maybe a
Prelude.Nothing
    }

-- | The code execution output.
statementOutput_data :: Lens.Lens' StatementOutput (Prelude.Maybe StatementOutputData)
statementOutput_data :: Lens' StatementOutput (Maybe StatementOutputData)
statementOutput_data = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatementOutput' {Maybe StatementOutputData
data' :: Maybe StatementOutputData
$sel:data':StatementOutput' :: StatementOutput -> Maybe StatementOutputData
data'} -> Maybe StatementOutputData
data') (\s :: StatementOutput
s@StatementOutput' {} Maybe StatementOutputData
a -> StatementOutput
s {$sel:data':StatementOutput' :: Maybe StatementOutputData
data' = Maybe StatementOutputData
a} :: StatementOutput)

-- | The name of the error in the output.
statementOutput_errorName :: Lens.Lens' StatementOutput (Prelude.Maybe Prelude.Text)
statementOutput_errorName :: Lens' StatementOutput (Maybe Text)
statementOutput_errorName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatementOutput' {Maybe Text
errorName :: Maybe Text
$sel:errorName:StatementOutput' :: StatementOutput -> Maybe Text
errorName} -> Maybe Text
errorName) (\s :: StatementOutput
s@StatementOutput' {} Maybe Text
a -> StatementOutput
s {$sel:errorName:StatementOutput' :: Maybe Text
errorName = Maybe Text
a} :: StatementOutput)

-- | The error value of the output.
statementOutput_errorValue :: Lens.Lens' StatementOutput (Prelude.Maybe Prelude.Text)
statementOutput_errorValue :: Lens' StatementOutput (Maybe Text)
statementOutput_errorValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatementOutput' {Maybe Text
errorValue :: Maybe Text
$sel:errorValue:StatementOutput' :: StatementOutput -> Maybe Text
errorValue} -> Maybe Text
errorValue) (\s :: StatementOutput
s@StatementOutput' {} Maybe Text
a -> StatementOutput
s {$sel:errorValue:StatementOutput' :: Maybe Text
errorValue = Maybe Text
a} :: StatementOutput)

-- | The execution count of the output.
statementOutput_executionCount :: Lens.Lens' StatementOutput (Prelude.Maybe Prelude.Int)
statementOutput_executionCount :: Lens' StatementOutput (Maybe Int)
statementOutput_executionCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatementOutput' {Maybe Int
executionCount :: Maybe Int
$sel:executionCount:StatementOutput' :: StatementOutput -> Maybe Int
executionCount} -> Maybe Int
executionCount) (\s :: StatementOutput
s@StatementOutput' {} Maybe Int
a -> StatementOutput
s {$sel:executionCount:StatementOutput' :: Maybe Int
executionCount = Maybe Int
a} :: StatementOutput)

-- | The status of the code execution output.
statementOutput_status :: Lens.Lens' StatementOutput (Prelude.Maybe StatementState)
statementOutput_status :: Lens' StatementOutput (Maybe StatementState)
statementOutput_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatementOutput' {Maybe StatementState
status :: Maybe StatementState
$sel:status:StatementOutput' :: StatementOutput -> Maybe StatementState
status} -> Maybe StatementState
status) (\s :: StatementOutput
s@StatementOutput' {} Maybe StatementState
a -> StatementOutput
s {$sel:status:StatementOutput' :: Maybe StatementState
status = Maybe StatementState
a} :: StatementOutput)

-- | The traceback of the output.
statementOutput_traceback :: Lens.Lens' StatementOutput (Prelude.Maybe [Prelude.Text])
statementOutput_traceback :: Lens' StatementOutput (Maybe [Text])
statementOutput_traceback = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatementOutput' {Maybe [Text]
traceback :: Maybe [Text]
$sel:traceback:StatementOutput' :: StatementOutput -> Maybe [Text]
traceback} -> Maybe [Text]
traceback) (\s :: StatementOutput
s@StatementOutput' {} Maybe [Text]
a -> StatementOutput
s {$sel:traceback:StatementOutput' :: Maybe [Text]
traceback = Maybe [Text]
a} :: StatementOutput) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON StatementOutput where
  parseJSON :: Value -> Parser StatementOutput
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StatementOutput"
      ( \Object
x ->
          Maybe StatementOutputData
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe StatementState
-> Maybe [Text]
-> StatementOutput
StatementOutput'
            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
"Data")
            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
"ErrorName")
            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
"ErrorValue")
            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
"ExecutionCount")
            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
"Status")
            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
"Traceback" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable StatementOutput where
  hashWithSalt :: Int -> StatementOutput -> Int
hashWithSalt Int
_salt StatementOutput' {Maybe Int
Maybe [Text]
Maybe Text
Maybe StatementOutputData
Maybe StatementState
traceback :: Maybe [Text]
status :: Maybe StatementState
executionCount :: Maybe Int
errorValue :: Maybe Text
errorName :: Maybe Text
data' :: Maybe StatementOutputData
$sel:traceback:StatementOutput' :: StatementOutput -> Maybe [Text]
$sel:status:StatementOutput' :: StatementOutput -> Maybe StatementState
$sel:executionCount:StatementOutput' :: StatementOutput -> Maybe Int
$sel:errorValue:StatementOutput' :: StatementOutput -> Maybe Text
$sel:errorName:StatementOutput' :: StatementOutput -> Maybe Text
$sel:data':StatementOutput' :: StatementOutput -> Maybe StatementOutputData
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StatementOutputData
data'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
errorValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
executionCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StatementState
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
traceback

instance Prelude.NFData StatementOutput where
  rnf :: StatementOutput -> ()
rnf StatementOutput' {Maybe Int
Maybe [Text]
Maybe Text
Maybe StatementOutputData
Maybe StatementState
traceback :: Maybe [Text]
status :: Maybe StatementState
executionCount :: Maybe Int
errorValue :: Maybe Text
errorName :: Maybe Text
data' :: Maybe StatementOutputData
$sel:traceback:StatementOutput' :: StatementOutput -> Maybe [Text]
$sel:status:StatementOutput' :: StatementOutput -> Maybe StatementState
$sel:executionCount:StatementOutput' :: StatementOutput -> Maybe Int
$sel:errorValue:StatementOutput' :: StatementOutput -> Maybe Text
$sel:errorName:StatementOutput' :: StatementOutput -> Maybe Text
$sel:data':StatementOutput' :: StatementOutput -> Maybe StatementOutputData
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StatementOutputData
data'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
errorValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
executionCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StatementState
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
traceback