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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.CrawlerNodeDetails
import Amazonka.Glue.Types.JobNodeDetails
import Amazonka.Glue.Types.NodeType
import Amazonka.Glue.Types.TriggerNodeDetails
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A node represents an Glue component (trigger, crawler, or job) on a
-- workflow graph.
--
-- /See:/ 'newNode' smart constructor.
data Node = Node'
  { -- | Details of the Trigger when the node represents a Trigger.
    Node -> Maybe TriggerNodeDetails
triggerDetails :: Prelude.Maybe TriggerNodeDetails,
    -- | The unique Id assigned to the node within the workflow.
    Node -> Maybe Text
uniqueId :: Prelude.Maybe Prelude.Text,
    -- | Details of the crawler when the node represents a crawler.
    Node -> Maybe CrawlerNodeDetails
crawlerDetails :: Prelude.Maybe CrawlerNodeDetails,
    -- | The name of the Glue component represented by the node.
    Node -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Details of the Job when the node represents a Job.
    Node -> Maybe JobNodeDetails
jobDetails :: Prelude.Maybe JobNodeDetails,
    -- | The type of Glue component represented by the node.
    Node -> Maybe NodeType
type' :: Prelude.Maybe NodeType
  }
  deriving (Node -> Node -> Bool
(Node -> Node -> Bool) -> (Node -> Node -> Bool) -> Eq Node
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Node -> Node -> Bool
$c/= :: Node -> Node -> Bool
== :: Node -> Node -> Bool
$c== :: Node -> Node -> Bool
Prelude.Eq, ReadPrec [Node]
ReadPrec Node
Int -> ReadS Node
ReadS [Node]
(Int -> ReadS Node)
-> ReadS [Node] -> ReadPrec Node -> ReadPrec [Node] -> Read Node
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Node]
$creadListPrec :: ReadPrec [Node]
readPrec :: ReadPrec Node
$creadPrec :: ReadPrec Node
readList :: ReadS [Node]
$creadList :: ReadS [Node]
readsPrec :: Int -> ReadS Node
$creadsPrec :: Int -> ReadS Node
Prelude.Read, Int -> Node -> ShowS
[Node] -> ShowS
Node -> String
(Int -> Node -> ShowS)
-> (Node -> String) -> ([Node] -> ShowS) -> Show Node
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Node] -> ShowS
$cshowList :: [Node] -> ShowS
show :: Node -> String
$cshow :: Node -> String
showsPrec :: Int -> Node -> ShowS
$cshowsPrec :: Int -> Node -> ShowS
Prelude.Show, (forall x. Node -> Rep Node x)
-> (forall x. Rep Node x -> Node) -> Generic Node
forall x. Rep Node x -> Node
forall x. Node -> Rep Node x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Node x -> Node
$cfrom :: forall x. Node -> Rep Node x
Prelude.Generic)

-- |
-- Create a value of 'Node' 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:
--
-- 'triggerDetails', 'node_triggerDetails' - Details of the Trigger when the node represents a Trigger.
--
-- 'uniqueId', 'node_uniqueId' - The unique Id assigned to the node within the workflow.
--
-- 'crawlerDetails', 'node_crawlerDetails' - Details of the crawler when the node represents a crawler.
--
-- 'name', 'node_name' - The name of the Glue component represented by the node.
--
-- 'jobDetails', 'node_jobDetails' - Details of the Job when the node represents a Job.
--
-- 'type'', 'node_type' - The type of Glue component represented by the node.
newNode ::
  Node
newNode :: Node
newNode =
  Node' :: Maybe TriggerNodeDetails
-> Maybe Text
-> Maybe CrawlerNodeDetails
-> Maybe Text
-> Maybe JobNodeDetails
-> Maybe NodeType
-> Node
Node'
    { $sel:triggerDetails:Node' :: Maybe TriggerNodeDetails
triggerDetails = Maybe TriggerNodeDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:uniqueId:Node' :: Maybe Text
uniqueId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:crawlerDetails:Node' :: Maybe CrawlerNodeDetails
crawlerDetails = Maybe CrawlerNodeDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Node' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:jobDetails:Node' :: Maybe JobNodeDetails
jobDetails = Maybe JobNodeDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Node' :: Maybe NodeType
type' = Maybe NodeType
forall a. Maybe a
Prelude.Nothing
    }

-- | Details of the Trigger when the node represents a Trigger.
node_triggerDetails :: Lens.Lens' Node (Prelude.Maybe TriggerNodeDetails)
node_triggerDetails :: (Maybe TriggerNodeDetails -> f (Maybe TriggerNodeDetails))
-> Node -> f Node
node_triggerDetails = (Node -> Maybe TriggerNodeDetails)
-> (Node -> Maybe TriggerNodeDetails -> Node)
-> Lens
     Node Node (Maybe TriggerNodeDetails) (Maybe TriggerNodeDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe TriggerNodeDetails
triggerDetails :: Maybe TriggerNodeDetails
$sel:triggerDetails:Node' :: Node -> Maybe TriggerNodeDetails
triggerDetails} -> Maybe TriggerNodeDetails
triggerDetails) (\s :: Node
s@Node' {} Maybe TriggerNodeDetails
a -> Node
s {$sel:triggerDetails:Node' :: Maybe TriggerNodeDetails
triggerDetails = Maybe TriggerNodeDetails
a} :: Node)

-- | The unique Id assigned to the node within the workflow.
node_uniqueId :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_uniqueId :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_uniqueId = (Node -> Maybe Text)
-> (Node -> Maybe Text -> Node)
-> Lens Node Node (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe Text
uniqueId :: Maybe Text
$sel:uniqueId:Node' :: Node -> Maybe Text
uniqueId} -> Maybe Text
uniqueId) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:uniqueId:Node' :: Maybe Text
uniqueId = Maybe Text
a} :: Node)

-- | Details of the crawler when the node represents a crawler.
node_crawlerDetails :: Lens.Lens' Node (Prelude.Maybe CrawlerNodeDetails)
node_crawlerDetails :: (Maybe CrawlerNodeDetails -> f (Maybe CrawlerNodeDetails))
-> Node -> f Node
node_crawlerDetails = (Node -> Maybe CrawlerNodeDetails)
-> (Node -> Maybe CrawlerNodeDetails -> Node)
-> Lens
     Node Node (Maybe CrawlerNodeDetails) (Maybe CrawlerNodeDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe CrawlerNodeDetails
crawlerDetails :: Maybe CrawlerNodeDetails
$sel:crawlerDetails:Node' :: Node -> Maybe CrawlerNodeDetails
crawlerDetails} -> Maybe CrawlerNodeDetails
crawlerDetails) (\s :: Node
s@Node' {} Maybe CrawlerNodeDetails
a -> Node
s {$sel:crawlerDetails:Node' :: Maybe CrawlerNodeDetails
crawlerDetails = Maybe CrawlerNodeDetails
a} :: Node)

-- | The name of the Glue component represented by the node.
node_name :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_name :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_name = (Node -> Maybe Text)
-> (Node -> Maybe Text -> Node)
-> Lens Node Node (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe Text
name :: Maybe Text
$sel:name:Node' :: Node -> Maybe Text
name} -> Maybe Text
name) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:name:Node' :: Maybe Text
name = Maybe Text
a} :: Node)

-- | Details of the Job when the node represents a Job.
node_jobDetails :: Lens.Lens' Node (Prelude.Maybe JobNodeDetails)
node_jobDetails :: (Maybe JobNodeDetails -> f (Maybe JobNodeDetails))
-> Node -> f Node
node_jobDetails = (Node -> Maybe JobNodeDetails)
-> (Node -> Maybe JobNodeDetails -> Node)
-> Lens Node Node (Maybe JobNodeDetails) (Maybe JobNodeDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe JobNodeDetails
jobDetails :: Maybe JobNodeDetails
$sel:jobDetails:Node' :: Node -> Maybe JobNodeDetails
jobDetails} -> Maybe JobNodeDetails
jobDetails) (\s :: Node
s@Node' {} Maybe JobNodeDetails
a -> Node
s {$sel:jobDetails:Node' :: Maybe JobNodeDetails
jobDetails = Maybe JobNodeDetails
a} :: Node)

-- | The type of Glue component represented by the node.
node_type :: Lens.Lens' Node (Prelude.Maybe NodeType)
node_type :: (Maybe NodeType -> f (Maybe NodeType)) -> Node -> f Node
node_type = (Node -> Maybe NodeType)
-> (Node -> Maybe NodeType -> Node)
-> Lens Node Node (Maybe NodeType) (Maybe NodeType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe NodeType
type' :: Maybe NodeType
$sel:type':Node' :: Node -> Maybe NodeType
type'} -> Maybe NodeType
type') (\s :: Node
s@Node' {} Maybe NodeType
a -> Node
s {$sel:type':Node' :: Maybe NodeType
type' = Maybe NodeType
a} :: Node)

instance Core.FromJSON Node where
  parseJSON :: Value -> Parser Node
parseJSON =
    String -> (Object -> Parser Node) -> Value -> Parser Node
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Node"
      ( \Object
x ->
          Maybe TriggerNodeDetails
-> Maybe Text
-> Maybe CrawlerNodeDetails
-> Maybe Text
-> Maybe JobNodeDetails
-> Maybe NodeType
-> Node
Node'
            (Maybe TriggerNodeDetails
 -> Maybe Text
 -> Maybe CrawlerNodeDetails
 -> Maybe Text
 -> Maybe JobNodeDetails
 -> Maybe NodeType
 -> Node)
-> Parser (Maybe TriggerNodeDetails)
-> Parser
     (Maybe Text
      -> Maybe CrawlerNodeDetails
      -> Maybe Text
      -> Maybe JobNodeDetails
      -> Maybe NodeType
      -> Node)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TriggerNodeDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TriggerDetails")
            Parser
  (Maybe Text
   -> Maybe CrawlerNodeDetails
   -> Maybe Text
   -> Maybe JobNodeDetails
   -> Maybe NodeType
   -> Node)
-> Parser (Maybe Text)
-> Parser
     (Maybe CrawlerNodeDetails
      -> Maybe Text -> Maybe JobNodeDetails -> Maybe NodeType -> Node)
forall (f :: * -> *) a b. Applicative f => 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
"UniqueId")
            Parser
  (Maybe CrawlerNodeDetails
   -> Maybe Text -> Maybe JobNodeDetails -> Maybe NodeType -> Node)
-> Parser (Maybe CrawlerNodeDetails)
-> Parser
     (Maybe Text -> Maybe JobNodeDetails -> Maybe NodeType -> Node)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CrawlerNodeDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CrawlerDetails")
            Parser
  (Maybe Text -> Maybe JobNodeDetails -> Maybe NodeType -> Node)
-> Parser (Maybe Text)
-> Parser (Maybe JobNodeDetails -> Maybe NodeType -> Node)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
            Parser (Maybe JobNodeDetails -> Maybe NodeType -> Node)
-> Parser (Maybe JobNodeDetails) -> Parser (Maybe NodeType -> Node)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JobNodeDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JobDetails")
            Parser (Maybe NodeType -> Node)
-> Parser (Maybe NodeType) -> Parser Node
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NodeType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable Node

instance Prelude.NFData Node