{-# 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.RDS.Types.RestoreWindow
-- 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.RDS.Types.RestoreWindow where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Earliest and latest time an instance can be restored to:
--
-- /See:/ 'newRestoreWindow' smart constructor.
data RestoreWindow = RestoreWindow'
  { -- | The latest time you can restore an instance to.
    RestoreWindow -> Maybe ISO8601
latestTime :: Prelude.Maybe Core.ISO8601,
    -- | The earliest time you can restore an instance to.
    RestoreWindow -> Maybe ISO8601
earliestTime :: Prelude.Maybe Core.ISO8601
  }
  deriving (RestoreWindow -> RestoreWindow -> Bool
(RestoreWindow -> RestoreWindow -> Bool)
-> (RestoreWindow -> RestoreWindow -> Bool) -> Eq RestoreWindow
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreWindow -> RestoreWindow -> Bool
$c/= :: RestoreWindow -> RestoreWindow -> Bool
== :: RestoreWindow -> RestoreWindow -> Bool
$c== :: RestoreWindow -> RestoreWindow -> Bool
Prelude.Eq, ReadPrec [RestoreWindow]
ReadPrec RestoreWindow
Int -> ReadS RestoreWindow
ReadS [RestoreWindow]
(Int -> ReadS RestoreWindow)
-> ReadS [RestoreWindow]
-> ReadPrec RestoreWindow
-> ReadPrec [RestoreWindow]
-> Read RestoreWindow
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreWindow]
$creadListPrec :: ReadPrec [RestoreWindow]
readPrec :: ReadPrec RestoreWindow
$creadPrec :: ReadPrec RestoreWindow
readList :: ReadS [RestoreWindow]
$creadList :: ReadS [RestoreWindow]
readsPrec :: Int -> ReadS RestoreWindow
$creadsPrec :: Int -> ReadS RestoreWindow
Prelude.Read, Int -> RestoreWindow -> ShowS
[RestoreWindow] -> ShowS
RestoreWindow -> String
(Int -> RestoreWindow -> ShowS)
-> (RestoreWindow -> String)
-> ([RestoreWindow] -> ShowS)
-> Show RestoreWindow
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreWindow] -> ShowS
$cshowList :: [RestoreWindow] -> ShowS
show :: RestoreWindow -> String
$cshow :: RestoreWindow -> String
showsPrec :: Int -> RestoreWindow -> ShowS
$cshowsPrec :: Int -> RestoreWindow -> ShowS
Prelude.Show, (forall x. RestoreWindow -> Rep RestoreWindow x)
-> (forall x. Rep RestoreWindow x -> RestoreWindow)
-> Generic RestoreWindow
forall x. Rep RestoreWindow x -> RestoreWindow
forall x. RestoreWindow -> Rep RestoreWindow x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreWindow x -> RestoreWindow
$cfrom :: forall x. RestoreWindow -> Rep RestoreWindow x
Prelude.Generic)

-- |
-- Create a value of 'RestoreWindow' 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:
--
-- 'latestTime', 'restoreWindow_latestTime' - The latest time you can restore an instance to.
--
-- 'earliestTime', 'restoreWindow_earliestTime' - The earliest time you can restore an instance to.
newRestoreWindow ::
  RestoreWindow
newRestoreWindow :: RestoreWindow
newRestoreWindow =
  RestoreWindow' :: Maybe ISO8601 -> Maybe ISO8601 -> RestoreWindow
RestoreWindow'
    { $sel:latestTime:RestoreWindow' :: Maybe ISO8601
latestTime = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:earliestTime:RestoreWindow' :: Maybe ISO8601
earliestTime = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | The latest time you can restore an instance to.
restoreWindow_latestTime :: Lens.Lens' RestoreWindow (Prelude.Maybe Prelude.UTCTime)
restoreWindow_latestTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RestoreWindow -> f RestoreWindow
restoreWindow_latestTime = (RestoreWindow -> Maybe ISO8601)
-> (RestoreWindow -> Maybe ISO8601 -> RestoreWindow)
-> Lens RestoreWindow RestoreWindow (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreWindow' {Maybe ISO8601
latestTime :: Maybe ISO8601
$sel:latestTime:RestoreWindow' :: RestoreWindow -> Maybe ISO8601
latestTime} -> Maybe ISO8601
latestTime) (\s :: RestoreWindow
s@RestoreWindow' {} Maybe ISO8601
a -> RestoreWindow
s {$sel:latestTime:RestoreWindow' :: Maybe ISO8601
latestTime = Maybe ISO8601
a} :: RestoreWindow) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> RestoreWindow -> f RestoreWindow)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RestoreWindow
-> f RestoreWindow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The earliest time you can restore an instance to.
restoreWindow_earliestTime :: Lens.Lens' RestoreWindow (Prelude.Maybe Prelude.UTCTime)
restoreWindow_earliestTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> RestoreWindow -> f RestoreWindow
restoreWindow_earliestTime = (RestoreWindow -> Maybe ISO8601)
-> (RestoreWindow -> Maybe ISO8601 -> RestoreWindow)
-> Lens RestoreWindow RestoreWindow (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreWindow' {Maybe ISO8601
earliestTime :: Maybe ISO8601
$sel:earliestTime:RestoreWindow' :: RestoreWindow -> Maybe ISO8601
earliestTime} -> Maybe ISO8601
earliestTime) (\s :: RestoreWindow
s@RestoreWindow' {} Maybe ISO8601
a -> RestoreWindow
s {$sel:earliestTime:RestoreWindow' :: Maybe ISO8601
earliestTime = Maybe ISO8601
a} :: RestoreWindow) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> RestoreWindow -> f RestoreWindow)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> RestoreWindow
-> f RestoreWindow
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (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 ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromXML RestoreWindow where
  parseXML :: [Node] -> Either String RestoreWindow
parseXML [Node]
x =
    Maybe ISO8601 -> Maybe ISO8601 -> RestoreWindow
RestoreWindow'
      (Maybe ISO8601 -> Maybe ISO8601 -> RestoreWindow)
-> Either String (Maybe ISO8601)
-> Either String (Maybe ISO8601 -> RestoreWindow)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LatestTime")
      Either String (Maybe ISO8601 -> RestoreWindow)
-> Either String (Maybe ISO8601) -> Either String RestoreWindow
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ISO8601)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"EarliestTime")

instance Prelude.Hashable RestoreWindow

instance Prelude.NFData RestoreWindow