{-# 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.Inspector.Types.AssessmentRunStateChange
-- 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.Inspector.Types.AssessmentRunStateChange where

import qualified Amazonka.Core as Core
import Amazonka.Inspector.Types.AssessmentRunState
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Used as one of the elements of the AssessmentRun data type.
--
-- /See:/ 'newAssessmentRunStateChange' smart constructor.
data AssessmentRunStateChange = AssessmentRunStateChange'
  { -- | The last time the assessment run state changed.
    AssessmentRunStateChange -> POSIX
stateChangedAt :: Core.POSIX,
    -- | The assessment run state.
    AssessmentRunStateChange -> AssessmentRunState
state :: AssessmentRunState
  }
  deriving (AssessmentRunStateChange -> AssessmentRunStateChange -> Bool
(AssessmentRunStateChange -> AssessmentRunStateChange -> Bool)
-> (AssessmentRunStateChange -> AssessmentRunStateChange -> Bool)
-> Eq AssessmentRunStateChange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssessmentRunStateChange -> AssessmentRunStateChange -> Bool
$c/= :: AssessmentRunStateChange -> AssessmentRunStateChange -> Bool
== :: AssessmentRunStateChange -> AssessmentRunStateChange -> Bool
$c== :: AssessmentRunStateChange -> AssessmentRunStateChange -> Bool
Prelude.Eq, ReadPrec [AssessmentRunStateChange]
ReadPrec AssessmentRunStateChange
Int -> ReadS AssessmentRunStateChange
ReadS [AssessmentRunStateChange]
(Int -> ReadS AssessmentRunStateChange)
-> ReadS [AssessmentRunStateChange]
-> ReadPrec AssessmentRunStateChange
-> ReadPrec [AssessmentRunStateChange]
-> Read AssessmentRunStateChange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssessmentRunStateChange]
$creadListPrec :: ReadPrec [AssessmentRunStateChange]
readPrec :: ReadPrec AssessmentRunStateChange
$creadPrec :: ReadPrec AssessmentRunStateChange
readList :: ReadS [AssessmentRunStateChange]
$creadList :: ReadS [AssessmentRunStateChange]
readsPrec :: Int -> ReadS AssessmentRunStateChange
$creadsPrec :: Int -> ReadS AssessmentRunStateChange
Prelude.Read, Int -> AssessmentRunStateChange -> ShowS
[AssessmentRunStateChange] -> ShowS
AssessmentRunStateChange -> String
(Int -> AssessmentRunStateChange -> ShowS)
-> (AssessmentRunStateChange -> String)
-> ([AssessmentRunStateChange] -> ShowS)
-> Show AssessmentRunStateChange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssessmentRunStateChange] -> ShowS
$cshowList :: [AssessmentRunStateChange] -> ShowS
show :: AssessmentRunStateChange -> String
$cshow :: AssessmentRunStateChange -> String
showsPrec :: Int -> AssessmentRunStateChange -> ShowS
$cshowsPrec :: Int -> AssessmentRunStateChange -> ShowS
Prelude.Show, (forall x.
 AssessmentRunStateChange -> Rep AssessmentRunStateChange x)
-> (forall x.
    Rep AssessmentRunStateChange x -> AssessmentRunStateChange)
-> Generic AssessmentRunStateChange
forall x.
Rep AssessmentRunStateChange x -> AssessmentRunStateChange
forall x.
AssessmentRunStateChange -> Rep AssessmentRunStateChange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AssessmentRunStateChange x -> AssessmentRunStateChange
$cfrom :: forall x.
AssessmentRunStateChange -> Rep AssessmentRunStateChange x
Prelude.Generic)

-- |
-- Create a value of 'AssessmentRunStateChange' 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:
--
-- 'stateChangedAt', 'assessmentRunStateChange_stateChangedAt' - The last time the assessment run state changed.
--
-- 'state', 'assessmentRunStateChange_state' - The assessment run state.
newAssessmentRunStateChange ::
  -- | 'stateChangedAt'
  Prelude.UTCTime ->
  -- | 'state'
  AssessmentRunState ->
  AssessmentRunStateChange
newAssessmentRunStateChange :: UTCTime -> AssessmentRunState -> AssessmentRunStateChange
newAssessmentRunStateChange UTCTime
pStateChangedAt_ AssessmentRunState
pState_ =
  AssessmentRunStateChange' :: POSIX -> AssessmentRunState -> AssessmentRunStateChange
AssessmentRunStateChange'
    { $sel:stateChangedAt:AssessmentRunStateChange' :: POSIX
stateChangedAt =
        Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStateChangedAt_,
      $sel:state:AssessmentRunStateChange' :: AssessmentRunState
state = AssessmentRunState
pState_
    }

-- | The last time the assessment run state changed.
assessmentRunStateChange_stateChangedAt :: Lens.Lens' AssessmentRunStateChange Prelude.UTCTime
assessmentRunStateChange_stateChangedAt :: (UTCTime -> f UTCTime)
-> AssessmentRunStateChange -> f AssessmentRunStateChange
assessmentRunStateChange_stateChangedAt = (AssessmentRunStateChange -> POSIX)
-> (AssessmentRunStateChange -> POSIX -> AssessmentRunStateChange)
-> Lens
     AssessmentRunStateChange AssessmentRunStateChange POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunStateChange' {POSIX
stateChangedAt :: POSIX
$sel:stateChangedAt:AssessmentRunStateChange' :: AssessmentRunStateChange -> POSIX
stateChangedAt} -> POSIX
stateChangedAt) (\s :: AssessmentRunStateChange
s@AssessmentRunStateChange' {} POSIX
a -> AssessmentRunStateChange
s {$sel:stateChangedAt:AssessmentRunStateChange' :: POSIX
stateChangedAt = POSIX
a} :: AssessmentRunStateChange) ((POSIX -> f POSIX)
 -> AssessmentRunStateChange -> f AssessmentRunStateChange)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> AssessmentRunStateChange
-> f AssessmentRunStateChange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The assessment run state.
assessmentRunStateChange_state :: Lens.Lens' AssessmentRunStateChange AssessmentRunState
assessmentRunStateChange_state :: (AssessmentRunState -> f AssessmentRunState)
-> AssessmentRunStateChange -> f AssessmentRunStateChange
assessmentRunStateChange_state = (AssessmentRunStateChange -> AssessmentRunState)
-> (AssessmentRunStateChange
    -> AssessmentRunState -> AssessmentRunStateChange)
-> Lens
     AssessmentRunStateChange
     AssessmentRunStateChange
     AssessmentRunState
     AssessmentRunState
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssessmentRunStateChange' {AssessmentRunState
state :: AssessmentRunState
$sel:state:AssessmentRunStateChange' :: AssessmentRunStateChange -> AssessmentRunState
state} -> AssessmentRunState
state) (\s :: AssessmentRunStateChange
s@AssessmentRunStateChange' {} AssessmentRunState
a -> AssessmentRunStateChange
s {$sel:state:AssessmentRunStateChange' :: AssessmentRunState
state = AssessmentRunState
a} :: AssessmentRunStateChange)

instance Core.FromJSON AssessmentRunStateChange where
  parseJSON :: Value -> Parser AssessmentRunStateChange
parseJSON =
    String
-> (Object -> Parser AssessmentRunStateChange)
-> Value
-> Parser AssessmentRunStateChange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssessmentRunStateChange"
      ( \Object
x ->
          POSIX -> AssessmentRunState -> AssessmentRunStateChange
AssessmentRunStateChange'
            (POSIX -> AssessmentRunState -> AssessmentRunStateChange)
-> Parser POSIX
-> Parser (AssessmentRunState -> AssessmentRunStateChange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"stateChangedAt")
            Parser (AssessmentRunState -> AssessmentRunStateChange)
-> Parser AssessmentRunState -> Parser AssessmentRunStateChange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AssessmentRunState
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"state")
      )

instance Prelude.Hashable AssessmentRunStateChange

instance Prelude.NFData AssessmentRunStateChange