{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RDS.Types.RestoreWindow where

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

-- | Earliest and latest time an instance can be restored to:
--
-- /See:/ 'newRestoreWindow' smart constructor.
data RestoreWindow = RestoreWindow'
  { -- | The earliest time you can restore an instance to.
    RestoreWindow -> Maybe ISO8601
earliestTime :: Prelude.Maybe Data.ISO8601,
    -- | The latest time you can restore an instance to.
    RestoreWindow -> Maybe ISO8601
latestTime :: Prelude.Maybe Data.ISO8601
  }
  deriving (RestoreWindow -> RestoreWindow -> Bool
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]
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
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. 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:
--
-- 'earliestTime', 'restoreWindow_earliestTime' - The earliest time you can restore an instance to.
--
-- 'latestTime', 'restoreWindow_latestTime' - The latest time you can restore an instance to.
newRestoreWindow ::
  RestoreWindow
newRestoreWindow :: RestoreWindow
newRestoreWindow =
  RestoreWindow'
    { $sel:earliestTime:RestoreWindow' :: Maybe ISO8601
earliestTime = forall a. Maybe a
Prelude.Nothing,
      $sel:latestTime:RestoreWindow' :: Maybe ISO8601
latestTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The earliest time you can restore an instance to.
restoreWindow_earliestTime :: Lens.Lens' RestoreWindow (Prelude.Maybe Prelude.UTCTime)
restoreWindow_earliestTime :: Lens' RestoreWindow (Maybe UTCTime)
restoreWindow_earliestTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The latest time you can restore an instance to.
restoreWindow_latestTime :: Lens.Lens' RestoreWindow (Prelude.Maybe Prelude.UTCTime)
restoreWindow_latestTime :: Lens' RestoreWindow (Maybe UTCTime)
restoreWindow_latestTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.Hashable RestoreWindow where
  hashWithSalt :: Int -> RestoreWindow -> Int
hashWithSalt Int
_salt RestoreWindow' {Maybe ISO8601
latestTime :: Maybe ISO8601
earliestTime :: Maybe ISO8601
$sel:latestTime:RestoreWindow' :: RestoreWindow -> Maybe ISO8601
$sel:earliestTime:RestoreWindow' :: RestoreWindow -> Maybe ISO8601
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
earliestTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
latestTime

instance Prelude.NFData RestoreWindow where
  rnf :: RestoreWindow -> ()
rnf RestoreWindow' {Maybe ISO8601
latestTime :: Maybe ISO8601
earliestTime :: Maybe ISO8601
$sel:latestTime:RestoreWindow' :: RestoreWindow -> Maybe ISO8601
$sel:earliestTime:RestoreWindow' :: RestoreWindow -> Maybe ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
earliestTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
latestTime