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

import Amazonka.CodePipeline.Types.JobData
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents information about a job.
--
-- /See:/ 'newJob' smart constructor.
data Job = Job'
  { -- | Other data about a job.
    Job -> Maybe JobData
data' :: Prelude.Maybe JobData,
    -- | The ID of the AWS account to use when performing the job.
    Job -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The unique system-generated ID of the job.
    Job -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | A system-generated random number that AWS CodePipeline uses to ensure
    -- that the job is being worked on by only one job worker. Use this number
    -- in an AcknowledgeJob request.
    Job -> Maybe Text
nonce :: Prelude.Maybe Prelude.Text
  }
  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, 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:
--
-- 'data'', 'job_data' - Other data about a job.
--
-- 'accountId', 'job_accountId' - The ID of the AWS account to use when performing the job.
--
-- 'id', 'job_id' - The unique system-generated ID of the job.
--
-- 'nonce', 'job_nonce' - A system-generated random number that AWS CodePipeline uses to ensure
-- that the job is being worked on by only one job worker. Use this number
-- in an AcknowledgeJob request.
newJob ::
  Job
newJob :: Job
newJob =
  Job' :: Maybe JobData -> Maybe Text -> Maybe Text -> Maybe Text -> Job
Job'
    { $sel:data':Job' :: Maybe JobData
data' = Maybe JobData
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:Job' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Job' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nonce:Job' :: Maybe Text
nonce = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Other data about a job.
job_data :: Lens.Lens' Job (Prelude.Maybe JobData)
job_data :: (Maybe JobData -> f (Maybe JobData)) -> Job -> f Job
job_data = (Job -> Maybe JobData)
-> (Job -> Maybe JobData -> Job)
-> Lens Job Job (Maybe JobData) (Maybe JobData)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {Maybe JobData
data' :: Maybe JobData
$sel:data':Job' :: Job -> Maybe JobData
data'} -> Maybe JobData
data') (\s :: Job
s@Job' {} Maybe JobData
a -> Job
s {$sel:data':Job' :: Maybe JobData
data' = Maybe JobData
a} :: Job)

-- | The ID of the AWS account to use when performing the job.
job_accountId :: Lens.Lens' Job (Prelude.Maybe Prelude.Text)
job_accountId :: (Maybe Text -> f (Maybe Text)) -> Job -> f Job
job_accountId = (Job -> Maybe Text)
-> (Job -> Maybe Text -> Job)
-> Lens Job Job (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {Maybe Text
accountId :: Maybe Text
$sel:accountId:Job' :: Job -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: Job
s@Job' {} Maybe Text
a -> Job
s {$sel:accountId:Job' :: Maybe Text
accountId = Maybe Text
a} :: Job)

-- | The unique system-generated ID of the job.
job_id :: Lens.Lens' Job (Prelude.Maybe Prelude.Text)
job_id :: (Maybe Text -> f (Maybe Text)) -> Job -> f Job
job_id = (Job -> Maybe Text)
-> (Job -> Maybe Text -> Job)
-> Lens Job Job (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {Maybe Text
id :: Maybe Text
$sel:id:Job' :: Job -> Maybe Text
id} -> Maybe Text
id) (\s :: Job
s@Job' {} Maybe Text
a -> Job
s {$sel:id:Job' :: Maybe Text
id = Maybe Text
a} :: Job)

-- | A system-generated random number that AWS CodePipeline uses to ensure
-- that the job is being worked on by only one job worker. Use this number
-- in an AcknowledgeJob request.
job_nonce :: Lens.Lens' Job (Prelude.Maybe Prelude.Text)
job_nonce :: (Maybe Text -> f (Maybe Text)) -> Job -> f Job
job_nonce = (Job -> Maybe Text)
-> (Job -> Maybe Text -> Job)
-> Lens Job Job (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Job' {Maybe Text
nonce :: Maybe Text
$sel:nonce:Job' :: Job -> Maybe Text
nonce} -> Maybe Text
nonce) (\s :: Job
s@Job' {} Maybe Text
a -> Job
s {$sel:nonce:Job' :: Maybe Text
nonce = Maybe Text
a} :: Job)

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 ->
          Maybe JobData -> Maybe Text -> Maybe Text -> Maybe Text -> Job
Job'
            (Maybe JobData -> Maybe Text -> Maybe Text -> Maybe Text -> Job)
-> Parser (Maybe JobData)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Job)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe JobData)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"data")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Job)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Maybe Text -> Job)
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
"accountId")
            Parser (Maybe Text -> Maybe Text -> Job)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Job)
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
"id")
            Parser (Maybe Text -> Job) -> Parser (Maybe Text) -> Parser Job
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
"nonce")
      )

instance Prelude.Hashable Job

instance Prelude.NFData Job