{-# 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.CodeGenEdge
-- 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.CodeGenEdge where

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

-- | Represents a directional edge in a directed acyclic graph (DAG).
--
-- /See:/ 'newCodeGenEdge' smart constructor.
data CodeGenEdge = CodeGenEdge'
  { -- | The target of the edge.
    CodeGenEdge -> Maybe Text
targetParameter :: Prelude.Maybe Prelude.Text,
    -- | The ID of the node at which the edge starts.
    CodeGenEdge -> Text
source :: Prelude.Text,
    -- | The ID of the node at which the edge ends.
    CodeGenEdge -> Text
target :: Prelude.Text
  }
  deriving (CodeGenEdge -> CodeGenEdge -> Bool
(CodeGenEdge -> CodeGenEdge -> Bool)
-> (CodeGenEdge -> CodeGenEdge -> Bool) -> Eq CodeGenEdge
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeGenEdge -> CodeGenEdge -> Bool
$c/= :: CodeGenEdge -> CodeGenEdge -> Bool
== :: CodeGenEdge -> CodeGenEdge -> Bool
$c== :: CodeGenEdge -> CodeGenEdge -> Bool
Prelude.Eq, ReadPrec [CodeGenEdge]
ReadPrec CodeGenEdge
Int -> ReadS CodeGenEdge
ReadS [CodeGenEdge]
(Int -> ReadS CodeGenEdge)
-> ReadS [CodeGenEdge]
-> ReadPrec CodeGenEdge
-> ReadPrec [CodeGenEdge]
-> Read CodeGenEdge
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeGenEdge]
$creadListPrec :: ReadPrec [CodeGenEdge]
readPrec :: ReadPrec CodeGenEdge
$creadPrec :: ReadPrec CodeGenEdge
readList :: ReadS [CodeGenEdge]
$creadList :: ReadS [CodeGenEdge]
readsPrec :: Int -> ReadS CodeGenEdge
$creadsPrec :: Int -> ReadS CodeGenEdge
Prelude.Read, Int -> CodeGenEdge -> ShowS
[CodeGenEdge] -> ShowS
CodeGenEdge -> String
(Int -> CodeGenEdge -> ShowS)
-> (CodeGenEdge -> String)
-> ([CodeGenEdge] -> ShowS)
-> Show CodeGenEdge
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeGenEdge] -> ShowS
$cshowList :: [CodeGenEdge] -> ShowS
show :: CodeGenEdge -> String
$cshow :: CodeGenEdge -> String
showsPrec :: Int -> CodeGenEdge -> ShowS
$cshowsPrec :: Int -> CodeGenEdge -> ShowS
Prelude.Show, (forall x. CodeGenEdge -> Rep CodeGenEdge x)
-> (forall x. Rep CodeGenEdge x -> CodeGenEdge)
-> Generic CodeGenEdge
forall x. Rep CodeGenEdge x -> CodeGenEdge
forall x. CodeGenEdge -> Rep CodeGenEdge x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeGenEdge x -> CodeGenEdge
$cfrom :: forall x. CodeGenEdge -> Rep CodeGenEdge x
Prelude.Generic)

-- |
-- Create a value of 'CodeGenEdge' 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:
--
-- 'targetParameter', 'codeGenEdge_targetParameter' - The target of the edge.
--
-- 'source', 'codeGenEdge_source' - The ID of the node at which the edge starts.
--
-- 'target', 'codeGenEdge_target' - The ID of the node at which the edge ends.
newCodeGenEdge ::
  -- | 'source'
  Prelude.Text ->
  -- | 'target'
  Prelude.Text ->
  CodeGenEdge
newCodeGenEdge :: Text -> Text -> CodeGenEdge
newCodeGenEdge Text
pSource_ Text
pTarget_ =
  CodeGenEdge' :: Maybe Text -> Text -> Text -> CodeGenEdge
CodeGenEdge'
    { $sel:targetParameter:CodeGenEdge' :: Maybe Text
targetParameter = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:source:CodeGenEdge' :: Text
source = Text
pSource_,
      $sel:target:CodeGenEdge' :: Text
target = Text
pTarget_
    }

-- | The target of the edge.
codeGenEdge_targetParameter :: Lens.Lens' CodeGenEdge (Prelude.Maybe Prelude.Text)
codeGenEdge_targetParameter :: (Maybe Text -> f (Maybe Text)) -> CodeGenEdge -> f CodeGenEdge
codeGenEdge_targetParameter = (CodeGenEdge -> Maybe Text)
-> (CodeGenEdge -> Maybe Text -> CodeGenEdge)
-> Lens CodeGenEdge CodeGenEdge (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeGenEdge' {Maybe Text
targetParameter :: Maybe Text
$sel:targetParameter:CodeGenEdge' :: CodeGenEdge -> Maybe Text
targetParameter} -> Maybe Text
targetParameter) (\s :: CodeGenEdge
s@CodeGenEdge' {} Maybe Text
a -> CodeGenEdge
s {$sel:targetParameter:CodeGenEdge' :: Maybe Text
targetParameter = Maybe Text
a} :: CodeGenEdge)

-- | The ID of the node at which the edge starts.
codeGenEdge_source :: Lens.Lens' CodeGenEdge Prelude.Text
codeGenEdge_source :: (Text -> f Text) -> CodeGenEdge -> f CodeGenEdge
codeGenEdge_source = (CodeGenEdge -> Text)
-> (CodeGenEdge -> Text -> CodeGenEdge)
-> Lens CodeGenEdge CodeGenEdge Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeGenEdge' {Text
source :: Text
$sel:source:CodeGenEdge' :: CodeGenEdge -> Text
source} -> Text
source) (\s :: CodeGenEdge
s@CodeGenEdge' {} Text
a -> CodeGenEdge
s {$sel:source:CodeGenEdge' :: Text
source = Text
a} :: CodeGenEdge)

-- | The ID of the node at which the edge ends.
codeGenEdge_target :: Lens.Lens' CodeGenEdge Prelude.Text
codeGenEdge_target :: (Text -> f Text) -> CodeGenEdge -> f CodeGenEdge
codeGenEdge_target = (CodeGenEdge -> Text)
-> (CodeGenEdge -> Text -> CodeGenEdge)
-> Lens CodeGenEdge CodeGenEdge Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeGenEdge' {Text
target :: Text
$sel:target:CodeGenEdge' :: CodeGenEdge -> Text
target} -> Text
target) (\s :: CodeGenEdge
s@CodeGenEdge' {} Text
a -> CodeGenEdge
s {$sel:target:CodeGenEdge' :: Text
target = Text
a} :: CodeGenEdge)

instance Core.FromJSON CodeGenEdge where
  parseJSON :: Value -> Parser CodeGenEdge
parseJSON =
    String
-> (Object -> Parser CodeGenEdge) -> Value -> Parser CodeGenEdge
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CodeGenEdge"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> CodeGenEdge
CodeGenEdge'
            (Maybe Text -> Text -> Text -> CodeGenEdge)
-> Parser (Maybe Text) -> Parser (Text -> Text -> CodeGenEdge)
forall (f :: * -> *) a b. Functor 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
"TargetParameter")
            Parser (Text -> Text -> CodeGenEdge)
-> Parser Text -> Parser (Text -> CodeGenEdge)
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
"Source")
            Parser (Text -> CodeGenEdge) -> Parser Text -> Parser CodeGenEdge
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
"Target")
      )

instance Prelude.Hashable CodeGenEdge

instance Prelude.NFData CodeGenEdge

instance Core.ToJSON CodeGenEdge where
  toJSON :: CodeGenEdge -> Value
toJSON CodeGenEdge' {Maybe Text
Text
target :: Text
source :: Text
targetParameter :: Maybe Text
$sel:target:CodeGenEdge' :: CodeGenEdge -> Text
$sel:source:CodeGenEdge' :: CodeGenEdge -> Text
$sel:targetParameter:CodeGenEdge' :: CodeGenEdge -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TargetParameter" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetParameter,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Source" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
source),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Target" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
target)
          ]
      )