{-# 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-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.WorkflowGraph 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.Edge
import Amazonka.Glue.Types.Node
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
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]
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
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. 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'
    { $sel:edges:WorkflowGraph' :: Maybe [Edge]
edges = forall a. Maybe a
Prelude.Nothing,
      $sel:nodes:WorkflowGraph' :: Maybe [Node]
nodes = 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 :: Lens' WorkflowGraph (Maybe [Edge])
workflowGraph_edges = 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) 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

-- | A list of the the Glue components belong to the workflow represented as
-- nodes.
workflowGraph_nodes :: Lens.Lens' WorkflowGraph (Prelude.Maybe [Node])
workflowGraph_nodes :: Lens' WorkflowGraph (Maybe [Node])
workflowGraph_nodes = 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) 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 WorkflowGraph where
  parseJSON :: Value -> Parser WorkflowGraph
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"WorkflowGraph"
      ( \Object
x ->
          Maybe [Edge] -> Maybe [Node] -> WorkflowGraph
WorkflowGraph'
            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
"Edges" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Nodes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable WorkflowGraph where
  hashWithSalt :: Int -> WorkflowGraph -> Int
hashWithSalt Int
_salt WorkflowGraph' {Maybe [Edge]
Maybe [Node]
nodes :: Maybe [Node]
edges :: Maybe [Edge]
$sel:nodes:WorkflowGraph' :: WorkflowGraph -> Maybe [Node]
$sel:edges:WorkflowGraph' :: WorkflowGraph -> Maybe [Edge]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Edge]
edges
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Node]
nodes

instance Prelude.NFData WorkflowGraph where
  rnf :: WorkflowGraph -> ()
rnf WorkflowGraph' {Maybe [Edge]
Maybe [Node]
nodes :: Maybe [Node]
edges :: Maybe [Edge]
$sel:nodes:WorkflowGraph' :: WorkflowGraph -> Maybe [Node]
$sel:edges:WorkflowGraph' :: WorkflowGraph -> Maybe [Edge]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Edge]
edges seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Node]
nodes