{-# 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 #-}
module Amazonka.S3.Types.RoutingRule 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.Condition
import Amazonka.S3.Types.Redirect
data RoutingRule = RoutingRule'
{
RoutingRule -> Maybe Condition
condition :: Prelude.Maybe Condition,
RoutingRule -> Redirect
redirect :: Redirect
}
deriving (RoutingRule -> RoutingRule -> Bool
(RoutingRule -> RoutingRule -> Bool)
-> (RoutingRule -> RoutingRule -> Bool) -> Eq RoutingRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RoutingRule -> RoutingRule -> Bool
$c/= :: RoutingRule -> RoutingRule -> Bool
== :: RoutingRule -> RoutingRule -> Bool
$c== :: RoutingRule -> RoutingRule -> Bool
Prelude.Eq, ReadPrec [RoutingRule]
ReadPrec RoutingRule
Int -> ReadS RoutingRule
ReadS [RoutingRule]
(Int -> ReadS RoutingRule)
-> ReadS [RoutingRule]
-> ReadPrec RoutingRule
-> ReadPrec [RoutingRule]
-> Read RoutingRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RoutingRule]
$creadListPrec :: ReadPrec [RoutingRule]
readPrec :: ReadPrec RoutingRule
$creadPrec :: ReadPrec RoutingRule
readList :: ReadS [RoutingRule]
$creadList :: ReadS [RoutingRule]
readsPrec :: Int -> ReadS RoutingRule
$creadsPrec :: Int -> ReadS RoutingRule
Prelude.Read, Int -> RoutingRule -> ShowS
[RoutingRule] -> ShowS
RoutingRule -> String
(Int -> RoutingRule -> ShowS)
-> (RoutingRule -> String)
-> ([RoutingRule] -> ShowS)
-> Show RoutingRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RoutingRule] -> ShowS
$cshowList :: [RoutingRule] -> ShowS
show :: RoutingRule -> String
$cshow :: RoutingRule -> String
showsPrec :: Int -> RoutingRule -> ShowS
$cshowsPrec :: Int -> RoutingRule -> ShowS
Prelude.Show, (forall x. RoutingRule -> Rep RoutingRule x)
-> (forall x. Rep RoutingRule x -> RoutingRule)
-> Generic RoutingRule
forall x. Rep RoutingRule x -> RoutingRule
forall x. RoutingRule -> Rep RoutingRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RoutingRule x -> RoutingRule
$cfrom :: forall x. RoutingRule -> Rep RoutingRule x
Prelude.Generic)
newRoutingRule ::
Redirect ->
RoutingRule
newRoutingRule :: Redirect -> RoutingRule
newRoutingRule Redirect
pRedirect_ =
RoutingRule' :: Maybe Condition -> Redirect -> RoutingRule
RoutingRule'
{ $sel:condition:RoutingRule' :: Maybe Condition
condition = Maybe Condition
forall a. Maybe a
Prelude.Nothing,
$sel:redirect:RoutingRule' :: Redirect
redirect = Redirect
pRedirect_
}
routingRule_condition :: Lens.Lens' RoutingRule (Prelude.Maybe Condition)
routingRule_condition :: (Maybe Condition -> f (Maybe Condition))
-> RoutingRule -> f RoutingRule
routingRule_condition = (RoutingRule -> Maybe Condition)
-> (RoutingRule -> Maybe Condition -> RoutingRule)
-> Lens RoutingRule RoutingRule (Maybe Condition) (Maybe Condition)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoutingRule' {Maybe Condition
condition :: Maybe Condition
$sel:condition:RoutingRule' :: RoutingRule -> Maybe Condition
condition} -> Maybe Condition
condition) (\s :: RoutingRule
s@RoutingRule' {} Maybe Condition
a -> RoutingRule
s {$sel:condition:RoutingRule' :: Maybe Condition
condition = Maybe Condition
a} :: RoutingRule)
routingRule_redirect :: Lens.Lens' RoutingRule Redirect
routingRule_redirect :: (Redirect -> f Redirect) -> RoutingRule -> f RoutingRule
routingRule_redirect = (RoutingRule -> Redirect)
-> (RoutingRule -> Redirect -> RoutingRule)
-> Lens RoutingRule RoutingRule Redirect Redirect
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RoutingRule' {Redirect
redirect :: Redirect
$sel:redirect:RoutingRule' :: RoutingRule -> Redirect
redirect} -> Redirect
redirect) (\s :: RoutingRule
s@RoutingRule' {} Redirect
a -> RoutingRule
s {$sel:redirect:RoutingRule' :: Redirect
redirect = Redirect
a} :: RoutingRule)
instance Core.FromXML RoutingRule where
parseXML :: [Node] -> Either String RoutingRule
parseXML [Node]
x =
Maybe Condition -> Redirect -> RoutingRule
RoutingRule'
(Maybe Condition -> Redirect -> RoutingRule)
-> Either String (Maybe Condition)
-> Either String (Redirect -> RoutingRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Condition)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Condition")
Either String (Redirect -> RoutingRule)
-> Either String Redirect -> Either String RoutingRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Redirect
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Redirect")
instance Prelude.Hashable RoutingRule
instance Prelude.NFData RoutingRule
instance Core.ToXML RoutingRule where
toXML :: RoutingRule -> XML
toXML RoutingRule' {Maybe Condition
Redirect
redirect :: Redirect
condition :: Maybe Condition
$sel:redirect:RoutingRule' :: RoutingRule -> Redirect
$sel:condition:RoutingRule' :: RoutingRule -> Maybe Condition
..} =
[XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ Name
"Condition" Name -> Maybe Condition -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Condition
condition,
Name
"Redirect" Name -> Redirect -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Redirect
redirect
]