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

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

-- | An edge represents a directed connection between two components on a
-- workflow graph.
--
-- /See:/ 'newEdge' smart constructor.
data Edge = Edge'
  { -- | The unique of the node within the workflow where the edge starts.
    Edge -> Maybe Text
sourceId :: Prelude.Maybe Prelude.Text,
    -- | The unique of the node within the workflow where the edge ends.
    Edge -> Maybe Text
destinationId :: Prelude.Maybe Prelude.Text
  }
  deriving (Edge -> Edge -> Bool
(Edge -> Edge -> Bool) -> (Edge -> Edge -> Bool) -> Eq Edge
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Edge -> Edge -> Bool
$c/= :: Edge -> Edge -> Bool
== :: Edge -> Edge -> Bool
$c== :: Edge -> Edge -> Bool
Prelude.Eq, ReadPrec [Edge]
ReadPrec Edge
Int -> ReadS Edge
ReadS [Edge]
(Int -> ReadS Edge)
-> ReadS [Edge] -> ReadPrec Edge -> ReadPrec [Edge] -> Read Edge
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Edge]
$creadListPrec :: ReadPrec [Edge]
readPrec :: ReadPrec Edge
$creadPrec :: ReadPrec Edge
readList :: ReadS [Edge]
$creadList :: ReadS [Edge]
readsPrec :: Int -> ReadS Edge
$creadsPrec :: Int -> ReadS Edge
Prelude.Read, Int -> Edge -> ShowS
[Edge] -> ShowS
Edge -> String
(Int -> Edge -> ShowS)
-> (Edge -> String) -> ([Edge] -> ShowS) -> Show Edge
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Edge] -> ShowS
$cshowList :: [Edge] -> ShowS
show :: Edge -> String
$cshow :: Edge -> String
showsPrec :: Int -> Edge -> ShowS
$cshowsPrec :: Int -> Edge -> ShowS
Prelude.Show, (forall x. Edge -> Rep Edge x)
-> (forall x. Rep Edge x -> Edge) -> Generic Edge
forall x. Rep Edge x -> Edge
forall x. Edge -> Rep Edge x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Edge x -> Edge
$cfrom :: forall x. Edge -> Rep Edge x
Prelude.Generic)

-- |
-- Create a value of 'Edge' 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:
--
-- 'sourceId', 'edge_sourceId' - The unique of the node within the workflow where the edge starts.
--
-- 'destinationId', 'edge_destinationId' - The unique of the node within the workflow where the edge ends.
newEdge ::
  Edge
newEdge :: Edge
newEdge =
  Edge' :: Maybe Text -> Maybe Text -> Edge
Edge'
    { $sel:sourceId:Edge' :: Maybe Text
sourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationId:Edge' :: Maybe Text
destinationId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique of the node within the workflow where the edge starts.
edge_sourceId :: Lens.Lens' Edge (Prelude.Maybe Prelude.Text)
edge_sourceId :: (Maybe Text -> f (Maybe Text)) -> Edge -> f Edge
edge_sourceId = (Edge -> Maybe Text)
-> (Edge -> Maybe Text -> Edge)
-> Lens Edge Edge (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe Text
sourceId :: Maybe Text
$sel:sourceId:Edge' :: Edge -> Maybe Text
sourceId} -> Maybe Text
sourceId) (\s :: Edge
s@Edge' {} Maybe Text
a -> Edge
s {$sel:sourceId:Edge' :: Maybe Text
sourceId = Maybe Text
a} :: Edge)

-- | The unique of the node within the workflow where the edge ends.
edge_destinationId :: Lens.Lens' Edge (Prelude.Maybe Prelude.Text)
edge_destinationId :: (Maybe Text -> f (Maybe Text)) -> Edge -> f Edge
edge_destinationId = (Edge -> Maybe Text)
-> (Edge -> Maybe Text -> Edge)
-> Lens Edge Edge (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Edge' {Maybe Text
destinationId :: Maybe Text
$sel:destinationId:Edge' :: Edge -> Maybe Text
destinationId} -> Maybe Text
destinationId) (\s :: Edge
s@Edge' {} Maybe Text
a -> Edge
s {$sel:destinationId:Edge' :: Maybe Text
destinationId = Maybe Text
a} :: Edge)

instance Core.FromJSON Edge where
  parseJSON :: Value -> Parser Edge
parseJSON =
    String -> (Object -> Parser Edge) -> Value -> Parser Edge
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Edge"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Edge
Edge'
            (Maybe Text -> Maybe Text -> Edge)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Edge)
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
"SourceId")
            Parser (Maybe Text -> Edge) -> Parser (Maybe Text) -> Parser Edge
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
"DestinationId")
      )

instance Prelude.Hashable Edge

instance Prelude.NFData Edge