{-# 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.ReplicationRule
-- 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.ReplicationRule 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.DeleteMarkerReplication
import Amazonka.S3.Types.Destination
import Amazonka.S3.Types.ExistingObjectReplication
import Amazonka.S3.Types.ReplicationRuleFilter
import Amazonka.S3.Types.ReplicationRuleStatus
import Amazonka.S3.Types.SourceSelectionCriteria

-- | Specifies which Amazon S3 objects to replicate and where to store the
-- replicas.
--
-- /See:/ 'newReplicationRule' smart constructor.
data ReplicationRule = ReplicationRule'
  { ReplicationRule -> Maybe DeleteMarkerReplication
deleteMarkerReplication :: Prelude.Maybe DeleteMarkerReplication,
    -- | The priority indicates which rule has precedence whenever two or more
    -- replication rules conflict. Amazon S3 will attempt to replicate objects
    -- according to all replication rules. However, if there are two or more
    -- rules with the same destination bucket, then objects will be replicated
    -- according to the rule with the highest priority. The higher the number,
    -- the higher the priority.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/replication.html Replication>
    -- in the /Amazon S3 User Guide/.
    ReplicationRule -> Maybe Int
priority :: Prelude.Maybe Prelude.Int,
    -- | An object key name prefix that identifies the object or objects to which
    -- the rule applies. The maximum prefix length is 1,024 characters. To
    -- include all objects in a bucket, specify an empty string.
    --
    -- Replacement must be made for object keys containing special characters
    -- (such as carriage returns) when using XML requests. For more
    -- information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html#object-key-xml-related-constraints XML related object key constraints>.
    ReplicationRule -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    ReplicationRule -> Maybe ExistingObjectReplication
existingObjectReplication :: Prelude.Maybe ExistingObjectReplication,
    -- | A unique identifier for the rule. The maximum value is 255 characters.
    ReplicationRule -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    ReplicationRule -> Maybe ReplicationRuleFilter
filter' :: Prelude.Maybe ReplicationRuleFilter,
    -- | A container that describes additional filters for identifying the source
    -- objects that you want to replicate. You can choose to enable or disable
    -- the replication of these objects. Currently, Amazon S3 supports only the
    -- filter that you can specify for objects created with server-side
    -- encryption using a customer managed key stored in Amazon Web Services
    -- Key Management Service (SSE-KMS).
    ReplicationRule -> Maybe SourceSelectionCriteria
sourceSelectionCriteria :: Prelude.Maybe SourceSelectionCriteria,
    -- | Specifies whether the rule is enabled.
    ReplicationRule -> ReplicationRuleStatus
status :: ReplicationRuleStatus,
    -- | A container for information about the replication destination and its
    -- configurations including enabling the S3 Replication Time Control (S3
    -- RTC).
    ReplicationRule -> Destination
destination :: Destination
  }
  deriving (ReplicationRule -> ReplicationRule -> Bool
(ReplicationRule -> ReplicationRule -> Bool)
-> (ReplicationRule -> ReplicationRule -> Bool)
-> Eq ReplicationRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReplicationRule -> ReplicationRule -> Bool
$c/= :: ReplicationRule -> ReplicationRule -> Bool
== :: ReplicationRule -> ReplicationRule -> Bool
$c== :: ReplicationRule -> ReplicationRule -> Bool
Prelude.Eq, ReadPrec [ReplicationRule]
ReadPrec ReplicationRule
Int -> ReadS ReplicationRule
ReadS [ReplicationRule]
(Int -> ReadS ReplicationRule)
-> ReadS [ReplicationRule]
-> ReadPrec ReplicationRule
-> ReadPrec [ReplicationRule]
-> Read ReplicationRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReplicationRule]
$creadListPrec :: ReadPrec [ReplicationRule]
readPrec :: ReadPrec ReplicationRule
$creadPrec :: ReadPrec ReplicationRule
readList :: ReadS [ReplicationRule]
$creadList :: ReadS [ReplicationRule]
readsPrec :: Int -> ReadS ReplicationRule
$creadsPrec :: Int -> ReadS ReplicationRule
Prelude.Read, Int -> ReplicationRule -> ShowS
[ReplicationRule] -> ShowS
ReplicationRule -> String
(Int -> ReplicationRule -> ShowS)
-> (ReplicationRule -> String)
-> ([ReplicationRule] -> ShowS)
-> Show ReplicationRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReplicationRule] -> ShowS
$cshowList :: [ReplicationRule] -> ShowS
show :: ReplicationRule -> String
$cshow :: ReplicationRule -> String
showsPrec :: Int -> ReplicationRule -> ShowS
$cshowsPrec :: Int -> ReplicationRule -> ShowS
Prelude.Show, (forall x. ReplicationRule -> Rep ReplicationRule x)
-> (forall x. Rep ReplicationRule x -> ReplicationRule)
-> Generic ReplicationRule
forall x. Rep ReplicationRule x -> ReplicationRule
forall x. ReplicationRule -> Rep ReplicationRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReplicationRule x -> ReplicationRule
$cfrom :: forall x. ReplicationRule -> Rep ReplicationRule x
Prelude.Generic)

-- |
-- Create a value of 'ReplicationRule' 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:
--
-- 'deleteMarkerReplication', 'replicationRule_deleteMarkerReplication' - Undocumented member.
--
-- 'priority', 'replicationRule_priority' - The priority indicates which rule has precedence whenever two or more
-- replication rules conflict. Amazon S3 will attempt to replicate objects
-- according to all replication rules. However, if there are two or more
-- rules with the same destination bucket, then objects will be replicated
-- according to the rule with the highest priority. The higher the number,
-- the higher the priority.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/replication.html Replication>
-- in the /Amazon S3 User Guide/.
--
-- 'prefix', 'replicationRule_prefix' - An object key name prefix that identifies the object or objects to which
-- the rule applies. The maximum prefix length is 1,024 characters. To
-- include all objects in a bucket, specify an empty string.
--
-- Replacement must be made for object keys containing special characters
-- (such as carriage returns) when using XML requests. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html#object-key-xml-related-constraints XML related object key constraints>.
--
-- 'existingObjectReplication', 'replicationRule_existingObjectReplication' -
--
-- 'id', 'replicationRule_id' - A unique identifier for the rule. The maximum value is 255 characters.
--
-- 'filter'', 'replicationRule_filter' - Undocumented member.
--
-- 'sourceSelectionCriteria', 'replicationRule_sourceSelectionCriteria' - A container that describes additional filters for identifying the source
-- objects that you want to replicate. You can choose to enable or disable
-- the replication of these objects. Currently, Amazon S3 supports only the
-- filter that you can specify for objects created with server-side
-- encryption using a customer managed key stored in Amazon Web Services
-- Key Management Service (SSE-KMS).
--
-- 'status', 'replicationRule_status' - Specifies whether the rule is enabled.
--
-- 'destination', 'replicationRule_destination' - A container for information about the replication destination and its
-- configurations including enabling the S3 Replication Time Control (S3
-- RTC).
newReplicationRule ::
  -- | 'status'
  ReplicationRuleStatus ->
  -- | 'destination'
  Destination ->
  ReplicationRule
newReplicationRule :: ReplicationRuleStatus -> Destination -> ReplicationRule
newReplicationRule ReplicationRuleStatus
pStatus_ Destination
pDestination_ =
  ReplicationRule' :: Maybe DeleteMarkerReplication
-> Maybe Int
-> Maybe Text
-> Maybe ExistingObjectReplication
-> Maybe Text
-> Maybe ReplicationRuleFilter
-> Maybe SourceSelectionCriteria
-> ReplicationRuleStatus
-> Destination
-> ReplicationRule
ReplicationRule'
    { $sel:deleteMarkerReplication:ReplicationRule' :: Maybe DeleteMarkerReplication
deleteMarkerReplication =
        Maybe DeleteMarkerReplication
forall a. Maybe a
Prelude.Nothing,
      $sel:priority:ReplicationRule' :: Maybe Int
priority = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:ReplicationRule' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:existingObjectReplication:ReplicationRule' :: Maybe ExistingObjectReplication
existingObjectReplication = Maybe ExistingObjectReplication
forall a. Maybe a
Prelude.Nothing,
      $sel:id:ReplicationRule' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':ReplicationRule' :: Maybe ReplicationRuleFilter
filter' = Maybe ReplicationRuleFilter
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceSelectionCriteria:ReplicationRule' :: Maybe SourceSelectionCriteria
sourceSelectionCriteria = Maybe SourceSelectionCriteria
forall a. Maybe a
Prelude.Nothing,
      $sel:status:ReplicationRule' :: ReplicationRuleStatus
status = ReplicationRuleStatus
pStatus_,
      $sel:destination:ReplicationRule' :: Destination
destination = Destination
pDestination_
    }

-- | Undocumented member.
replicationRule_deleteMarkerReplication :: Lens.Lens' ReplicationRule (Prelude.Maybe DeleteMarkerReplication)
replicationRule_deleteMarkerReplication :: (Maybe DeleteMarkerReplication
 -> f (Maybe DeleteMarkerReplication))
-> ReplicationRule -> f ReplicationRule
replicationRule_deleteMarkerReplication = (ReplicationRule -> Maybe DeleteMarkerReplication)
-> (ReplicationRule
    -> Maybe DeleteMarkerReplication -> ReplicationRule)
-> Lens
     ReplicationRule
     ReplicationRule
     (Maybe DeleteMarkerReplication)
     (Maybe DeleteMarkerReplication)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Maybe DeleteMarkerReplication
deleteMarkerReplication :: Maybe DeleteMarkerReplication
$sel:deleteMarkerReplication:ReplicationRule' :: ReplicationRule -> Maybe DeleteMarkerReplication
deleteMarkerReplication} -> Maybe DeleteMarkerReplication
deleteMarkerReplication) (\s :: ReplicationRule
s@ReplicationRule' {} Maybe DeleteMarkerReplication
a -> ReplicationRule
s {$sel:deleteMarkerReplication:ReplicationRule' :: Maybe DeleteMarkerReplication
deleteMarkerReplication = Maybe DeleteMarkerReplication
a} :: ReplicationRule)

-- | The priority indicates which rule has precedence whenever two or more
-- replication rules conflict. Amazon S3 will attempt to replicate objects
-- according to all replication rules. However, if there are two or more
-- rules with the same destination bucket, then objects will be replicated
-- according to the rule with the highest priority. The higher the number,
-- the higher the priority.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/replication.html Replication>
-- in the /Amazon S3 User Guide/.
replicationRule_priority :: Lens.Lens' ReplicationRule (Prelude.Maybe Prelude.Int)
replicationRule_priority :: (Maybe Int -> f (Maybe Int))
-> ReplicationRule -> f ReplicationRule
replicationRule_priority = (ReplicationRule -> Maybe Int)
-> (ReplicationRule -> Maybe Int -> ReplicationRule)
-> Lens ReplicationRule ReplicationRule (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Maybe Int
priority :: Maybe Int
$sel:priority:ReplicationRule' :: ReplicationRule -> Maybe Int
priority} -> Maybe Int
priority) (\s :: ReplicationRule
s@ReplicationRule' {} Maybe Int
a -> ReplicationRule
s {$sel:priority:ReplicationRule' :: Maybe Int
priority = Maybe Int
a} :: ReplicationRule)

-- | An object key name prefix that identifies the object or objects to which
-- the rule applies. The maximum prefix length is 1,024 characters. To
-- include all objects in a bucket, specify an empty string.
--
-- Replacement must be made for object keys containing special characters
-- (such as carriage returns) when using XML requests. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html#object-key-xml-related-constraints XML related object key constraints>.
replicationRule_prefix :: Lens.Lens' ReplicationRule (Prelude.Maybe Prelude.Text)
replicationRule_prefix :: (Maybe Text -> f (Maybe Text))
-> ReplicationRule -> f ReplicationRule
replicationRule_prefix = (ReplicationRule -> Maybe Text)
-> (ReplicationRule -> Maybe Text -> ReplicationRule)
-> Lens ReplicationRule ReplicationRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Maybe Text
prefix :: Maybe Text
$sel:prefix:ReplicationRule' :: ReplicationRule -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: ReplicationRule
s@ReplicationRule' {} Maybe Text
a -> ReplicationRule
s {$sel:prefix:ReplicationRule' :: Maybe Text
prefix = Maybe Text
a} :: ReplicationRule)

-- |
replicationRule_existingObjectReplication :: Lens.Lens' ReplicationRule (Prelude.Maybe ExistingObjectReplication)
replicationRule_existingObjectReplication :: (Maybe ExistingObjectReplication
 -> f (Maybe ExistingObjectReplication))
-> ReplicationRule -> f ReplicationRule
replicationRule_existingObjectReplication = (ReplicationRule -> Maybe ExistingObjectReplication)
-> (ReplicationRule
    -> Maybe ExistingObjectReplication -> ReplicationRule)
-> Lens
     ReplicationRule
     ReplicationRule
     (Maybe ExistingObjectReplication)
     (Maybe ExistingObjectReplication)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Maybe ExistingObjectReplication
existingObjectReplication :: Maybe ExistingObjectReplication
$sel:existingObjectReplication:ReplicationRule' :: ReplicationRule -> Maybe ExistingObjectReplication
existingObjectReplication} -> Maybe ExistingObjectReplication
existingObjectReplication) (\s :: ReplicationRule
s@ReplicationRule' {} Maybe ExistingObjectReplication
a -> ReplicationRule
s {$sel:existingObjectReplication:ReplicationRule' :: Maybe ExistingObjectReplication
existingObjectReplication = Maybe ExistingObjectReplication
a} :: ReplicationRule)

-- | A unique identifier for the rule. The maximum value is 255 characters.
replicationRule_id :: Lens.Lens' ReplicationRule (Prelude.Maybe Prelude.Text)
replicationRule_id :: (Maybe Text -> f (Maybe Text))
-> ReplicationRule -> f ReplicationRule
replicationRule_id = (ReplicationRule -> Maybe Text)
-> (ReplicationRule -> Maybe Text -> ReplicationRule)
-> Lens ReplicationRule ReplicationRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Maybe Text
id :: Maybe Text
$sel:id:ReplicationRule' :: ReplicationRule -> Maybe Text
id} -> Maybe Text
id) (\s :: ReplicationRule
s@ReplicationRule' {} Maybe Text
a -> ReplicationRule
s {$sel:id:ReplicationRule' :: Maybe Text
id = Maybe Text
a} :: ReplicationRule)

-- | Undocumented member.
replicationRule_filter :: Lens.Lens' ReplicationRule (Prelude.Maybe ReplicationRuleFilter)
replicationRule_filter :: (Maybe ReplicationRuleFilter -> f (Maybe ReplicationRuleFilter))
-> ReplicationRule -> f ReplicationRule
replicationRule_filter = (ReplicationRule -> Maybe ReplicationRuleFilter)
-> (ReplicationRule
    -> Maybe ReplicationRuleFilter -> ReplicationRule)
-> Lens
     ReplicationRule
     ReplicationRule
     (Maybe ReplicationRuleFilter)
     (Maybe ReplicationRuleFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Maybe ReplicationRuleFilter
filter' :: Maybe ReplicationRuleFilter
$sel:filter':ReplicationRule' :: ReplicationRule -> Maybe ReplicationRuleFilter
filter'} -> Maybe ReplicationRuleFilter
filter') (\s :: ReplicationRule
s@ReplicationRule' {} Maybe ReplicationRuleFilter
a -> ReplicationRule
s {$sel:filter':ReplicationRule' :: Maybe ReplicationRuleFilter
filter' = Maybe ReplicationRuleFilter
a} :: ReplicationRule)

-- | A container that describes additional filters for identifying the source
-- objects that you want to replicate. You can choose to enable or disable
-- the replication of these objects. Currently, Amazon S3 supports only the
-- filter that you can specify for objects created with server-side
-- encryption using a customer managed key stored in Amazon Web Services
-- Key Management Service (SSE-KMS).
replicationRule_sourceSelectionCriteria :: Lens.Lens' ReplicationRule (Prelude.Maybe SourceSelectionCriteria)
replicationRule_sourceSelectionCriteria :: (Maybe SourceSelectionCriteria
 -> f (Maybe SourceSelectionCriteria))
-> ReplicationRule -> f ReplicationRule
replicationRule_sourceSelectionCriteria = (ReplicationRule -> Maybe SourceSelectionCriteria)
-> (ReplicationRule
    -> Maybe SourceSelectionCriteria -> ReplicationRule)
-> Lens
     ReplicationRule
     ReplicationRule
     (Maybe SourceSelectionCriteria)
     (Maybe SourceSelectionCriteria)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Maybe SourceSelectionCriteria
sourceSelectionCriteria :: Maybe SourceSelectionCriteria
$sel:sourceSelectionCriteria:ReplicationRule' :: ReplicationRule -> Maybe SourceSelectionCriteria
sourceSelectionCriteria} -> Maybe SourceSelectionCriteria
sourceSelectionCriteria) (\s :: ReplicationRule
s@ReplicationRule' {} Maybe SourceSelectionCriteria
a -> ReplicationRule
s {$sel:sourceSelectionCriteria:ReplicationRule' :: Maybe SourceSelectionCriteria
sourceSelectionCriteria = Maybe SourceSelectionCriteria
a} :: ReplicationRule)

-- | Specifies whether the rule is enabled.
replicationRule_status :: Lens.Lens' ReplicationRule ReplicationRuleStatus
replicationRule_status :: (ReplicationRuleStatus -> f ReplicationRuleStatus)
-> ReplicationRule -> f ReplicationRule
replicationRule_status = (ReplicationRule -> ReplicationRuleStatus)
-> (ReplicationRule -> ReplicationRuleStatus -> ReplicationRule)
-> Lens
     ReplicationRule
     ReplicationRule
     ReplicationRuleStatus
     ReplicationRuleStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {ReplicationRuleStatus
status :: ReplicationRuleStatus
$sel:status:ReplicationRule' :: ReplicationRule -> ReplicationRuleStatus
status} -> ReplicationRuleStatus
status) (\s :: ReplicationRule
s@ReplicationRule' {} ReplicationRuleStatus
a -> ReplicationRule
s {$sel:status:ReplicationRule' :: ReplicationRuleStatus
status = ReplicationRuleStatus
a} :: ReplicationRule)

-- | A container for information about the replication destination and its
-- configurations including enabling the S3 Replication Time Control (S3
-- RTC).
replicationRule_destination :: Lens.Lens' ReplicationRule Destination
replicationRule_destination :: (Destination -> f Destination)
-> ReplicationRule -> f ReplicationRule
replicationRule_destination = (ReplicationRule -> Destination)
-> (ReplicationRule -> Destination -> ReplicationRule)
-> Lens ReplicationRule ReplicationRule Destination Destination
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReplicationRule' {Destination
destination :: Destination
$sel:destination:ReplicationRule' :: ReplicationRule -> Destination
destination} -> Destination
destination) (\s :: ReplicationRule
s@ReplicationRule' {} Destination
a -> ReplicationRule
s {$sel:destination:ReplicationRule' :: Destination
destination = Destination
a} :: ReplicationRule)

instance Core.FromXML ReplicationRule where
  parseXML :: [Node] -> Either String ReplicationRule
parseXML [Node]
x =
    Maybe DeleteMarkerReplication
-> Maybe Int
-> Maybe Text
-> Maybe ExistingObjectReplication
-> Maybe Text
-> Maybe ReplicationRuleFilter
-> Maybe SourceSelectionCriteria
-> ReplicationRuleStatus
-> Destination
-> ReplicationRule
ReplicationRule'
      (Maybe DeleteMarkerReplication
 -> Maybe Int
 -> Maybe Text
 -> Maybe ExistingObjectReplication
 -> Maybe Text
 -> Maybe ReplicationRuleFilter
 -> Maybe SourceSelectionCriteria
 -> ReplicationRuleStatus
 -> Destination
 -> ReplicationRule)
-> Either String (Maybe DeleteMarkerReplication)
-> Either
     String
     (Maybe Int
      -> Maybe Text
      -> Maybe ExistingObjectReplication
      -> Maybe Text
      -> Maybe ReplicationRuleFilter
      -> Maybe SourceSelectionCriteria
      -> ReplicationRuleStatus
      -> Destination
      -> ReplicationRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe DeleteMarkerReplication)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DeleteMarkerReplication")
      Either
  String
  (Maybe Int
   -> Maybe Text
   -> Maybe ExistingObjectReplication
   -> Maybe Text
   -> Maybe ReplicationRuleFilter
   -> Maybe SourceSelectionCriteria
   -> ReplicationRuleStatus
   -> Destination
   -> ReplicationRule)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Text
      -> Maybe ExistingObjectReplication
      -> Maybe Text
      -> Maybe ReplicationRuleFilter
      -> Maybe SourceSelectionCriteria
      -> ReplicationRuleStatus
      -> Destination
      -> ReplicationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Priority")
      Either
  String
  (Maybe Text
   -> Maybe ExistingObjectReplication
   -> Maybe Text
   -> Maybe ReplicationRuleFilter
   -> Maybe SourceSelectionCriteria
   -> ReplicationRuleStatus
   -> Destination
   -> ReplicationRule)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe ExistingObjectReplication
      -> Maybe Text
      -> Maybe ReplicationRuleFilter
      -> Maybe SourceSelectionCriteria
      -> ReplicationRuleStatus
      -> Destination
      -> ReplicationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Prefix")
      Either
  String
  (Maybe ExistingObjectReplication
   -> Maybe Text
   -> Maybe ReplicationRuleFilter
   -> Maybe SourceSelectionCriteria
   -> ReplicationRuleStatus
   -> Destination
   -> ReplicationRule)
-> Either String (Maybe ExistingObjectReplication)
-> Either
     String
     (Maybe Text
      -> Maybe ReplicationRuleFilter
      -> Maybe SourceSelectionCriteria
      -> ReplicationRuleStatus
      -> Destination
      -> ReplicationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ExistingObjectReplication)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ExistingObjectReplication")
      Either
  String
  (Maybe Text
   -> Maybe ReplicationRuleFilter
   -> Maybe SourceSelectionCriteria
   -> ReplicationRuleStatus
   -> Destination
   -> ReplicationRule)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe ReplicationRuleFilter
      -> Maybe SourceSelectionCriteria
      -> ReplicationRuleStatus
      -> Destination
      -> ReplicationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ID")
      Either
  String
  (Maybe ReplicationRuleFilter
   -> Maybe SourceSelectionCriteria
   -> ReplicationRuleStatus
   -> Destination
   -> ReplicationRule)
-> Either String (Maybe ReplicationRuleFilter)
-> Either
     String
     (Maybe SourceSelectionCriteria
      -> ReplicationRuleStatus -> Destination -> ReplicationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ReplicationRuleFilter)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Filter")
      Either
  String
  (Maybe SourceSelectionCriteria
   -> ReplicationRuleStatus -> Destination -> ReplicationRule)
-> Either String (Maybe SourceSelectionCriteria)
-> Either
     String (ReplicationRuleStatus -> Destination -> ReplicationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe SourceSelectionCriteria)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourceSelectionCriteria")
      Either
  String (ReplicationRuleStatus -> Destination -> ReplicationRule)
-> Either String ReplicationRuleStatus
-> Either String (Destination -> ReplicationRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ReplicationRuleStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Status")
      Either String (Destination -> ReplicationRule)
-> Either String Destination -> Either String ReplicationRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Destination
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Destination")

instance Prelude.Hashable ReplicationRule

instance Prelude.NFData ReplicationRule

instance Core.ToXML ReplicationRule where
  toXML :: ReplicationRule -> XML
toXML ReplicationRule' {Maybe Int
Maybe Text
Maybe DeleteMarkerReplication
Maybe ExistingObjectReplication
Maybe SourceSelectionCriteria
Maybe ReplicationRuleFilter
ReplicationRuleStatus
Destination
destination :: Destination
status :: ReplicationRuleStatus
sourceSelectionCriteria :: Maybe SourceSelectionCriteria
filter' :: Maybe ReplicationRuleFilter
id :: Maybe Text
existingObjectReplication :: Maybe ExistingObjectReplication
prefix :: Maybe Text
priority :: Maybe Int
deleteMarkerReplication :: Maybe DeleteMarkerReplication
$sel:destination:ReplicationRule' :: ReplicationRule -> Destination
$sel:status:ReplicationRule' :: ReplicationRule -> ReplicationRuleStatus
$sel:sourceSelectionCriteria:ReplicationRule' :: ReplicationRule -> Maybe SourceSelectionCriteria
$sel:filter':ReplicationRule' :: ReplicationRule -> Maybe ReplicationRuleFilter
$sel:id:ReplicationRule' :: ReplicationRule -> Maybe Text
$sel:existingObjectReplication:ReplicationRule' :: ReplicationRule -> Maybe ExistingObjectReplication
$sel:prefix:ReplicationRule' :: ReplicationRule -> Maybe Text
$sel:priority:ReplicationRule' :: ReplicationRule -> Maybe Int
$sel:deleteMarkerReplication:ReplicationRule' :: ReplicationRule -> Maybe DeleteMarkerReplication
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"DeleteMarkerReplication"
          Name -> Maybe DeleteMarkerReplication -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe DeleteMarkerReplication
deleteMarkerReplication,
        Name
"Priority" Name -> Maybe Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Int
priority,
        Name
"Prefix" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
prefix,
        Name
"ExistingObjectReplication"
          Name -> Maybe ExistingObjectReplication -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe ExistingObjectReplication
existingObjectReplication,
        Name
"ID" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
id,
        Name
"Filter" Name -> Maybe ReplicationRuleFilter -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe ReplicationRuleFilter
filter',
        Name
"SourceSelectionCriteria"
          Name -> Maybe SourceSelectionCriteria -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe SourceSelectionCriteria
sourceSelectionCriteria,
        Name
"Status" Name -> ReplicationRuleStatus -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= ReplicationRuleStatus
status,
        Name
"Destination" Name -> Destination -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Destination
destination
      ]