{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.ELBV2.CreateRule
(
CreateRule (..),
newCreateRule,
createRule_tags,
createRule_listenerArn,
createRule_conditions,
createRule_priority,
createRule_actions,
CreateRuleResponse (..),
newCreateRuleResponse,
createRuleResponse_rules,
createRuleResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ELBV2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateRule = CreateRule'
{
CreateRule -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
CreateRule -> Text
listenerArn :: Prelude.Text,
CreateRule -> [RuleCondition]
conditions :: [RuleCondition],
CreateRule -> Natural
priority :: Prelude.Natural,
CreateRule -> [Action]
actions :: [Action]
}
deriving (CreateRule -> CreateRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRule -> CreateRule -> Bool
$c/= :: CreateRule -> CreateRule -> Bool
== :: CreateRule -> CreateRule -> Bool
$c== :: CreateRule -> CreateRule -> Bool
Prelude.Eq, ReadPrec [CreateRule]
ReadPrec CreateRule
Int -> ReadS CreateRule
ReadS [CreateRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRule]
$creadListPrec :: ReadPrec [CreateRule]
readPrec :: ReadPrec CreateRule
$creadPrec :: ReadPrec CreateRule
readList :: ReadS [CreateRule]
$creadList :: ReadS [CreateRule]
readsPrec :: Int -> ReadS CreateRule
$creadsPrec :: Int -> ReadS CreateRule
Prelude.Read, Int -> CreateRule -> ShowS
[CreateRule] -> ShowS
CreateRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRule] -> ShowS
$cshowList :: [CreateRule] -> ShowS
show :: CreateRule -> String
$cshow :: CreateRule -> String
showsPrec :: Int -> CreateRule -> ShowS
$cshowsPrec :: Int -> CreateRule -> ShowS
Prelude.Show, forall x. Rep CreateRule x -> CreateRule
forall x. CreateRule -> Rep CreateRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRule x -> CreateRule
$cfrom :: forall x. CreateRule -> Rep CreateRule x
Prelude.Generic)
newCreateRule ::
Prelude.Text ->
Prelude.Natural ->
CreateRule
newCreateRule :: Text -> Natural -> CreateRule
newCreateRule Text
pListenerArn_ Natural
pPriority_ =
CreateRule'
{ $sel:tags:CreateRule' :: Maybe (NonEmpty Tag)
tags = forall a. Maybe a
Prelude.Nothing,
$sel:listenerArn:CreateRule' :: Text
listenerArn = Text
pListenerArn_,
$sel:conditions:CreateRule' :: [RuleCondition]
conditions = forall a. Monoid a => a
Prelude.mempty,
$sel:priority:CreateRule' :: Natural
priority = Natural
pPriority_,
$sel:actions:CreateRule' :: [Action]
actions = forall a. Monoid a => a
Prelude.mempty
}
createRule_tags :: Lens.Lens' CreateRule (Prelude.Maybe (Prelude.NonEmpty Tag))
createRule_tags :: Lens' CreateRule (Maybe (NonEmpty Tag))
createRule_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateRule
s@CreateRule' {} Maybe (NonEmpty Tag)
a -> CreateRule
s {$sel:tags:CreateRule' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateRule) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createRule_listenerArn :: Lens.Lens' CreateRule Prelude.Text
createRule_listenerArn :: Lens' CreateRule Text
createRule_listenerArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Text
listenerArn :: Text
$sel:listenerArn:CreateRule' :: CreateRule -> Text
listenerArn} -> Text
listenerArn) (\s :: CreateRule
s@CreateRule' {} Text
a -> CreateRule
s {$sel:listenerArn:CreateRule' :: Text
listenerArn = Text
a} :: CreateRule)
createRule_conditions :: Lens.Lens' CreateRule [RuleCondition]
createRule_conditions :: Lens' CreateRule [RuleCondition]
createRule_conditions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {[RuleCondition]
conditions :: [RuleCondition]
$sel:conditions:CreateRule' :: CreateRule -> [RuleCondition]
conditions} -> [RuleCondition]
conditions) (\s :: CreateRule
s@CreateRule' {} [RuleCondition]
a -> CreateRule
s {$sel:conditions:CreateRule' :: [RuleCondition]
conditions = [RuleCondition]
a} :: CreateRule) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createRule_priority :: Lens.Lens' CreateRule Prelude.Natural
createRule_priority :: Lens' CreateRule Natural
createRule_priority = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {Natural
priority :: Natural
$sel:priority:CreateRule' :: CreateRule -> Natural
priority} -> Natural
priority) (\s :: CreateRule
s@CreateRule' {} Natural
a -> CreateRule
s {$sel:priority:CreateRule' :: Natural
priority = Natural
a} :: CreateRule)
createRule_actions :: Lens.Lens' CreateRule [Action]
createRule_actions :: Lens' CreateRule [Action]
createRule_actions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRule' {[Action]
actions :: [Action]
$sel:actions:CreateRule' :: CreateRule -> [Action]
actions} -> [Action]
actions) (\s :: CreateRule
s@CreateRule' {} [Action]
a -> CreateRule
s {$sel:actions:CreateRule' :: [Action]
actions = [Action]
a} :: CreateRule) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreateRule where
type AWSResponse CreateRule = CreateRuleResponse
request :: (Service -> Service) -> CreateRule -> Request CreateRule
request Service -> Service
overrides =
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRule)))
response =
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
-> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
Text
"CreateRuleResult"
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe [Rule] -> Int -> CreateRuleResponse
CreateRuleResponse'
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
"Rules"
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateRule where
hashWithSalt :: Int -> CreateRule -> Int
hashWithSalt Int
_salt CreateRule' {Natural
[RuleCondition]
[Action]
Maybe (NonEmpty Tag)
Text
actions :: [Action]
priority :: Natural
conditions :: [RuleCondition]
listenerArn :: Text
tags :: Maybe (NonEmpty Tag)
$sel:actions:CreateRule' :: CreateRule -> [Action]
$sel:priority:CreateRule' :: CreateRule -> Natural
$sel:conditions:CreateRule' :: CreateRule -> [RuleCondition]
$sel:listenerArn:CreateRule' :: CreateRule -> Text
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Tag)
tags
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
listenerArn
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [RuleCondition]
conditions
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
priority
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Action]
actions
instance Prelude.NFData CreateRule where
rnf :: CreateRule -> ()
rnf CreateRule' {Natural
[RuleCondition]
[Action]
Maybe (NonEmpty Tag)
Text
actions :: [Action]
priority :: Natural
conditions :: [RuleCondition]
listenerArn :: Text
tags :: Maybe (NonEmpty Tag)
$sel:actions:CreateRule' :: CreateRule -> [Action]
$sel:priority:CreateRule' :: CreateRule -> Natural
$sel:conditions:CreateRule' :: CreateRule -> [RuleCondition]
$sel:listenerArn:CreateRule' :: CreateRule -> Text
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Tag)
tags
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
listenerArn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [RuleCondition]
conditions
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
priority
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Action]
actions
instance Data.ToHeaders CreateRule where
toHeaders :: CreateRule -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
instance Data.ToPath CreateRule where
toPath :: CreateRule -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery CreateRule where
toQuery :: CreateRule -> QueryString
toQuery CreateRule' {Natural
[RuleCondition]
[Action]
Maybe (NonEmpty Tag)
Text
actions :: [Action]
priority :: Natural
conditions :: [RuleCondition]
listenerArn :: Text
tags :: Maybe (NonEmpty Tag)
$sel:actions:CreateRule' :: CreateRule -> [Action]
$sel:priority:CreateRule' :: CreateRule -> Natural
$sel:conditions:CreateRule' :: CreateRule -> [RuleCondition]
$sel:listenerArn:CreateRule' :: CreateRule -> Text
$sel:tags:CreateRule' :: CreateRule -> Maybe (NonEmpty Tag)
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Action"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"CreateRule" :: Prelude.ByteString),
ByteString
"Version"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2015-12-01" :: Prelude.ByteString),
ByteString
"Tags"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a. ToQuery a => a -> QueryString
Data.toQuery
(forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags),
ByteString
"ListenerArn" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
listenerArn,
ByteString
"Conditions"
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [RuleCondition]
conditions,
ByteString
"Priority" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Natural
priority,
ByteString
"Actions" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Data.toQueryList ByteString
"member" [Action]
actions
]
data CreateRuleResponse = CreateRuleResponse'
{
CreateRuleResponse -> Maybe [Rule]
rules :: Prelude.Maybe [Rule],
CreateRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateRuleResponse -> CreateRuleResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRuleResponse -> CreateRuleResponse -> Bool
$c/= :: CreateRuleResponse -> CreateRuleResponse -> Bool
== :: CreateRuleResponse -> CreateRuleResponse -> Bool
$c== :: CreateRuleResponse -> CreateRuleResponse -> Bool
Prelude.Eq, ReadPrec [CreateRuleResponse]
ReadPrec CreateRuleResponse
Int -> ReadS CreateRuleResponse
ReadS [CreateRuleResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRuleResponse]
$creadListPrec :: ReadPrec [CreateRuleResponse]
readPrec :: ReadPrec CreateRuleResponse
$creadPrec :: ReadPrec CreateRuleResponse
readList :: ReadS [CreateRuleResponse]
$creadList :: ReadS [CreateRuleResponse]
readsPrec :: Int -> ReadS CreateRuleResponse
$creadsPrec :: Int -> ReadS CreateRuleResponse
Prelude.Read, Int -> CreateRuleResponse -> ShowS
[CreateRuleResponse] -> ShowS
CreateRuleResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRuleResponse] -> ShowS
$cshowList :: [CreateRuleResponse] -> ShowS
show :: CreateRuleResponse -> String
$cshow :: CreateRuleResponse -> String
showsPrec :: Int -> CreateRuleResponse -> ShowS
$cshowsPrec :: Int -> CreateRuleResponse -> ShowS
Prelude.Show, forall x. Rep CreateRuleResponse x -> CreateRuleResponse
forall x. CreateRuleResponse -> Rep CreateRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRuleResponse x -> CreateRuleResponse
$cfrom :: forall x. CreateRuleResponse -> Rep CreateRuleResponse x
Prelude.Generic)
newCreateRuleResponse ::
Prelude.Int ->
CreateRuleResponse
newCreateRuleResponse :: Int -> CreateRuleResponse
newCreateRuleResponse Int
pHttpStatus_ =
CreateRuleResponse'
{ $sel:rules:CreateRuleResponse' :: Maybe [Rule]
rules = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createRuleResponse_rules :: Lens.Lens' CreateRuleResponse (Prelude.Maybe [Rule])
createRuleResponse_rules :: Lens' CreateRuleResponse (Maybe [Rule])
createRuleResponse_rules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleResponse' {Maybe [Rule]
rules :: Maybe [Rule]
$sel:rules:CreateRuleResponse' :: CreateRuleResponse -> Maybe [Rule]
rules} -> Maybe [Rule]
rules) (\s :: CreateRuleResponse
s@CreateRuleResponse' {} Maybe [Rule]
a -> CreateRuleResponse
s {$sel:rules:CreateRuleResponse' :: Maybe [Rule]
rules = Maybe [Rule]
a} :: CreateRuleResponse) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createRuleResponse_httpStatus :: Lens.Lens' CreateRuleResponse Prelude.Int
createRuleResponse_httpStatus :: Lens' CreateRuleResponse Int
createRuleResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateRuleResponse' :: CreateRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateRuleResponse
s@CreateRuleResponse' {} Int
a -> CreateRuleResponse
s {$sel:httpStatus:CreateRuleResponse' :: Int
httpStatus = Int
a} :: CreateRuleResponse)
instance Prelude.NFData CreateRuleResponse where
rnf :: CreateRuleResponse -> ()
rnf CreateRuleResponse' {Int
Maybe [Rule]
httpStatus :: Int
rules :: Maybe [Rule]
$sel:httpStatus:CreateRuleResponse' :: CreateRuleResponse -> Int
$sel:rules:CreateRuleResponse' :: CreateRuleResponse -> Maybe [Rule]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Rule]
rules
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus