{-# 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.Amplify.Types.Job
-- 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.Amplify.Types.Job where

import Amazonka.Amplify.Types.JobSummary
import Amazonka.Amplify.Types.Step
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes an execution job for an Amplify app.
--
-- /See:/ 'newJob' smart constructor.
data Job = Job'
  { -- | Describes the summary for an execution job for an Amplify app.
    Job -> JobSummary
summary :: JobSummary,
    -- | The execution steps for an execution job, for an Amplify app.
    Job -> [Step]
steps :: [Step]
  }
  deriving (Job -> Job -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Job -> Job -> Bool
$c/= :: Job -> Job -> Bool
== :: Job -> Job -> Bool
$c== :: Job -> Job -> Bool
Prelude.Eq, ReadPrec [Job]
ReadPrec Job
Int -> ReadS Job
ReadS [Job]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Job]
$creadListPrec :: ReadPrec [Job]
readPrec :: ReadPrec Job
$creadPrec :: ReadPrec Job
readList :: ReadS [Job]
$creadList :: ReadS [Job]
readsPrec :: Int -> ReadS Job
$creadsPrec :: Int -> ReadS Job
Prelude.Read, Int -> Job -> ShowS
[Job] -> ShowS
Job -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Job] -> ShowS
$cshowList :: [Job] -> ShowS
show :: Job -> String
$cshow :: Job -> String
showsPrec :: Int -> Job -> ShowS
$cshowsPrec :: Int -> Job -> ShowS
Prelude.Show, forall x. Rep Job x -> Job
forall x. Job -> Rep Job x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Job x -> Job
$cfrom :: forall x. Job -> Rep Job x
Prelude.Generic)

-- |
-- Create a value of 'Job' 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:
--
-- 'summary', 'job_summary' - Describes the summary for an execution job for an Amplify app.
--
-- 'steps', 'job_steps' - The execution steps for an execution job, for an Amplify app.
newJob ::
  -- | 'summary'
  JobSummary ->
  Job
newJob :: JobSummary -> Job
newJob JobSummary
pSummary_ =
  Job' {$sel:summary:Job' :: JobSummary
summary = JobSummary
pSummary_, $sel:steps:Job' :: [Step]
steps = forall a. Monoid a => a
Prelude.mempty}

-- | Describes the summary for an execution job for an Amplify app.
job_summary :: Lens.Lens' Job JobSummary
job_summary :: Lens' Job JobSummary
job_summary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {JobSummary
summary :: JobSummary
$sel:summary:Job' :: Job -> JobSummary
summary} -> JobSummary
summary) (\s :: Job
s@Job' {} JobSummary
a -> Job
s {$sel:summary:Job' :: JobSummary
summary = JobSummary
a} :: Job)

-- | The execution steps for an execution job, for an Amplify app.
job_steps :: Lens.Lens' Job [Step]
job_steps :: Lens' Job [Step]
job_steps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {[Step]
steps :: [Step]
$sel:steps:Job' :: Job -> [Step]
steps} -> [Step]
steps) (\s :: Job
s@Job' {} [Step]
a -> Job
s {$sel:steps:Job' :: [Step]
steps = [Step]
a} :: Job) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON Job where
  parseJSON :: Value -> Parser Job
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Job"
      ( \Object
x ->
          JobSummary -> [Step] -> Job
Job'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"summary")
            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
"steps" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Job where
  hashWithSalt :: Int -> Job -> Int
hashWithSalt Int
_salt Job' {[Step]
JobSummary
steps :: [Step]
summary :: JobSummary
$sel:steps:Job' :: Job -> [Step]
$sel:summary:Job' :: Job -> JobSummary
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` JobSummary
summary
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Step]
steps

instance Prelude.NFData Job where
  rnf :: Job -> ()
rnf Job' {[Step]
JobSummary
steps :: [Step]
summary :: JobSummary
$sel:steps:Job' :: Job -> [Step]
$sel:summary:Job' :: Job -> JobSummary
..} =
    forall a. NFData a => a -> ()
Prelude.rnf JobSummary
summary seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Step]
steps