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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.Edge
import Amazonka.Glue.Types.Node
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A workflow graph represents the complete workflow containing all the
-- Glue components present in the workflow and all the directed connections
-- between them.
--
-- /See:/ 'newWorkflowGraph' smart constructor.
data WorkflowGraph = WorkflowGraph'
  { -- | A list of all the directed connections between the nodes belonging to
    -- the workflow.
    WorkflowGraph -> Maybe [Edge]
edges :: Prelude.Maybe [Edge],
    -- | A list of the the Glue components belong to the workflow represented as
    -- nodes.
    WorkflowGraph -> Maybe [Node]
nodes :: Prelude.Maybe [Node]
  }
  deriving (WorkflowGraph -> WorkflowGraph -> Bool
(WorkflowGraph -> WorkflowGraph -> Bool)
-> (WorkflowGraph -> WorkflowGraph -> Bool) -> Eq WorkflowGraph
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WorkflowGraph -> WorkflowGraph -> Bool
$c/= :: WorkflowGraph -> WorkflowGraph -> Bool
== :: WorkflowGraph -> WorkflowGraph -> Bool
$c== :: WorkflowGraph -> WorkflowGraph -> Bool
Prelude.Eq, ReadPrec [WorkflowGraph]
ReadPrec WorkflowGraph
Int -> ReadS WorkflowGraph
ReadS [WorkflowGraph]
(Int -> ReadS WorkflowGraph)
-> ReadS [WorkflowGraph]
-> ReadPrec WorkflowGraph
-> ReadPrec [WorkflowGraph]
-> Read WorkflowGraph
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WorkflowGraph]
$creadListPrec :: ReadPrec [WorkflowGraph]
readPrec :: ReadPrec WorkflowGraph
$creadPrec :: ReadPrec WorkflowGraph
readList :: ReadS [WorkflowGraph]
$creadList :: ReadS [WorkflowGraph]
readsPrec :: Int -> ReadS WorkflowGraph
$creadsPrec :: Int -> ReadS WorkflowGraph
Prelude.Read, Int -> WorkflowGraph -> ShowS
[WorkflowGraph] -> ShowS
WorkflowGraph -> String
(Int -> WorkflowGraph -> ShowS)
-> (WorkflowGraph -> String)
-> ([WorkflowGraph] -> ShowS)
-> Show WorkflowGraph
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WorkflowGraph] -> ShowS
$cshowList :: [WorkflowGraph] -> ShowS
show :: WorkflowGraph -> String
$cshow :: WorkflowGraph -> String
showsPrec :: Int -> WorkflowGraph -> ShowS
$cshowsPrec :: Int -> WorkflowGraph -> ShowS
Prelude.Show, (forall x. WorkflowGraph -> Rep WorkflowGraph x)
-> (forall x. Rep WorkflowGraph x -> WorkflowGraph)
-> Generic WorkflowGraph
forall x. Rep WorkflowGraph x -> WorkflowGraph
forall x. WorkflowGraph -> Rep WorkflowGraph x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WorkflowGraph x -> WorkflowGraph
$cfrom :: forall x. WorkflowGraph -> Rep WorkflowGraph x
Prelude.Generic)

-- |
-- Create a value of 'WorkflowGraph' 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:
--
-- 'edges', 'workflowGraph_edges' - A list of all the directed connections between the nodes belonging to
-- the workflow.
--
-- 'nodes', 'workflowGraph_nodes' - A list of the the Glue components belong to the workflow represented as
-- nodes.
newWorkflowGraph ::
  WorkflowGraph
newWorkflowGraph :: WorkflowGraph
newWorkflowGraph =
  WorkflowGraph' :: Maybe [Edge] -> Maybe [Node] -> WorkflowGraph
WorkflowGraph'
    { $sel:edges:WorkflowGraph' :: Maybe [Edge]
edges = Maybe [Edge]
forall a. Maybe a
Prelude.Nothing,
      $sel:nodes:WorkflowGraph' :: Maybe [Node]
nodes = Maybe [Node]
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of all the directed connections between the nodes belonging to
-- the workflow.
workflowGraph_edges :: Lens.Lens' WorkflowGraph (Prelude.Maybe [Edge])
workflowGraph_edges :: (Maybe [Edge] -> f (Maybe [Edge]))
-> WorkflowGraph -> f WorkflowGraph
workflowGraph_edges = (WorkflowGraph -> Maybe [Edge])
-> (WorkflowGraph -> Maybe [Edge] -> WorkflowGraph)
-> Lens WorkflowGraph WorkflowGraph (Maybe [Edge]) (Maybe [Edge])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowGraph' {Maybe [Edge]
edges :: Maybe [Edge]
$sel:edges:WorkflowGraph' :: WorkflowGraph -> Maybe [Edge]
edges} -> Maybe [Edge]
edges) (\s :: WorkflowGraph
s@WorkflowGraph' {} Maybe [Edge]
a -> WorkflowGraph
s {$sel:edges:WorkflowGraph' :: Maybe [Edge]
edges = Maybe [Edge]
a} :: WorkflowGraph) ((Maybe [Edge] -> f (Maybe [Edge]))
 -> WorkflowGraph -> f WorkflowGraph)
-> ((Maybe [Edge] -> f (Maybe [Edge]))
    -> Maybe [Edge] -> f (Maybe [Edge]))
-> (Maybe [Edge] -> f (Maybe [Edge]))
-> WorkflowGraph
-> f WorkflowGraph
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Edge] [Edge] [Edge] [Edge]
-> Iso (Maybe [Edge]) (Maybe [Edge]) (Maybe [Edge]) (Maybe [Edge])
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 [Edge] [Edge] [Edge] [Edge]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of the the Glue components belong to the workflow represented as
-- nodes.
workflowGraph_nodes :: Lens.Lens' WorkflowGraph (Prelude.Maybe [Node])
workflowGraph_nodes :: (Maybe [Node] -> f (Maybe [Node]))
-> WorkflowGraph -> f WorkflowGraph
workflowGraph_nodes = (WorkflowGraph -> Maybe [Node])
-> (WorkflowGraph -> Maybe [Node] -> WorkflowGraph)
-> Lens WorkflowGraph WorkflowGraph (Maybe [Node]) (Maybe [Node])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WorkflowGraph' {Maybe [Node]
nodes :: Maybe [Node]
$sel:nodes:WorkflowGraph' :: WorkflowGraph -> Maybe [Node]
nodes} -> Maybe [Node]
nodes) (\s :: WorkflowGraph
s@WorkflowGraph' {} Maybe [Node]
a -> WorkflowGraph
s {$sel:nodes:WorkflowGraph' :: Maybe [Node]
nodes = Maybe [Node]
a} :: WorkflowGraph) ((Maybe [Node] -> f (Maybe [Node]))
 -> WorkflowGraph -> f WorkflowGraph)
-> ((Maybe [Node] -> f (Maybe [Node]))
    -> Maybe [Node] -> f (Maybe [Node]))
-> (Maybe [Node] -> f (Maybe [Node]))
-> WorkflowGraph
-> f WorkflowGraph
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Node] [Node] [Node] [Node]
-> Iso (Maybe [Node]) (Maybe [Node]) (Maybe [Node]) (Maybe [Node])
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 [Node] [Node] [Node] [Node]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON WorkflowGraph where
  parseJSON :: Value -> Parser WorkflowGraph
parseJSON =
    String
-> (Object -> Parser WorkflowGraph)
-> Value
-> Parser WorkflowGraph
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WorkflowGraph"
      ( \Object
x ->
          Maybe [Edge] -> Maybe [Node] -> WorkflowGraph
WorkflowGraph'
            (Maybe [Edge] -> Maybe [Node] -> WorkflowGraph)
-> Parser (Maybe [Edge]) -> Parser (Maybe [Node] -> WorkflowGraph)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Edge]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Edges" Parser (Maybe (Maybe [Edge]))
-> Maybe [Edge] -> Parser (Maybe [Edge])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Edge]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Node] -> WorkflowGraph)
-> Parser (Maybe [Node]) -> Parser WorkflowGraph
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Node]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Nodes" Parser (Maybe (Maybe [Node]))
-> Maybe [Node] -> Parser (Maybe [Node])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Node]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable WorkflowGraph

instance Prelude.NFData WorkflowGraph