{-# 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.IoT.Types.JobSummary
-- 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.IoT.Types.JobSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types.JobStatus
import Amazonka.IoT.Types.TargetSelection
import qualified Amazonka.Prelude as Prelude

-- | The job summary.
--
-- /See:/ 'newJobSummary' smart constructor.
data JobSummary = JobSummary'
  { -- | The time, in seconds since the epoch, when the job completed.
    JobSummary -> Maybe POSIX
completedAt :: Prelude.Maybe Data.POSIX,
    -- | The time, in seconds since the epoch, when the job was created.
    JobSummary -> Maybe POSIX
createdAt :: Prelude.Maybe Data.POSIX,
    -- | Indicates whether a job is concurrent. Will be true when a job is
    -- rolling out new job executions or canceling previously created
    -- executions, otherwise false.
    JobSummary -> Maybe Bool
isConcurrent :: Prelude.Maybe Prelude.Bool,
    -- | The job ARN.
    JobSummary -> Maybe Text
jobArn :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier you assigned to this job when it was created.
    JobSummary -> Maybe Text
jobId :: Prelude.Maybe Prelude.Text,
    -- | The time, in seconds since the epoch, when the job was last updated.
    JobSummary -> Maybe POSIX
lastUpdatedAt :: Prelude.Maybe Data.POSIX,
    -- | The job summary status.
    JobSummary -> Maybe JobStatus
status :: Prelude.Maybe JobStatus,
    -- | Specifies whether the job will continue to run (CONTINUOUS), or will be
    -- complete after all those things specified as targets have completed the
    -- job (SNAPSHOT). If continuous, the job may also be run on a thing when a
    -- change is detected in a target. For example, a job will run on a thing
    -- when the thing is added to a target group, even after the job was
    -- completed by all things originally in the group.
    --
    -- We recommend that you use continuous jobs instead of snapshot jobs for
    -- dynamic thing group targets. By using continuous jobs, devices that join
    -- the group receive the job execution even after the job has been created.
    JobSummary -> Maybe TargetSelection
targetSelection :: Prelude.Maybe TargetSelection,
    -- | The ID of the thing group.
    JobSummary -> Maybe Text
thingGroupId :: Prelude.Maybe Prelude.Text
  }
  deriving (JobSummary -> JobSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobSummary -> JobSummary -> Bool
$c/= :: JobSummary -> JobSummary -> Bool
== :: JobSummary -> JobSummary -> Bool
$c== :: JobSummary -> JobSummary -> Bool
Prelude.Eq, ReadPrec [JobSummary]
ReadPrec JobSummary
Int -> ReadS JobSummary
ReadS [JobSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobSummary]
$creadListPrec :: ReadPrec [JobSummary]
readPrec :: ReadPrec JobSummary
$creadPrec :: ReadPrec JobSummary
readList :: ReadS [JobSummary]
$creadList :: ReadS [JobSummary]
readsPrec :: Int -> ReadS JobSummary
$creadsPrec :: Int -> ReadS JobSummary
Prelude.Read, Int -> JobSummary -> ShowS
[JobSummary] -> ShowS
JobSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobSummary] -> ShowS
$cshowList :: [JobSummary] -> ShowS
show :: JobSummary -> String
$cshow :: JobSummary -> String
showsPrec :: Int -> JobSummary -> ShowS
$cshowsPrec :: Int -> JobSummary -> ShowS
Prelude.Show, forall x. Rep JobSummary x -> JobSummary
forall x. JobSummary -> Rep JobSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobSummary x -> JobSummary
$cfrom :: forall x. JobSummary -> Rep JobSummary x
Prelude.Generic)

-- |
-- Create a value of 'JobSummary' 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:
--
-- 'completedAt', 'jobSummary_completedAt' - The time, in seconds since the epoch, when the job completed.
--
-- 'createdAt', 'jobSummary_createdAt' - The time, in seconds since the epoch, when the job was created.
--
-- 'isConcurrent', 'jobSummary_isConcurrent' - Indicates whether a job is concurrent. Will be true when a job is
-- rolling out new job executions or canceling previously created
-- executions, otherwise false.
--
-- 'jobArn', 'jobSummary_jobArn' - The job ARN.
--
-- 'jobId', 'jobSummary_jobId' - The unique identifier you assigned to this job when it was created.
--
-- 'lastUpdatedAt', 'jobSummary_lastUpdatedAt' - The time, in seconds since the epoch, when the job was last updated.
--
-- 'status', 'jobSummary_status' - The job summary status.
--
-- 'targetSelection', 'jobSummary_targetSelection' - Specifies whether the job will continue to run (CONTINUOUS), or will be
-- complete after all those things specified as targets have completed the
-- job (SNAPSHOT). If continuous, the job may also be run on a thing when a
-- change is detected in a target. For example, a job will run on a thing
-- when the thing is added to a target group, even after the job was
-- completed by all things originally in the group.
--
-- We recommend that you use continuous jobs instead of snapshot jobs for
-- dynamic thing group targets. By using continuous jobs, devices that join
-- the group receive the job execution even after the job has been created.
--
-- 'thingGroupId', 'jobSummary_thingGroupId' - The ID of the thing group.
newJobSummary ::
  JobSummary
newJobSummary :: JobSummary
newJobSummary =
  JobSummary'
    { $sel:completedAt:JobSummary' :: Maybe POSIX
completedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:JobSummary' :: Maybe POSIX
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:isConcurrent:JobSummary' :: Maybe Bool
isConcurrent = forall a. Maybe a
Prelude.Nothing,
      $sel:jobArn:JobSummary' :: Maybe Text
jobArn = forall a. Maybe a
Prelude.Nothing,
      $sel:jobId:JobSummary' :: Maybe Text
jobId = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedAt:JobSummary' :: Maybe POSIX
lastUpdatedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:status:JobSummary' :: Maybe JobStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:targetSelection:JobSummary' :: Maybe TargetSelection
targetSelection = forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupId:JobSummary' :: Maybe Text
thingGroupId = forall a. Maybe a
Prelude.Nothing
    }

-- | The time, in seconds since the epoch, when the job completed.
jobSummary_completedAt :: Lens.Lens' JobSummary (Prelude.Maybe Prelude.UTCTime)
jobSummary_completedAt :: Lens' JobSummary (Maybe UTCTime)
jobSummary_completedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe POSIX
completedAt :: Maybe POSIX
$sel:completedAt:JobSummary' :: JobSummary -> Maybe POSIX
completedAt} -> Maybe POSIX
completedAt) (\s :: JobSummary
s@JobSummary' {} Maybe POSIX
a -> JobSummary
s {$sel:completedAt:JobSummary' :: Maybe POSIX
completedAt = Maybe POSIX
a} :: JobSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The time, in seconds since the epoch, when the job was created.
jobSummary_createdAt :: Lens.Lens' JobSummary (Prelude.Maybe Prelude.UTCTime)
jobSummary_createdAt :: Lens' JobSummary (Maybe UTCTime)
jobSummary_createdAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:JobSummary' :: JobSummary -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: JobSummary
s@JobSummary' {} Maybe POSIX
a -> JobSummary
s {$sel:createdAt:JobSummary' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: JobSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Indicates whether a job is concurrent. Will be true when a job is
-- rolling out new job executions or canceling previously created
-- executions, otherwise false.
jobSummary_isConcurrent :: Lens.Lens' JobSummary (Prelude.Maybe Prelude.Bool)
jobSummary_isConcurrent :: Lens' JobSummary (Maybe Bool)
jobSummary_isConcurrent = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe Bool
isConcurrent :: Maybe Bool
$sel:isConcurrent:JobSummary' :: JobSummary -> Maybe Bool
isConcurrent} -> Maybe Bool
isConcurrent) (\s :: JobSummary
s@JobSummary' {} Maybe Bool
a -> JobSummary
s {$sel:isConcurrent:JobSummary' :: Maybe Bool
isConcurrent = Maybe Bool
a} :: JobSummary)

-- | The job ARN.
jobSummary_jobArn :: Lens.Lens' JobSummary (Prelude.Maybe Prelude.Text)
jobSummary_jobArn :: Lens' JobSummary (Maybe Text)
jobSummary_jobArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe Text
jobArn :: Maybe Text
$sel:jobArn:JobSummary' :: JobSummary -> Maybe Text
jobArn} -> Maybe Text
jobArn) (\s :: JobSummary
s@JobSummary' {} Maybe Text
a -> JobSummary
s {$sel:jobArn:JobSummary' :: Maybe Text
jobArn = Maybe Text
a} :: JobSummary)

-- | The unique identifier you assigned to this job when it was created.
jobSummary_jobId :: Lens.Lens' JobSummary (Prelude.Maybe Prelude.Text)
jobSummary_jobId :: Lens' JobSummary (Maybe Text)
jobSummary_jobId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe Text
jobId :: Maybe Text
$sel:jobId:JobSummary' :: JobSummary -> Maybe Text
jobId} -> Maybe Text
jobId) (\s :: JobSummary
s@JobSummary' {} Maybe Text
a -> JobSummary
s {$sel:jobId:JobSummary' :: Maybe Text
jobId = Maybe Text
a} :: JobSummary)

-- | The time, in seconds since the epoch, when the job was last updated.
jobSummary_lastUpdatedAt :: Lens.Lens' JobSummary (Prelude.Maybe Prelude.UTCTime)
jobSummary_lastUpdatedAt :: Lens' JobSummary (Maybe UTCTime)
jobSummary_lastUpdatedAt = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe POSIX
lastUpdatedAt :: Maybe POSIX
$sel:lastUpdatedAt:JobSummary' :: JobSummary -> Maybe POSIX
lastUpdatedAt} -> Maybe POSIX
lastUpdatedAt) (\s :: JobSummary
s@JobSummary' {} Maybe POSIX
a -> JobSummary
s {$sel:lastUpdatedAt:JobSummary' :: Maybe POSIX
lastUpdatedAt = Maybe POSIX
a} :: JobSummary) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The job summary status.
jobSummary_status :: Lens.Lens' JobSummary (Prelude.Maybe JobStatus)
jobSummary_status :: Lens' JobSummary (Maybe JobStatus)
jobSummary_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe JobStatus
status :: Maybe JobStatus
$sel:status:JobSummary' :: JobSummary -> Maybe JobStatus
status} -> Maybe JobStatus
status) (\s :: JobSummary
s@JobSummary' {} Maybe JobStatus
a -> JobSummary
s {$sel:status:JobSummary' :: Maybe JobStatus
status = Maybe JobStatus
a} :: JobSummary)

-- | Specifies whether the job will continue to run (CONTINUOUS), or will be
-- complete after all those things specified as targets have completed the
-- job (SNAPSHOT). If continuous, the job may also be run on a thing when a
-- change is detected in a target. For example, a job will run on a thing
-- when the thing is added to a target group, even after the job was
-- completed by all things originally in the group.
--
-- We recommend that you use continuous jobs instead of snapshot jobs for
-- dynamic thing group targets. By using continuous jobs, devices that join
-- the group receive the job execution even after the job has been created.
jobSummary_targetSelection :: Lens.Lens' JobSummary (Prelude.Maybe TargetSelection)
jobSummary_targetSelection :: Lens' JobSummary (Maybe TargetSelection)
jobSummary_targetSelection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe TargetSelection
targetSelection :: Maybe TargetSelection
$sel:targetSelection:JobSummary' :: JobSummary -> Maybe TargetSelection
targetSelection} -> Maybe TargetSelection
targetSelection) (\s :: JobSummary
s@JobSummary' {} Maybe TargetSelection
a -> JobSummary
s {$sel:targetSelection:JobSummary' :: Maybe TargetSelection
targetSelection = Maybe TargetSelection
a} :: JobSummary)

-- | The ID of the thing group.
jobSummary_thingGroupId :: Lens.Lens' JobSummary (Prelude.Maybe Prelude.Text)
jobSummary_thingGroupId :: Lens' JobSummary (Maybe Text)
jobSummary_thingGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobSummary' {Maybe Text
thingGroupId :: Maybe Text
$sel:thingGroupId:JobSummary' :: JobSummary -> Maybe Text
thingGroupId} -> Maybe Text
thingGroupId) (\s :: JobSummary
s@JobSummary' {} Maybe Text
a -> JobSummary
s {$sel:thingGroupId:JobSummary' :: Maybe Text
thingGroupId = Maybe Text
a} :: JobSummary)

instance Data.FromJSON JobSummary where
  parseJSON :: Value -> Parser JobSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JobSummary"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Maybe JobStatus
-> Maybe TargetSelection
-> Maybe Text
-> JobSummary
JobSummary'
            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
"completedAt")
            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
"createdAt")
            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
"isConcurrent")
            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
"jobArn")
            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
"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
"lastUpdatedAt")
            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
"status")
            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
"targetSelection")
            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
"thingGroupId")
      )

instance Prelude.Hashable JobSummary where
  hashWithSalt :: Int -> JobSummary -> Int
hashWithSalt Int
_salt JobSummary' {Maybe Bool
Maybe Text
Maybe POSIX
Maybe JobStatus
Maybe TargetSelection
thingGroupId :: Maybe Text
targetSelection :: Maybe TargetSelection
status :: Maybe JobStatus
lastUpdatedAt :: Maybe POSIX
jobId :: Maybe Text
jobArn :: Maybe Text
isConcurrent :: Maybe Bool
createdAt :: Maybe POSIX
completedAt :: Maybe POSIX
$sel:thingGroupId:JobSummary' :: JobSummary -> Maybe Text
$sel:targetSelection:JobSummary' :: JobSummary -> Maybe TargetSelection
$sel:status:JobSummary' :: JobSummary -> Maybe JobStatus
$sel:lastUpdatedAt:JobSummary' :: JobSummary -> Maybe POSIX
$sel:jobId:JobSummary' :: JobSummary -> Maybe Text
$sel:jobArn:JobSummary' :: JobSummary -> Maybe Text
$sel:isConcurrent:JobSummary' :: JobSummary -> Maybe Bool
$sel:createdAt:JobSummary' :: JobSummary -> Maybe POSIX
$sel:completedAt:JobSummary' :: JobSummary -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
completedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isConcurrent
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
jobArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
jobId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdatedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe JobStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TargetSelection
targetSelection
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingGroupId

instance Prelude.NFData JobSummary where
  rnf :: JobSummary -> ()
rnf JobSummary' {Maybe Bool
Maybe Text
Maybe POSIX
Maybe JobStatus
Maybe TargetSelection
thingGroupId :: Maybe Text
targetSelection :: Maybe TargetSelection
status :: Maybe JobStatus
lastUpdatedAt :: Maybe POSIX
jobId :: Maybe Text
jobArn :: Maybe Text
isConcurrent :: Maybe Bool
createdAt :: Maybe POSIX
completedAt :: Maybe POSIX
$sel:thingGroupId:JobSummary' :: JobSummary -> Maybe Text
$sel:targetSelection:JobSummary' :: JobSummary -> Maybe TargetSelection
$sel:status:JobSummary' :: JobSummary -> Maybe JobStatus
$sel:lastUpdatedAt:JobSummary' :: JobSummary -> Maybe POSIX
$sel:jobId:JobSummary' :: JobSummary -> Maybe Text
$sel:jobArn:JobSummary' :: JobSummary -> Maybe Text
$sel:isConcurrent:JobSummary' :: JobSummary -> Maybe Bool
$sel:createdAt:JobSummary' :: JobSummary -> Maybe POSIX
$sel:completedAt:JobSummary' :: JobSummary -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
completedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isConcurrent
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jobArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 POSIX
lastUpdatedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe JobStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TargetSelection
targetSelection
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingGroupId