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

import Amazonka.Amplify.Types.JobSummary
import Amazonka.Amplify.Types.Step
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Job -> Job -> Bool) -> (Job -> Job -> Bool) -> Eq Job
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]
(Int -> ReadS Job)
-> ReadS [Job] -> ReadPrec Job -> ReadPrec [Job] -> Read 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
(Int -> Job -> ShowS)
-> (Job -> String) -> ([Job] -> ShowS) -> Show Job
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. Job -> Rep Job x)
-> (forall x. Rep Job x -> Job) -> Generic Job
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' :: JobSummary -> [Step] -> Job
Job' {$sel:summary:Job' :: JobSummary
summary = JobSummary
pSummary_, $sel:steps:Job' :: [Step]
steps = [Step]
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 :: (JobSummary -> f JobSummary) -> Job -> f Job
job_summary = (Job -> JobSummary)
-> (Job -> JobSummary -> Job) -> Lens Job Job JobSummary JobSummary
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 :: ([Step] -> f [Step]) -> Job -> f Job
job_steps = (Job -> [Step])
-> (Job -> [Step] -> Job) -> Lens Job Job [Step] [Step]
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) (([Step] -> f [Step]) -> Job -> f Job)
-> (([Step] -> f [Step]) -> [Step] -> f [Step])
-> ([Step] -> f [Step])
-> Job
-> f Job
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Step] -> f [Step]) -> [Step] -> f [Step]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Job where
  parseJSON :: Value -> Parser Job
parseJSON =
    String -> (Object -> Parser Job) -> Value -> Parser Job
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Job"
      ( \Object
x ->
          JobSummary -> [Step] -> Job
Job'
            (JobSummary -> [Step] -> Job)
-> Parser JobSummary -> Parser ([Step] -> Job)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser JobSummary
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"summary")
            Parser ([Step] -> Job) -> Parser [Step] -> Parser Job
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Step])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"steps" Parser (Maybe [Step]) -> [Step] -> Parser [Step]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Step]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Job

instance Prelude.NFData Job