{-# 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.Config.Types.RemediationExecutionStep
-- 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.Config.Types.RemediationExecutionStep where

import Amazonka.Config.Types.RemediationExecutionStepState
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Name of the step from the SSM document.
--
-- /See:/ 'newRemediationExecutionStep' smart constructor.
data RemediationExecutionStep = RemediationExecutionStep'
  { -- | The valid status of the step.
    RemediationExecutionStep -> Maybe RemediationExecutionStepState
state :: Prelude.Maybe RemediationExecutionStepState,
    -- | The time when the step started.
    RemediationExecutionStep -> Maybe POSIX
startTime :: Prelude.Maybe Core.POSIX,
    -- | The details of the step.
    RemediationExecutionStep -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The time when the step stopped.
    RemediationExecutionStep -> Maybe POSIX
stopTime :: Prelude.Maybe Core.POSIX,
    -- | An error message if the step was interrupted during execution.
    RemediationExecutionStep -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (RemediationExecutionStep -> RemediationExecutionStep -> Bool
(RemediationExecutionStep -> RemediationExecutionStep -> Bool)
-> (RemediationExecutionStep -> RemediationExecutionStep -> Bool)
-> Eq RemediationExecutionStep
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemediationExecutionStep -> RemediationExecutionStep -> Bool
$c/= :: RemediationExecutionStep -> RemediationExecutionStep -> Bool
== :: RemediationExecutionStep -> RemediationExecutionStep -> Bool
$c== :: RemediationExecutionStep -> RemediationExecutionStep -> Bool
Prelude.Eq, ReadPrec [RemediationExecutionStep]
ReadPrec RemediationExecutionStep
Int -> ReadS RemediationExecutionStep
ReadS [RemediationExecutionStep]
(Int -> ReadS RemediationExecutionStep)
-> ReadS [RemediationExecutionStep]
-> ReadPrec RemediationExecutionStep
-> ReadPrec [RemediationExecutionStep]
-> Read RemediationExecutionStep
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemediationExecutionStep]
$creadListPrec :: ReadPrec [RemediationExecutionStep]
readPrec :: ReadPrec RemediationExecutionStep
$creadPrec :: ReadPrec RemediationExecutionStep
readList :: ReadS [RemediationExecutionStep]
$creadList :: ReadS [RemediationExecutionStep]
readsPrec :: Int -> ReadS RemediationExecutionStep
$creadsPrec :: Int -> ReadS RemediationExecutionStep
Prelude.Read, Int -> RemediationExecutionStep -> ShowS
[RemediationExecutionStep] -> ShowS
RemediationExecutionStep -> String
(Int -> RemediationExecutionStep -> ShowS)
-> (RemediationExecutionStep -> String)
-> ([RemediationExecutionStep] -> ShowS)
-> Show RemediationExecutionStep
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemediationExecutionStep] -> ShowS
$cshowList :: [RemediationExecutionStep] -> ShowS
show :: RemediationExecutionStep -> String
$cshow :: RemediationExecutionStep -> String
showsPrec :: Int -> RemediationExecutionStep -> ShowS
$cshowsPrec :: Int -> RemediationExecutionStep -> ShowS
Prelude.Show, (forall x.
 RemediationExecutionStep -> Rep RemediationExecutionStep x)
-> (forall x.
    Rep RemediationExecutionStep x -> RemediationExecutionStep)
-> Generic RemediationExecutionStep
forall x.
Rep RemediationExecutionStep x -> RemediationExecutionStep
forall x.
RemediationExecutionStep -> Rep RemediationExecutionStep x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemediationExecutionStep x -> RemediationExecutionStep
$cfrom :: forall x.
RemediationExecutionStep -> Rep RemediationExecutionStep x
Prelude.Generic)

-- |
-- Create a value of 'RemediationExecutionStep' 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:
--
-- 'state', 'remediationExecutionStep_state' - The valid status of the step.
--
-- 'startTime', 'remediationExecutionStep_startTime' - The time when the step started.
--
-- 'name', 'remediationExecutionStep_name' - The details of the step.
--
-- 'stopTime', 'remediationExecutionStep_stopTime' - The time when the step stopped.
--
-- 'errorMessage', 'remediationExecutionStep_errorMessage' - An error message if the step was interrupted during execution.
newRemediationExecutionStep ::
  RemediationExecutionStep
newRemediationExecutionStep :: RemediationExecutionStep
newRemediationExecutionStep =
  RemediationExecutionStep' :: Maybe RemediationExecutionStepState
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> RemediationExecutionStep
RemediationExecutionStep'
    { $sel:state:RemediationExecutionStep' :: Maybe RemediationExecutionStepState
state = Maybe RemediationExecutionStepState
forall a. Maybe a
Prelude.Nothing,
      $sel:startTime:RemediationExecutionStep' :: Maybe POSIX
startTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:RemediationExecutionStep' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stopTime:RemediationExecutionStep' :: Maybe POSIX
stopTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:RemediationExecutionStep' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The valid status of the step.
remediationExecutionStep_state :: Lens.Lens' RemediationExecutionStep (Prelude.Maybe RemediationExecutionStepState)
remediationExecutionStep_state :: (Maybe RemediationExecutionStepState
 -> f (Maybe RemediationExecutionStepState))
-> RemediationExecutionStep -> f RemediationExecutionStep
remediationExecutionStep_state = (RemediationExecutionStep -> Maybe RemediationExecutionStepState)
-> (RemediationExecutionStep
    -> Maybe RemediationExecutionStepState -> RemediationExecutionStep)
-> Lens
     RemediationExecutionStep
     RemediationExecutionStep
     (Maybe RemediationExecutionStepState)
     (Maybe RemediationExecutionStepState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationExecutionStep' {Maybe RemediationExecutionStepState
state :: Maybe RemediationExecutionStepState
$sel:state:RemediationExecutionStep' :: RemediationExecutionStep -> Maybe RemediationExecutionStepState
state} -> Maybe RemediationExecutionStepState
state) (\s :: RemediationExecutionStep
s@RemediationExecutionStep' {} Maybe RemediationExecutionStepState
a -> RemediationExecutionStep
s {$sel:state:RemediationExecutionStep' :: Maybe RemediationExecutionStepState
state = Maybe RemediationExecutionStepState
a} :: RemediationExecutionStep)

-- | The time when the step started.
remediationExecutionStep_startTime :: Lens.Lens' RemediationExecutionStep (Prelude.Maybe Prelude.UTCTime)
remediationExecutionStep_startTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RemediationExecutionStep -> f RemediationExecutionStep
remediationExecutionStep_startTime = (RemediationExecutionStep -> Maybe POSIX)
-> (RemediationExecutionStep
    -> Maybe POSIX -> RemediationExecutionStep)
-> Lens
     RemediationExecutionStep
     RemediationExecutionStep
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationExecutionStep' {Maybe POSIX
startTime :: Maybe POSIX
$sel:startTime:RemediationExecutionStep' :: RemediationExecutionStep -> Maybe POSIX
startTime} -> Maybe POSIX
startTime) (\s :: RemediationExecutionStep
s@RemediationExecutionStep' {} Maybe POSIX
a -> RemediationExecutionStep
s {$sel:startTime:RemediationExecutionStep' :: Maybe POSIX
startTime = Maybe POSIX
a} :: RemediationExecutionStep) ((Maybe POSIX -> f (Maybe POSIX))
 -> RemediationExecutionStep -> f RemediationExecutionStep)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RemediationExecutionStep
-> f RemediationExecutionStep
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The details of the step.
remediationExecutionStep_name :: Lens.Lens' RemediationExecutionStep (Prelude.Maybe Prelude.Text)
remediationExecutionStep_name :: (Maybe Text -> f (Maybe Text))
-> RemediationExecutionStep -> f RemediationExecutionStep
remediationExecutionStep_name = (RemediationExecutionStep -> Maybe Text)
-> (RemediationExecutionStep
    -> Maybe Text -> RemediationExecutionStep)
-> Lens
     RemediationExecutionStep
     RemediationExecutionStep
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationExecutionStep' {Maybe Text
name :: Maybe Text
$sel:name:RemediationExecutionStep' :: RemediationExecutionStep -> Maybe Text
name} -> Maybe Text
name) (\s :: RemediationExecutionStep
s@RemediationExecutionStep' {} Maybe Text
a -> RemediationExecutionStep
s {$sel:name:RemediationExecutionStep' :: Maybe Text
name = Maybe Text
a} :: RemediationExecutionStep)

-- | The time when the step stopped.
remediationExecutionStep_stopTime :: Lens.Lens' RemediationExecutionStep (Prelude.Maybe Prelude.UTCTime)
remediationExecutionStep_stopTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RemediationExecutionStep -> f RemediationExecutionStep
remediationExecutionStep_stopTime = (RemediationExecutionStep -> Maybe POSIX)
-> (RemediationExecutionStep
    -> Maybe POSIX -> RemediationExecutionStep)
-> Lens
     RemediationExecutionStep
     RemediationExecutionStep
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationExecutionStep' {Maybe POSIX
stopTime :: Maybe POSIX
$sel:stopTime:RemediationExecutionStep' :: RemediationExecutionStep -> Maybe POSIX
stopTime} -> Maybe POSIX
stopTime) (\s :: RemediationExecutionStep
s@RemediationExecutionStep' {} Maybe POSIX
a -> RemediationExecutionStep
s {$sel:stopTime:RemediationExecutionStep' :: Maybe POSIX
stopTime = Maybe POSIX
a} :: RemediationExecutionStep) ((Maybe POSIX -> f (Maybe POSIX))
 -> RemediationExecutionStep -> f RemediationExecutionStep)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RemediationExecutionStep
-> f RemediationExecutionStep
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | An error message if the step was interrupted during execution.
remediationExecutionStep_errorMessage :: Lens.Lens' RemediationExecutionStep (Prelude.Maybe Prelude.Text)
remediationExecutionStep_errorMessage :: (Maybe Text -> f (Maybe Text))
-> RemediationExecutionStep -> f RemediationExecutionStep
remediationExecutionStep_errorMessage = (RemediationExecutionStep -> Maybe Text)
-> (RemediationExecutionStep
    -> Maybe Text -> RemediationExecutionStep)
-> Lens
     RemediationExecutionStep
     RemediationExecutionStep
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemediationExecutionStep' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:RemediationExecutionStep' :: RemediationExecutionStep -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: RemediationExecutionStep
s@RemediationExecutionStep' {} Maybe Text
a -> RemediationExecutionStep
s {$sel:errorMessage:RemediationExecutionStep' :: Maybe Text
errorMessage = Maybe Text
a} :: RemediationExecutionStep)

instance Core.FromJSON RemediationExecutionStep where
  parseJSON :: Value -> Parser RemediationExecutionStep
parseJSON =
    String
-> (Object -> Parser RemediationExecutionStep)
-> Value
-> Parser RemediationExecutionStep
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RemediationExecutionStep"
      ( \Object
x ->
          Maybe RemediationExecutionStepState
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> RemediationExecutionStep
RemediationExecutionStep'
            (Maybe RemediationExecutionStepState
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> RemediationExecutionStep)
-> Parser (Maybe RemediationExecutionStepState)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> RemediationExecutionStep)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RemediationExecutionStepState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> RemediationExecutionStep)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe POSIX -> Maybe Text -> RemediationExecutionStep)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartTime")
            Parser
  (Maybe Text
   -> Maybe POSIX -> Maybe Text -> RemediationExecutionStep)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> RemediationExecutionStep)
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
"Name")
            Parser (Maybe POSIX -> Maybe Text -> RemediationExecutionStep)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> RemediationExecutionStep)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StopTime")
            Parser (Maybe Text -> RemediationExecutionStep)
-> Parser (Maybe Text) -> Parser RemediationExecutionStep
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
"ErrorMessage")
      )

instance Prelude.Hashable RemediationExecutionStep

instance Prelude.NFData RemediationExecutionStep