{-# 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.Route53RecoveryReadiness.Types.RuleResult
-- 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.Route53RecoveryReadiness.Types.RuleResult where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryReadiness.Types.Message
import Amazonka.Route53RecoveryReadiness.Types.Readiness

-- | Result with status for an individual rule..
--
-- /See:/ 'newRuleResult' smart constructor.
data RuleResult = RuleResult'
  { -- | Details about the resource\'s readiness
    RuleResult -> [Message]
messages :: [Message],
    -- | The readiness at rule level.
    RuleResult -> Readiness
readiness :: Readiness,
    -- | The identifier of the rule.
    RuleResult -> Text
ruleId :: Prelude.Text,
    -- | The time the resource was last checked for readiness, in ISO-8601
    -- format, UTC.
    RuleResult -> POSIX
lastCheckedTimestamp :: Core.POSIX
  }
  deriving (RuleResult -> RuleResult -> Bool
(RuleResult -> RuleResult -> Bool)
-> (RuleResult -> RuleResult -> Bool) -> Eq RuleResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleResult -> RuleResult -> Bool
$c/= :: RuleResult -> RuleResult -> Bool
== :: RuleResult -> RuleResult -> Bool
$c== :: RuleResult -> RuleResult -> Bool
Prelude.Eq, ReadPrec [RuleResult]
ReadPrec RuleResult
Int -> ReadS RuleResult
ReadS [RuleResult]
(Int -> ReadS RuleResult)
-> ReadS [RuleResult]
-> ReadPrec RuleResult
-> ReadPrec [RuleResult]
-> Read RuleResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleResult]
$creadListPrec :: ReadPrec [RuleResult]
readPrec :: ReadPrec RuleResult
$creadPrec :: ReadPrec RuleResult
readList :: ReadS [RuleResult]
$creadList :: ReadS [RuleResult]
readsPrec :: Int -> ReadS RuleResult
$creadsPrec :: Int -> ReadS RuleResult
Prelude.Read, Int -> RuleResult -> ShowS
[RuleResult] -> ShowS
RuleResult -> String
(Int -> RuleResult -> ShowS)
-> (RuleResult -> String)
-> ([RuleResult] -> ShowS)
-> Show RuleResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleResult] -> ShowS
$cshowList :: [RuleResult] -> ShowS
show :: RuleResult -> String
$cshow :: RuleResult -> String
showsPrec :: Int -> RuleResult -> ShowS
$cshowsPrec :: Int -> RuleResult -> ShowS
Prelude.Show, (forall x. RuleResult -> Rep RuleResult x)
-> (forall x. Rep RuleResult x -> RuleResult) -> Generic RuleResult
forall x. Rep RuleResult x -> RuleResult
forall x. RuleResult -> Rep RuleResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleResult x -> RuleResult
$cfrom :: forall x. RuleResult -> Rep RuleResult x
Prelude.Generic)

-- |
-- Create a value of 'RuleResult' 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:
--
-- 'messages', 'ruleResult_messages' - Details about the resource\'s readiness
--
-- 'readiness', 'ruleResult_readiness' - The readiness at rule level.
--
-- 'ruleId', 'ruleResult_ruleId' - The identifier of the rule.
--
-- 'lastCheckedTimestamp', 'ruleResult_lastCheckedTimestamp' - The time the resource was last checked for readiness, in ISO-8601
-- format, UTC.
newRuleResult ::
  -- | 'readiness'
  Readiness ->
  -- | 'ruleId'
  Prelude.Text ->
  -- | 'lastCheckedTimestamp'
  Prelude.UTCTime ->
  RuleResult
newRuleResult :: Readiness -> Text -> UTCTime -> RuleResult
newRuleResult
  Readiness
pReadiness_
  Text
pRuleId_
  UTCTime
pLastCheckedTimestamp_ =
    RuleResult' :: [Message] -> Readiness -> Text -> POSIX -> RuleResult
RuleResult'
      { $sel:messages:RuleResult' :: [Message]
messages = [Message]
forall a. Monoid a => a
Prelude.mempty,
        $sel:readiness:RuleResult' :: Readiness
readiness = Readiness
pReadiness_,
        $sel:ruleId:RuleResult' :: Text
ruleId = Text
pRuleId_,
        $sel:lastCheckedTimestamp:RuleResult' :: POSIX
lastCheckedTimestamp =
          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
pLastCheckedTimestamp_
      }

-- | Details about the resource\'s readiness
ruleResult_messages :: Lens.Lens' RuleResult [Message]
ruleResult_messages :: ([Message] -> f [Message]) -> RuleResult -> f RuleResult
ruleResult_messages = (RuleResult -> [Message])
-> (RuleResult -> [Message] -> RuleResult)
-> Lens RuleResult RuleResult [Message] [Message]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleResult' {[Message]
messages :: [Message]
$sel:messages:RuleResult' :: RuleResult -> [Message]
messages} -> [Message]
messages) (\s :: RuleResult
s@RuleResult' {} [Message]
a -> RuleResult
s {$sel:messages:RuleResult' :: [Message]
messages = [Message]
a} :: RuleResult) (([Message] -> f [Message]) -> RuleResult -> f RuleResult)
-> (([Message] -> f [Message]) -> [Message] -> f [Message])
-> ([Message] -> f [Message])
-> RuleResult
-> f RuleResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Message] -> f [Message]) -> [Message] -> f [Message]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The readiness at rule level.
ruleResult_readiness :: Lens.Lens' RuleResult Readiness
ruleResult_readiness :: (Readiness -> f Readiness) -> RuleResult -> f RuleResult
ruleResult_readiness = (RuleResult -> Readiness)
-> (RuleResult -> Readiness -> RuleResult)
-> Lens RuleResult RuleResult Readiness Readiness
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleResult' {Readiness
readiness :: Readiness
$sel:readiness:RuleResult' :: RuleResult -> Readiness
readiness} -> Readiness
readiness) (\s :: RuleResult
s@RuleResult' {} Readiness
a -> RuleResult
s {$sel:readiness:RuleResult' :: Readiness
readiness = Readiness
a} :: RuleResult)

-- | The identifier of the rule.
ruleResult_ruleId :: Lens.Lens' RuleResult Prelude.Text
ruleResult_ruleId :: (Text -> f Text) -> RuleResult -> f RuleResult
ruleResult_ruleId = (RuleResult -> Text)
-> (RuleResult -> Text -> RuleResult)
-> Lens RuleResult RuleResult Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleResult' {Text
ruleId :: Text
$sel:ruleId:RuleResult' :: RuleResult -> Text
ruleId} -> Text
ruleId) (\s :: RuleResult
s@RuleResult' {} Text
a -> RuleResult
s {$sel:ruleId:RuleResult' :: Text
ruleId = Text
a} :: RuleResult)

-- | The time the resource was last checked for readiness, in ISO-8601
-- format, UTC.
ruleResult_lastCheckedTimestamp :: Lens.Lens' RuleResult Prelude.UTCTime
ruleResult_lastCheckedTimestamp :: (UTCTime -> f UTCTime) -> RuleResult -> f RuleResult
ruleResult_lastCheckedTimestamp = (RuleResult -> POSIX)
-> (RuleResult -> POSIX -> RuleResult)
-> Lens RuleResult RuleResult POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleResult' {POSIX
lastCheckedTimestamp :: POSIX
$sel:lastCheckedTimestamp:RuleResult' :: RuleResult -> POSIX
lastCheckedTimestamp} -> POSIX
lastCheckedTimestamp) (\s :: RuleResult
s@RuleResult' {} POSIX
a -> RuleResult
s {$sel:lastCheckedTimestamp:RuleResult' :: POSIX
lastCheckedTimestamp = POSIX
a} :: RuleResult) ((POSIX -> f POSIX) -> RuleResult -> f RuleResult)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> RuleResult
-> f RuleResult
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

instance Core.FromJSON RuleResult where
  parseJSON :: Value -> Parser RuleResult
parseJSON =
    String
-> (Object -> Parser RuleResult) -> Value -> Parser RuleResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RuleResult"
      ( \Object
x ->
          [Message] -> Readiness -> Text -> POSIX -> RuleResult
RuleResult'
            ([Message] -> Readiness -> Text -> POSIX -> RuleResult)
-> Parser [Message]
-> Parser (Readiness -> Text -> POSIX -> RuleResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe [Message])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"messages" Parser (Maybe [Message]) -> [Message] -> Parser [Message]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Message]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Readiness -> Text -> POSIX -> RuleResult)
-> Parser Readiness -> Parser (Text -> POSIX -> RuleResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Readiness
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"readiness")
            Parser (Text -> POSIX -> RuleResult)
-> Parser Text -> Parser (POSIX -> RuleResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ruleId")
            Parser (POSIX -> RuleResult) -> Parser POSIX -> Parser RuleResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"lastCheckedTimestamp")
      )

instance Prelude.Hashable RuleResult

instance Prelude.NFData RuleResult