{-# 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.CodeGenNodeArg
-- 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.Glue.Types.CodeGenNodeArg where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An argument or property of a node.
--
-- /See:/ 'newCodeGenNodeArg' smart constructor.
data CodeGenNodeArg = CodeGenNodeArg'
  { -- | True if the value is used as a parameter.
    CodeGenNodeArg -> Maybe Bool
param :: Prelude.Maybe Prelude.Bool,
    -- | The name of the argument or property.
    CodeGenNodeArg -> Text
name :: Prelude.Text,
    -- | The value of the argument or property.
    CodeGenNodeArg -> Text
value :: Prelude.Text
  }
  deriving (CodeGenNodeArg -> CodeGenNodeArg -> Bool
(CodeGenNodeArg -> CodeGenNodeArg -> Bool)
-> (CodeGenNodeArg -> CodeGenNodeArg -> Bool) -> Eq CodeGenNodeArg
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeGenNodeArg -> CodeGenNodeArg -> Bool
$c/= :: CodeGenNodeArg -> CodeGenNodeArg -> Bool
== :: CodeGenNodeArg -> CodeGenNodeArg -> Bool
$c== :: CodeGenNodeArg -> CodeGenNodeArg -> Bool
Prelude.Eq, ReadPrec [CodeGenNodeArg]
ReadPrec CodeGenNodeArg
Int -> ReadS CodeGenNodeArg
ReadS [CodeGenNodeArg]
(Int -> ReadS CodeGenNodeArg)
-> ReadS [CodeGenNodeArg]
-> ReadPrec CodeGenNodeArg
-> ReadPrec [CodeGenNodeArg]
-> Read CodeGenNodeArg
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeGenNodeArg]
$creadListPrec :: ReadPrec [CodeGenNodeArg]
readPrec :: ReadPrec CodeGenNodeArg
$creadPrec :: ReadPrec CodeGenNodeArg
readList :: ReadS [CodeGenNodeArg]
$creadList :: ReadS [CodeGenNodeArg]
readsPrec :: Int -> ReadS CodeGenNodeArg
$creadsPrec :: Int -> ReadS CodeGenNodeArg
Prelude.Read, Int -> CodeGenNodeArg -> ShowS
[CodeGenNodeArg] -> ShowS
CodeGenNodeArg -> String
(Int -> CodeGenNodeArg -> ShowS)
-> (CodeGenNodeArg -> String)
-> ([CodeGenNodeArg] -> ShowS)
-> Show CodeGenNodeArg
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeGenNodeArg] -> ShowS
$cshowList :: [CodeGenNodeArg] -> ShowS
show :: CodeGenNodeArg -> String
$cshow :: CodeGenNodeArg -> String
showsPrec :: Int -> CodeGenNodeArg -> ShowS
$cshowsPrec :: Int -> CodeGenNodeArg -> ShowS
Prelude.Show, (forall x. CodeGenNodeArg -> Rep CodeGenNodeArg x)
-> (forall x. Rep CodeGenNodeArg x -> CodeGenNodeArg)
-> Generic CodeGenNodeArg
forall x. Rep CodeGenNodeArg x -> CodeGenNodeArg
forall x. CodeGenNodeArg -> Rep CodeGenNodeArg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeGenNodeArg x -> CodeGenNodeArg
$cfrom :: forall x. CodeGenNodeArg -> Rep CodeGenNodeArg x
Prelude.Generic)

-- |
-- Create a value of 'CodeGenNodeArg' 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:
--
-- 'param', 'codeGenNodeArg_param' - True if the value is used as a parameter.
--
-- 'name', 'codeGenNodeArg_name' - The name of the argument or property.
--
-- 'value', 'codeGenNodeArg_value' - The value of the argument or property.
newCodeGenNodeArg ::
  -- | 'name'
  Prelude.Text ->
  -- | 'value'
  Prelude.Text ->
  CodeGenNodeArg
newCodeGenNodeArg :: Text -> Text -> CodeGenNodeArg
newCodeGenNodeArg Text
pName_ Text
pValue_ =
  CodeGenNodeArg' :: Maybe Bool -> Text -> Text -> CodeGenNodeArg
CodeGenNodeArg'
    { $sel:param:CodeGenNodeArg' :: Maybe Bool
param = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CodeGenNodeArg' :: Text
name = Text
pName_,
      $sel:value:CodeGenNodeArg' :: Text
value = Text
pValue_
    }

-- | True if the value is used as a parameter.
codeGenNodeArg_param :: Lens.Lens' CodeGenNodeArg (Prelude.Maybe Prelude.Bool)
codeGenNodeArg_param :: (Maybe Bool -> f (Maybe Bool))
-> CodeGenNodeArg -> f CodeGenNodeArg
codeGenNodeArg_param = (CodeGenNodeArg -> Maybe Bool)
-> (CodeGenNodeArg -> Maybe Bool -> CodeGenNodeArg)
-> Lens CodeGenNodeArg CodeGenNodeArg (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeGenNodeArg' {Maybe Bool
param :: Maybe Bool
$sel:param:CodeGenNodeArg' :: CodeGenNodeArg -> Maybe Bool
param} -> Maybe Bool
param) (\s :: CodeGenNodeArg
s@CodeGenNodeArg' {} Maybe Bool
a -> CodeGenNodeArg
s {$sel:param:CodeGenNodeArg' :: Maybe Bool
param = Maybe Bool
a} :: CodeGenNodeArg)

-- | The name of the argument or property.
codeGenNodeArg_name :: Lens.Lens' CodeGenNodeArg Prelude.Text
codeGenNodeArg_name :: (Text -> f Text) -> CodeGenNodeArg -> f CodeGenNodeArg
codeGenNodeArg_name = (CodeGenNodeArg -> Text)
-> (CodeGenNodeArg -> Text -> CodeGenNodeArg)
-> Lens CodeGenNodeArg CodeGenNodeArg Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeGenNodeArg' {Text
name :: Text
$sel:name:CodeGenNodeArg' :: CodeGenNodeArg -> Text
name} -> Text
name) (\s :: CodeGenNodeArg
s@CodeGenNodeArg' {} Text
a -> CodeGenNodeArg
s {$sel:name:CodeGenNodeArg' :: Text
name = Text
a} :: CodeGenNodeArg)

-- | The value of the argument or property.
codeGenNodeArg_value :: Lens.Lens' CodeGenNodeArg Prelude.Text
codeGenNodeArg_value :: (Text -> f Text) -> CodeGenNodeArg -> f CodeGenNodeArg
codeGenNodeArg_value = (CodeGenNodeArg -> Text)
-> (CodeGenNodeArg -> Text -> CodeGenNodeArg)
-> Lens CodeGenNodeArg CodeGenNodeArg Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeGenNodeArg' {Text
value :: Text
$sel:value:CodeGenNodeArg' :: CodeGenNodeArg -> Text
value} -> Text
value) (\s :: CodeGenNodeArg
s@CodeGenNodeArg' {} Text
a -> CodeGenNodeArg
s {$sel:value:CodeGenNodeArg' :: Text
value = Text
a} :: CodeGenNodeArg)

instance Core.FromJSON CodeGenNodeArg where
  parseJSON :: Value -> Parser CodeGenNodeArg
parseJSON =
    String
-> (Object -> Parser CodeGenNodeArg)
-> Value
-> Parser CodeGenNodeArg
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CodeGenNodeArg"
      ( \Object
x ->
          Maybe Bool -> Text -> Text -> CodeGenNodeArg
CodeGenNodeArg'
            (Maybe Bool -> Text -> Text -> CodeGenNodeArg)
-> Parser (Maybe Bool) -> Parser (Text -> Text -> CodeGenNodeArg)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Param")
            Parser (Text -> Text -> CodeGenNodeArg)
-> Parser Text -> Parser (Text -> CodeGenNodeArg)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
            Parser (Text -> CodeGenNodeArg)
-> Parser Text -> Parser CodeGenNodeArg
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Value")
      )

instance Prelude.Hashable CodeGenNodeArg

instance Prelude.NFData CodeGenNodeArg

instance Core.ToJSON CodeGenNodeArg where
  toJSON :: CodeGenNodeArg -> Value
toJSON CodeGenNodeArg' {Maybe Bool
Text
value :: Text
name :: Text
param :: Maybe Bool
$sel:value:CodeGenNodeArg' :: CodeGenNodeArg -> Text
$sel:name:CodeGenNodeArg' :: CodeGenNodeArg -> Text
$sel:param:CodeGenNodeArg' :: CodeGenNodeArg -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Param" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
param,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Value" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
value)
          ]
      )