{-# 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.Pipes.Types.BatchJobDependency
-- 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.Pipes.Types.BatchJobDependency where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pipes.Types.BatchJobDependencyType
import qualified Amazonka.Prelude as Prelude

-- | An object that represents an Batch job dependency.
--
-- /See:/ 'newBatchJobDependency' smart constructor.
data BatchJobDependency = BatchJobDependency'
  { -- | The job ID of the Batch job that\'s associated with this dependency.
    BatchJobDependency -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | The type of the job dependency.
    BatchJobDependency -> Maybe BatchJobDependencyType
type' :: Prelude.Maybe BatchJobDependencyType
  }
  deriving (BatchJobDependency -> BatchJobDependency -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchJobDependency -> BatchJobDependency -> Bool
$c/= :: BatchJobDependency -> BatchJobDependency -> Bool
== :: BatchJobDependency -> BatchJobDependency -> Bool
$c== :: BatchJobDependency -> BatchJobDependency -> Bool
Prelude.Eq, ReadPrec [BatchJobDependency]
ReadPrec BatchJobDependency
Int -> ReadS BatchJobDependency
ReadS [BatchJobDependency]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchJobDependency]
$creadListPrec :: ReadPrec [BatchJobDependency]
readPrec :: ReadPrec BatchJobDependency
$creadPrec :: ReadPrec BatchJobDependency
readList :: ReadS [BatchJobDependency]
$creadList :: ReadS [BatchJobDependency]
readsPrec :: Int -> ReadS BatchJobDependency
$creadsPrec :: Int -> ReadS BatchJobDependency
Prelude.Read, Int -> BatchJobDependency -> ShowS
[BatchJobDependency] -> ShowS
BatchJobDependency -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchJobDependency] -> ShowS
$cshowList :: [BatchJobDependency] -> ShowS
show :: BatchJobDependency -> String
$cshow :: BatchJobDependency -> String
showsPrec :: Int -> BatchJobDependency -> ShowS
$cshowsPrec :: Int -> BatchJobDependency -> ShowS
Prelude.Show, forall x. Rep BatchJobDependency x -> BatchJobDependency
forall x. BatchJobDependency -> Rep BatchJobDependency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchJobDependency x -> BatchJobDependency
$cfrom :: forall x. BatchJobDependency -> Rep BatchJobDependency x
Prelude.Generic)

-- |
-- Create a value of 'BatchJobDependency' 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:
--
-- 'jobId', 'batchJobDependency_jobId' - The job ID of the Batch job that\'s associated with this dependency.
--
-- 'type'', 'batchJobDependency_type' - The type of the job dependency.
newBatchJobDependency ::
  BatchJobDependency
newBatchJobDependency :: BatchJobDependency
newBatchJobDependency =
  BatchJobDependency'
    { $sel:jobId:BatchJobDependency' :: Maybe Text
jobId = forall a. Maybe a
Prelude.Nothing,
      $sel:type':BatchJobDependency' :: Maybe BatchJobDependencyType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The job ID of the Batch job that\'s associated with this dependency.
batchJobDependency_jobId :: Lens.Lens' BatchJobDependency (Prelude.Maybe Prelude.Text)
batchJobDependency_jobId :: Lens' BatchJobDependency (Maybe Text)
batchJobDependency_jobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchJobDependency' {Maybe Text
jobId :: Maybe Text
$sel:jobId:BatchJobDependency' :: BatchJobDependency -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: BatchJobDependency
s@BatchJobDependency' {} Maybe Text
a -> BatchJobDependency
s {$sel:jobId:BatchJobDependency' :: Maybe Text
jobId = Maybe Text
a} :: BatchJobDependency)

-- | The type of the job dependency.
batchJobDependency_type :: Lens.Lens' BatchJobDependency (Prelude.Maybe BatchJobDependencyType)
batchJobDependency_type :: Lens' BatchJobDependency (Maybe BatchJobDependencyType)
batchJobDependency_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchJobDependency' {Maybe BatchJobDependencyType
type' :: Maybe BatchJobDependencyType
$sel:type':BatchJobDependency' :: BatchJobDependency -> Maybe BatchJobDependencyType
type'} -> Maybe BatchJobDependencyType
type') (\s :: BatchJobDependency
s@BatchJobDependency' {} Maybe BatchJobDependencyType
a -> BatchJobDependency
s {$sel:type':BatchJobDependency' :: Maybe BatchJobDependencyType
type' = Maybe BatchJobDependencyType
a} :: BatchJobDependency)

instance Data.FromJSON BatchJobDependency where
  parseJSON :: Value -> Parser BatchJobDependency
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchJobDependency"
      ( \Object
x ->
          Maybe Text -> Maybe BatchJobDependencyType -> BatchJobDependency
BatchJobDependency'
            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
"JobId")
            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
"Type")
      )

instance Prelude.Hashable BatchJobDependency where
  hashWithSalt :: Int -> BatchJobDependency -> Int
hashWithSalt Int
_salt BatchJobDependency' {Maybe Text
Maybe BatchJobDependencyType
type' :: Maybe BatchJobDependencyType
jobId :: Maybe Text
$sel:type':BatchJobDependency' :: BatchJobDependency -> Maybe BatchJobDependencyType
$sel:jobId:BatchJobDependency' :: BatchJobDependency -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
jobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BatchJobDependencyType
type'

instance Prelude.NFData BatchJobDependency where
  rnf :: BatchJobDependency -> ()
rnf BatchJobDependency' {Maybe Text
Maybe BatchJobDependencyType
type' :: Maybe BatchJobDependencyType
jobId :: Maybe Text
$sel:type':BatchJobDependency' :: BatchJobDependency -> Maybe BatchJobDependencyType
$sel:jobId:BatchJobDependency' :: BatchJobDependency -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jobId seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BatchJobDependencyType
type'

instance Data.ToJSON BatchJobDependency where
  toJSON :: BatchJobDependency -> Value
toJSON BatchJobDependency' {Maybe Text
Maybe BatchJobDependencyType
type' :: Maybe BatchJobDependencyType
jobId :: Maybe Text
$sel:type':BatchJobDependency' :: BatchJobDependency -> Maybe BatchJobDependencyType
$sel:jobId:BatchJobDependency' :: BatchJobDependency -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"JobId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
jobId,
            (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BatchJobDependencyType
type'
          ]
      )