{-# 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.S3.Types.ReplicationTime
-- 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.S3.Types.ReplicationTime where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.ReplicationTimeStatus
import Amazonka.S3.Types.ReplicationTimeValue

-- | A container specifying S3 Replication Time Control (S3 RTC) related
-- information, including whether S3 RTC is enabled and the time when all
-- objects and operations on objects must be replicated. Must be specified
-- together with a @Metrics@ block.
--
-- /See:/ 'newReplicationTime' smart constructor.
data ReplicationTime = ReplicationTime'
  { -- | Specifies whether the replication time is enabled.
    ReplicationTime -> ReplicationTimeStatus
status :: ReplicationTimeStatus,
    -- | A container specifying the time by which replication should be complete
    -- for all objects and operations on objects.
    ReplicationTime -> ReplicationTimeValue
time :: ReplicationTimeValue
  }
  deriving (ReplicationTime -> ReplicationTime -> Bool
(ReplicationTime -> ReplicationTime -> Bool)
-> (ReplicationTime -> ReplicationTime -> Bool)
-> Eq ReplicationTime
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplicationTime -> ReplicationTime -> Bool
$c/= :: ReplicationTime -> ReplicationTime -> Bool
== :: ReplicationTime -> ReplicationTime -> Bool
$c== :: ReplicationTime -> ReplicationTime -> Bool
Prelude.Eq, ReadPrec [ReplicationTime]
ReadPrec ReplicationTime
Int -> ReadS ReplicationTime
ReadS [ReplicationTime]
(Int -> ReadS ReplicationTime)
-> ReadS [ReplicationTime]
-> ReadPrec ReplicationTime
-> ReadPrec [ReplicationTime]
-> Read ReplicationTime
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplicationTime]
$creadListPrec :: ReadPrec [ReplicationTime]
readPrec :: ReadPrec ReplicationTime
$creadPrec :: ReadPrec ReplicationTime
readList :: ReadS [ReplicationTime]
$creadList :: ReadS [ReplicationTime]
readsPrec :: Int -> ReadS ReplicationTime
$creadsPrec :: Int -> ReadS ReplicationTime
Prelude.Read, Int -> ReplicationTime -> ShowS
[ReplicationTime] -> ShowS
ReplicationTime -> String
(Int -> ReplicationTime -> ShowS)
-> (ReplicationTime -> String)
-> ([ReplicationTime] -> ShowS)
-> Show ReplicationTime
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplicationTime] -> ShowS
$cshowList :: [ReplicationTime] -> ShowS
show :: ReplicationTime -> String
$cshow :: ReplicationTime -> String
showsPrec :: Int -> ReplicationTime -> ShowS
$cshowsPrec :: Int -> ReplicationTime -> ShowS
Prelude.Show, (forall x. ReplicationTime -> Rep ReplicationTime x)
-> (forall x. Rep ReplicationTime x -> ReplicationTime)
-> Generic ReplicationTime
forall x. Rep ReplicationTime x -> ReplicationTime
forall x. ReplicationTime -> Rep ReplicationTime x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplicationTime x -> ReplicationTime
$cfrom :: forall x. ReplicationTime -> Rep ReplicationTime x
Prelude.Generic)

-- |
-- Create a value of 'ReplicationTime' 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:
--
-- 'status', 'replicationTime_status' - Specifies whether the replication time is enabled.
--
-- 'time', 'replicationTime_time' - A container specifying the time by which replication should be complete
-- for all objects and operations on objects.
newReplicationTime ::
  -- | 'status'
  ReplicationTimeStatus ->
  -- | 'time'
  ReplicationTimeValue ->
  ReplicationTime
newReplicationTime :: ReplicationTimeStatus -> ReplicationTimeValue -> ReplicationTime
newReplicationTime ReplicationTimeStatus
pStatus_ ReplicationTimeValue
pTime_ =
  ReplicationTime' :: ReplicationTimeStatus -> ReplicationTimeValue -> ReplicationTime
ReplicationTime' {$sel:status:ReplicationTime' :: ReplicationTimeStatus
status = ReplicationTimeStatus
pStatus_, $sel:time:ReplicationTime' :: ReplicationTimeValue
time = ReplicationTimeValue
pTime_}

-- | Specifies whether the replication time is enabled.
replicationTime_status :: Lens.Lens' ReplicationTime ReplicationTimeStatus
replicationTime_status :: (ReplicationTimeStatus -> f ReplicationTimeStatus)
-> ReplicationTime -> f ReplicationTime
replicationTime_status = (ReplicationTime -> ReplicationTimeStatus)
-> (ReplicationTime -> ReplicationTimeStatus -> ReplicationTime)
-> Lens
     ReplicationTime
     ReplicationTime
     ReplicationTimeStatus
     ReplicationTimeStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationTime' {ReplicationTimeStatus
status :: ReplicationTimeStatus
$sel:status:ReplicationTime' :: ReplicationTime -> ReplicationTimeStatus
status} -> ReplicationTimeStatus
status) (\s :: ReplicationTime
s@ReplicationTime' {} ReplicationTimeStatus
a -> ReplicationTime
s {$sel:status:ReplicationTime' :: ReplicationTimeStatus
status = ReplicationTimeStatus
a} :: ReplicationTime)

-- | A container specifying the time by which replication should be complete
-- for all objects and operations on objects.
replicationTime_time :: Lens.Lens' ReplicationTime ReplicationTimeValue
replicationTime_time :: (ReplicationTimeValue -> f ReplicationTimeValue)
-> ReplicationTime -> f ReplicationTime
replicationTime_time = (ReplicationTime -> ReplicationTimeValue)
-> (ReplicationTime -> ReplicationTimeValue -> ReplicationTime)
-> Lens
     ReplicationTime
     ReplicationTime
     ReplicationTimeValue
     ReplicationTimeValue
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationTime' {ReplicationTimeValue
time :: ReplicationTimeValue
$sel:time:ReplicationTime' :: ReplicationTime -> ReplicationTimeValue
time} -> ReplicationTimeValue
time) (\s :: ReplicationTime
s@ReplicationTime' {} ReplicationTimeValue
a -> ReplicationTime
s {$sel:time:ReplicationTime' :: ReplicationTimeValue
time = ReplicationTimeValue
a} :: ReplicationTime)

instance Core.FromXML ReplicationTime where
  parseXML :: [Node] -> Either String ReplicationTime
parseXML [Node]
x =
    ReplicationTimeStatus -> ReplicationTimeValue -> ReplicationTime
ReplicationTime'
      (ReplicationTimeStatus -> ReplicationTimeValue -> ReplicationTime)
-> Either String ReplicationTimeStatus
-> Either String (ReplicationTimeValue -> ReplicationTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String ReplicationTimeStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Status") Either String (ReplicationTimeValue -> ReplicationTime)
-> Either String ReplicationTimeValue
-> Either String ReplicationTime
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ReplicationTimeValue
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Time")

instance Prelude.Hashable ReplicationTime

instance Prelude.NFData ReplicationTime

instance Core.ToXML ReplicationTime where
  toXML :: ReplicationTime -> XML
toXML ReplicationTime' {ReplicationTimeStatus
ReplicationTimeValue
time :: ReplicationTimeValue
status :: ReplicationTimeStatus
$sel:time:ReplicationTime' :: ReplicationTime -> ReplicationTimeValue
$sel:status:ReplicationTime' :: ReplicationTime -> ReplicationTimeStatus
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"Status" Name -> ReplicationTimeStatus -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= ReplicationTimeStatus
status, Name
"Time" Name -> ReplicationTimeValue -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= ReplicationTimeValue
time]