{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Represents information about a job.
--
-- /See:/ 'newJob' smart constructor.
data Job = Job'
  { -- | The ID of the AWS account to use when performing the job.
    Job -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | Other data about a job.
    Job -> Maybe JobData
data' :: Prelude.Maybe JobData,
    -- | 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
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
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:
--
-- 'accountId', 'job_accountId' - The ID of the AWS account to use when performing the job.
--
-- 'data'', 'job_data' - Other data about a 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'
    { $sel:accountId:Job' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:data':Job' :: Maybe JobData
data' = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Job' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:nonce:Job' :: Maybe Text
nonce = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the AWS account to use when performing the job.
job_accountId :: Lens.Lens' Job (Prelude.Maybe Prelude.Text)
job_accountId :: Lens' Job (Maybe Text)
job_accountId = 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)

-- | Other data about a job.
job_data :: Lens.Lens' Job (Prelude.Maybe JobData)
job_data :: Lens' Job (Maybe JobData)
job_data = 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 unique system-generated ID of the job.
job_id :: Lens.Lens' Job (Prelude.Maybe Prelude.Text)
job_id :: Lens' Job (Maybe Text)
job_id = 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 :: Lens' Job (Maybe Text)
job_nonce = 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 Data.FromJSON Job where
  parseJSON :: Value -> Parser Job
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Job"
      ( \Object
x ->
          Maybe Text -> Maybe JobData -> Maybe Text -> Maybe Text -> Job
Job'
            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
"accountId")
            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
"data")
            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
"id")
            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
"nonce")
      )

instance Prelude.Hashable Job where
  hashWithSalt :: Int -> Job -> Int
hashWithSalt Int
_salt Job' {Maybe Text
Maybe JobData
nonce :: Maybe Text
id :: Maybe Text
data' :: Maybe JobData
accountId :: Maybe Text
$sel:nonce:Job' :: Job -> Maybe Text
$sel:id:Job' :: Job -> Maybe Text
$sel:data':Job' :: Job -> Maybe JobData
$sel:accountId:Job' :: Job -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JobData
data'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nonce

instance Prelude.NFData Job where
  rnf :: Job -> ()
rnf Job' {Maybe Text
Maybe JobData
nonce :: Maybe Text
id :: Maybe Text
data' :: Maybe JobData
accountId :: Maybe Text
$sel:nonce:Job' :: Job -> Maybe Text
$sel:id:Job' :: Job -> Maybe Text
$sel:data':Job' :: Job -> Maybe JobData
$sel:accountId:Job' :: Job -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe JobData
data'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nonce