{-# 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.ResourceResult
-- 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.ResourceResult where

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

-- | Result with status for an individual resource.
--
-- /See:/ 'newResourceResult' smart constructor.
data ResourceResult = ResourceResult'
  { -- | The ARN of the resource
    ResourceResult -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The component id of the resource
    ResourceResult -> Maybe Text
componentId :: Prelude.Maybe Prelude.Text,
    -- | The readiness of the resource.
    ResourceResult -> Readiness
readiness :: Readiness,
    -- | The time the resource was last checked for readiness, in ISO-8601
    -- format, UTC.
    ResourceResult -> POSIX
lastCheckedTimestamp :: Core.POSIX
  }
  deriving (ResourceResult -> ResourceResult -> Bool
(ResourceResult -> ResourceResult -> Bool)
-> (ResourceResult -> ResourceResult -> Bool) -> Eq ResourceResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceResult -> ResourceResult -> Bool
$c/= :: ResourceResult -> ResourceResult -> Bool
== :: ResourceResult -> ResourceResult -> Bool
$c== :: ResourceResult -> ResourceResult -> Bool
Prelude.Eq, ReadPrec [ResourceResult]
ReadPrec ResourceResult
Int -> ReadS ResourceResult
ReadS [ResourceResult]
(Int -> ReadS ResourceResult)
-> ReadS [ResourceResult]
-> ReadPrec ResourceResult
-> ReadPrec [ResourceResult]
-> Read ResourceResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceResult]
$creadListPrec :: ReadPrec [ResourceResult]
readPrec :: ReadPrec ResourceResult
$creadPrec :: ReadPrec ResourceResult
readList :: ReadS [ResourceResult]
$creadList :: ReadS [ResourceResult]
readsPrec :: Int -> ReadS ResourceResult
$creadsPrec :: Int -> ReadS ResourceResult
Prelude.Read, Int -> ResourceResult -> ShowS
[ResourceResult] -> ShowS
ResourceResult -> String
(Int -> ResourceResult -> ShowS)
-> (ResourceResult -> String)
-> ([ResourceResult] -> ShowS)
-> Show ResourceResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceResult] -> ShowS
$cshowList :: [ResourceResult] -> ShowS
show :: ResourceResult -> String
$cshow :: ResourceResult -> String
showsPrec :: Int -> ResourceResult -> ShowS
$cshowsPrec :: Int -> ResourceResult -> ShowS
Prelude.Show, (forall x. ResourceResult -> Rep ResourceResult x)
-> (forall x. Rep ResourceResult x -> ResourceResult)
-> Generic ResourceResult
forall x. Rep ResourceResult x -> ResourceResult
forall x. ResourceResult -> Rep ResourceResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceResult x -> ResourceResult
$cfrom :: forall x. ResourceResult -> Rep ResourceResult x
Prelude.Generic)

-- |
-- Create a value of 'ResourceResult' 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:
--
-- 'resourceArn', 'resourceResult_resourceArn' - The ARN of the resource
--
-- 'componentId', 'resourceResult_componentId' - The component id of the resource
--
-- 'readiness', 'resourceResult_readiness' - The readiness of the resource.
--
-- 'lastCheckedTimestamp', 'resourceResult_lastCheckedTimestamp' - The time the resource was last checked for readiness, in ISO-8601
-- format, UTC.
newResourceResult ::
  -- | 'readiness'
  Readiness ->
  -- | 'lastCheckedTimestamp'
  Prelude.UTCTime ->
  ResourceResult
newResourceResult :: Readiness -> UTCTime -> ResourceResult
newResourceResult Readiness
pReadiness_ UTCTime
pLastCheckedTimestamp_ =
  ResourceResult' :: Maybe Text -> Maybe Text -> Readiness -> POSIX -> ResourceResult
ResourceResult'
    { $sel:resourceArn:ResourceResult' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:componentId:ResourceResult' :: Maybe Text
componentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:readiness:ResourceResult' :: Readiness
readiness = Readiness
pReadiness_,
      $sel:lastCheckedTimestamp:ResourceResult' :: 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_
    }

-- | The ARN of the resource
resourceResult_resourceArn :: Lens.Lens' ResourceResult (Prelude.Maybe Prelude.Text)
resourceResult_resourceArn :: (Maybe Text -> f (Maybe Text))
-> ResourceResult -> f ResourceResult
resourceResult_resourceArn = (ResourceResult -> Maybe Text)
-> (ResourceResult -> Maybe Text -> ResourceResult)
-> Lens ResourceResult ResourceResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceResult' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:ResourceResult' :: ResourceResult -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: ResourceResult
s@ResourceResult' {} Maybe Text
a -> ResourceResult
s {$sel:resourceArn:ResourceResult' :: Maybe Text
resourceArn = Maybe Text
a} :: ResourceResult)

-- | The component id of the resource
resourceResult_componentId :: Lens.Lens' ResourceResult (Prelude.Maybe Prelude.Text)
resourceResult_componentId :: (Maybe Text -> f (Maybe Text))
-> ResourceResult -> f ResourceResult
resourceResult_componentId = (ResourceResult -> Maybe Text)
-> (ResourceResult -> Maybe Text -> ResourceResult)
-> Lens ResourceResult ResourceResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceResult' {Maybe Text
componentId :: Maybe Text
$sel:componentId:ResourceResult' :: ResourceResult -> Maybe Text
componentId} -> Maybe Text
componentId) (\s :: ResourceResult
s@ResourceResult' {} Maybe Text
a -> ResourceResult
s {$sel:componentId:ResourceResult' :: Maybe Text
componentId = Maybe Text
a} :: ResourceResult)

-- | The readiness of the resource.
resourceResult_readiness :: Lens.Lens' ResourceResult Readiness
resourceResult_readiness :: (Readiness -> f Readiness) -> ResourceResult -> f ResourceResult
resourceResult_readiness = (ResourceResult -> Readiness)
-> (ResourceResult -> Readiness -> ResourceResult)
-> Lens ResourceResult ResourceResult Readiness Readiness
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceResult' {Readiness
readiness :: Readiness
$sel:readiness:ResourceResult' :: ResourceResult -> Readiness
readiness} -> Readiness
readiness) (\s :: ResourceResult
s@ResourceResult' {} Readiness
a -> ResourceResult
s {$sel:readiness:ResourceResult' :: Readiness
readiness = Readiness
a} :: ResourceResult)

-- | The time the resource was last checked for readiness, in ISO-8601
-- format, UTC.
resourceResult_lastCheckedTimestamp :: Lens.Lens' ResourceResult Prelude.UTCTime
resourceResult_lastCheckedTimestamp :: (UTCTime -> f UTCTime) -> ResourceResult -> f ResourceResult
resourceResult_lastCheckedTimestamp = (ResourceResult -> POSIX)
-> (ResourceResult -> POSIX -> ResourceResult)
-> Lens ResourceResult ResourceResult POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceResult' {POSIX
lastCheckedTimestamp :: POSIX
$sel:lastCheckedTimestamp:ResourceResult' :: ResourceResult -> POSIX
lastCheckedTimestamp} -> POSIX
lastCheckedTimestamp) (\s :: ResourceResult
s@ResourceResult' {} POSIX
a -> ResourceResult
s {$sel:lastCheckedTimestamp:ResourceResult' :: POSIX
lastCheckedTimestamp = POSIX
a} :: ResourceResult) ((POSIX -> f POSIX) -> ResourceResult -> f ResourceResult)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ResourceResult
-> f ResourceResult
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 ResourceResult where
  parseJSON :: Value -> Parser ResourceResult
parseJSON =
    String
-> (Object -> Parser ResourceResult)
-> Value
-> Parser ResourceResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceResult"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Readiness -> POSIX -> ResourceResult
ResourceResult'
            (Maybe Text -> Maybe Text -> Readiness -> POSIX -> ResourceResult)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Readiness -> POSIX -> ResourceResult)
forall (f :: * -> *) a b. Functor 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
"resourceArn")
            Parser (Maybe Text -> Readiness -> POSIX -> ResourceResult)
-> Parser (Maybe Text)
-> Parser (Readiness -> POSIX -> ResourceResult)
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
"componentId")
            Parser (Readiness -> POSIX -> ResourceResult)
-> Parser Readiness -> Parser (POSIX -> ResourceResult)
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 (POSIX -> ResourceResult)
-> Parser POSIX -> Parser ResourceResult
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 ResourceResult

instance Prelude.NFData ResourceResult