{-# 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.Chime.CreateSipRule
(
CreateSipRule (..),
newCreateSipRule,
createSipRule_disabled,
createSipRule_name,
createSipRule_triggerType,
createSipRule_triggerValue,
createSipRule_targetApplications,
CreateSipRuleResponse (..),
newCreateSipRuleResponse,
createSipRuleResponse_sipRule,
createSipRuleResponse_httpStatus,
)
where
import Amazonka.Chime.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateSipRule = CreateSipRule'
{
CreateSipRule -> Maybe Bool
disabled :: Prelude.Maybe Prelude.Bool,
CreateSipRule -> Text
name :: Prelude.Text,
CreateSipRule -> SipRuleTriggerType
triggerType :: SipRuleTriggerType,
CreateSipRule -> Text
triggerValue :: Prelude.Text,
CreateSipRule -> NonEmpty SipRuleTargetApplication
targetApplications :: Prelude.NonEmpty SipRuleTargetApplication
}
deriving (CreateSipRule -> CreateSipRule -> Bool
(CreateSipRule -> CreateSipRule -> Bool)
-> (CreateSipRule -> CreateSipRule -> Bool) -> Eq CreateSipRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSipRule -> CreateSipRule -> Bool
$c/= :: CreateSipRule -> CreateSipRule -> Bool
== :: CreateSipRule -> CreateSipRule -> Bool
$c== :: CreateSipRule -> CreateSipRule -> Bool
Prelude.Eq, ReadPrec [CreateSipRule]
ReadPrec CreateSipRule
Int -> ReadS CreateSipRule
ReadS [CreateSipRule]
(Int -> ReadS CreateSipRule)
-> ReadS [CreateSipRule]
-> ReadPrec CreateSipRule
-> ReadPrec [CreateSipRule]
-> Read CreateSipRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSipRule]
$creadListPrec :: ReadPrec [CreateSipRule]
readPrec :: ReadPrec CreateSipRule
$creadPrec :: ReadPrec CreateSipRule
readList :: ReadS [CreateSipRule]
$creadList :: ReadS [CreateSipRule]
readsPrec :: Int -> ReadS CreateSipRule
$creadsPrec :: Int -> ReadS CreateSipRule
Prelude.Read, Int -> CreateSipRule -> ShowS
[CreateSipRule] -> ShowS
CreateSipRule -> String
(Int -> CreateSipRule -> ShowS)
-> (CreateSipRule -> String)
-> ([CreateSipRule] -> ShowS)
-> Show CreateSipRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSipRule] -> ShowS
$cshowList :: [CreateSipRule] -> ShowS
show :: CreateSipRule -> String
$cshow :: CreateSipRule -> String
showsPrec :: Int -> CreateSipRule -> ShowS
$cshowsPrec :: Int -> CreateSipRule -> ShowS
Prelude.Show, (forall x. CreateSipRule -> Rep CreateSipRule x)
-> (forall x. Rep CreateSipRule x -> CreateSipRule)
-> Generic CreateSipRule
forall x. Rep CreateSipRule x -> CreateSipRule
forall x. CreateSipRule -> Rep CreateSipRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSipRule x -> CreateSipRule
$cfrom :: forall x. CreateSipRule -> Rep CreateSipRule x
Prelude.Generic)
newCreateSipRule ::
Prelude.Text ->
SipRuleTriggerType ->
Prelude.Text ->
Prelude.NonEmpty SipRuleTargetApplication ->
CreateSipRule
newCreateSipRule :: Text
-> SipRuleTriggerType
-> Text
-> NonEmpty SipRuleTargetApplication
-> CreateSipRule
newCreateSipRule
Text
pName_
SipRuleTriggerType
pTriggerType_
Text
pTriggerValue_
NonEmpty SipRuleTargetApplication
pTargetApplications_ =
CreateSipRule' :: Maybe Bool
-> Text
-> SipRuleTriggerType
-> Text
-> NonEmpty SipRuleTargetApplication
-> CreateSipRule
CreateSipRule'
{ $sel:disabled:CreateSipRule' :: Maybe Bool
disabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateSipRule' :: Text
name = Text
pName_,
$sel:triggerType:CreateSipRule' :: SipRuleTriggerType
triggerType = SipRuleTriggerType
pTriggerType_,
$sel:triggerValue:CreateSipRule' :: Text
triggerValue = Text
pTriggerValue_,
$sel:targetApplications:CreateSipRule' :: NonEmpty SipRuleTargetApplication
targetApplications =
Tagged
(NonEmpty SipRuleTargetApplication)
(Identity (NonEmpty SipRuleTargetApplication))
-> Tagged
(NonEmpty SipRuleTargetApplication)
(Identity (NonEmpty SipRuleTargetApplication))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty SipRuleTargetApplication)
(Identity (NonEmpty SipRuleTargetApplication))
-> Tagged
(NonEmpty SipRuleTargetApplication)
(Identity (NonEmpty SipRuleTargetApplication)))
-> NonEmpty SipRuleTargetApplication
-> NonEmpty SipRuleTargetApplication
forall t b. AReview t b -> b -> t
Lens.# NonEmpty SipRuleTargetApplication
pTargetApplications_
}
createSipRule_disabled :: Lens.Lens' CreateSipRule (Prelude.Maybe Prelude.Bool)
createSipRule_disabled :: (Maybe Bool -> f (Maybe Bool)) -> CreateSipRule -> f CreateSipRule
createSipRule_disabled = (CreateSipRule -> Maybe Bool)
-> (CreateSipRule -> Maybe Bool -> CreateSipRule)
-> Lens CreateSipRule CreateSipRule (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSipRule' {Maybe Bool
disabled :: Maybe Bool
$sel:disabled:CreateSipRule' :: CreateSipRule -> Maybe Bool
disabled} -> Maybe Bool
disabled) (\s :: CreateSipRule
s@CreateSipRule' {} Maybe Bool
a -> CreateSipRule
s {$sel:disabled:CreateSipRule' :: Maybe Bool
disabled = Maybe Bool
a} :: CreateSipRule)
createSipRule_name :: Lens.Lens' CreateSipRule Prelude.Text
createSipRule_name :: (Text -> f Text) -> CreateSipRule -> f CreateSipRule
createSipRule_name = (CreateSipRule -> Text)
-> (CreateSipRule -> Text -> CreateSipRule)
-> Lens CreateSipRule CreateSipRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSipRule' {Text
name :: Text
$sel:name:CreateSipRule' :: CreateSipRule -> Text
name} -> Text
name) (\s :: CreateSipRule
s@CreateSipRule' {} Text
a -> CreateSipRule
s {$sel:name:CreateSipRule' :: Text
name = Text
a} :: CreateSipRule)
createSipRule_triggerType :: Lens.Lens' CreateSipRule SipRuleTriggerType
createSipRule_triggerType :: (SipRuleTriggerType -> f SipRuleTriggerType)
-> CreateSipRule -> f CreateSipRule
createSipRule_triggerType = (CreateSipRule -> SipRuleTriggerType)
-> (CreateSipRule -> SipRuleTriggerType -> CreateSipRule)
-> Lens
CreateSipRule CreateSipRule SipRuleTriggerType SipRuleTriggerType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSipRule' {SipRuleTriggerType
triggerType :: SipRuleTriggerType
$sel:triggerType:CreateSipRule' :: CreateSipRule -> SipRuleTriggerType
triggerType} -> SipRuleTriggerType
triggerType) (\s :: CreateSipRule
s@CreateSipRule' {} SipRuleTriggerType
a -> CreateSipRule
s {$sel:triggerType:CreateSipRule' :: SipRuleTriggerType
triggerType = SipRuleTriggerType
a} :: CreateSipRule)
createSipRule_triggerValue :: Lens.Lens' CreateSipRule Prelude.Text
createSipRule_triggerValue :: (Text -> f Text) -> CreateSipRule -> f CreateSipRule
createSipRule_triggerValue = (CreateSipRule -> Text)
-> (CreateSipRule -> Text -> CreateSipRule)
-> Lens CreateSipRule CreateSipRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSipRule' {Text
triggerValue :: Text
$sel:triggerValue:CreateSipRule' :: CreateSipRule -> Text
triggerValue} -> Text
triggerValue) (\s :: CreateSipRule
s@CreateSipRule' {} Text
a -> CreateSipRule
s {$sel:triggerValue:CreateSipRule' :: Text
triggerValue = Text
a} :: CreateSipRule)
createSipRule_targetApplications :: Lens.Lens' CreateSipRule (Prelude.NonEmpty SipRuleTargetApplication)
createSipRule_targetApplications :: (NonEmpty SipRuleTargetApplication
-> f (NonEmpty SipRuleTargetApplication))
-> CreateSipRule -> f CreateSipRule
createSipRule_targetApplications = (CreateSipRule -> NonEmpty SipRuleTargetApplication)
-> (CreateSipRule
-> NonEmpty SipRuleTargetApplication -> CreateSipRule)
-> Lens
CreateSipRule
CreateSipRule
(NonEmpty SipRuleTargetApplication)
(NonEmpty SipRuleTargetApplication)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSipRule' {NonEmpty SipRuleTargetApplication
targetApplications :: NonEmpty SipRuleTargetApplication
$sel:targetApplications:CreateSipRule' :: CreateSipRule -> NonEmpty SipRuleTargetApplication
targetApplications} -> NonEmpty SipRuleTargetApplication
targetApplications) (\s :: CreateSipRule
s@CreateSipRule' {} NonEmpty SipRuleTargetApplication
a -> CreateSipRule
s {$sel:targetApplications:CreateSipRule' :: NonEmpty SipRuleTargetApplication
targetApplications = NonEmpty SipRuleTargetApplication
a} :: CreateSipRule) ((NonEmpty SipRuleTargetApplication
-> f (NonEmpty SipRuleTargetApplication))
-> CreateSipRule -> f CreateSipRule)
-> ((NonEmpty SipRuleTargetApplication
-> f (NonEmpty SipRuleTargetApplication))
-> NonEmpty SipRuleTargetApplication
-> f (NonEmpty SipRuleTargetApplication))
-> (NonEmpty SipRuleTargetApplication
-> f (NonEmpty SipRuleTargetApplication))
-> CreateSipRule
-> f CreateSipRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty SipRuleTargetApplication
-> f (NonEmpty SipRuleTargetApplication))
-> NonEmpty SipRuleTargetApplication
-> f (NonEmpty SipRuleTargetApplication)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreateSipRule where
type
AWSResponse CreateSipRule =
CreateSipRuleResponse
request :: CreateSipRule -> Request CreateSipRule
request = Service -> CreateSipRule -> Request CreateSipRule
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateSipRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSipRule)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateSipRule))
-> Logger
-> Service
-> Proxy CreateSipRule
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateSipRule)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe SipRule -> Int -> CreateSipRuleResponse
CreateSipRuleResponse'
(Maybe SipRule -> Int -> CreateSipRuleResponse)
-> Either String (Maybe SipRule)
-> Either String (Int -> CreateSipRuleResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe SipRule)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SipRule")
Either String (Int -> CreateSipRuleResponse)
-> Either String Int -> Either String CreateSipRuleResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateSipRule
instance Prelude.NFData CreateSipRule
instance Core.ToHeaders CreateSipRule where
toHeaders :: CreateSipRule -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateSipRule -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateSipRule where
toJSON :: CreateSipRule -> Value
toJSON CreateSipRule' {Maybe Bool
NonEmpty SipRuleTargetApplication
Text
SipRuleTriggerType
targetApplications :: NonEmpty SipRuleTargetApplication
triggerValue :: Text
triggerType :: SipRuleTriggerType
name :: Text
disabled :: Maybe Bool
$sel:targetApplications:CreateSipRule' :: CreateSipRule -> NonEmpty SipRuleTargetApplication
$sel:triggerValue:CreateSipRule' :: CreateSipRule -> Text
$sel:triggerType:CreateSipRule' :: CreateSipRule -> SipRuleTriggerType
$sel:name:CreateSipRule' :: CreateSipRule -> Text
$sel:disabled:CreateSipRule' :: CreateSipRule -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Disabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
disabled,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TriggerType" Text -> SipRuleTriggerType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SipRuleTriggerType
triggerType),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TriggerValue" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
triggerValue),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"TargetApplications" Text -> NonEmpty SipRuleTargetApplication -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty SipRuleTargetApplication
targetApplications)
]
)
instance Core.ToPath CreateSipRule where
toPath :: CreateSipRule -> ByteString
toPath = ByteString -> CreateSipRule -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/sip-rules"
instance Core.ToQuery CreateSipRule where
toQuery :: CreateSipRule -> QueryString
toQuery = QueryString -> CreateSipRule -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateSipRuleResponse = CreateSipRuleResponse'
{
CreateSipRuleResponse -> Maybe SipRule
sipRule :: Prelude.Maybe SipRule,
CreateSipRuleResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateSipRuleResponse -> CreateSipRuleResponse -> Bool
(CreateSipRuleResponse -> CreateSipRuleResponse -> Bool)
-> (CreateSipRuleResponse -> CreateSipRuleResponse -> Bool)
-> Eq CreateSipRuleResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateSipRuleResponse -> CreateSipRuleResponse -> Bool
$c/= :: CreateSipRuleResponse -> CreateSipRuleResponse -> Bool
== :: CreateSipRuleResponse -> CreateSipRuleResponse -> Bool
$c== :: CreateSipRuleResponse -> CreateSipRuleResponse -> Bool
Prelude.Eq, ReadPrec [CreateSipRuleResponse]
ReadPrec CreateSipRuleResponse
Int -> ReadS CreateSipRuleResponse
ReadS [CreateSipRuleResponse]
(Int -> ReadS CreateSipRuleResponse)
-> ReadS [CreateSipRuleResponse]
-> ReadPrec CreateSipRuleResponse
-> ReadPrec [CreateSipRuleResponse]
-> Read CreateSipRuleResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateSipRuleResponse]
$creadListPrec :: ReadPrec [CreateSipRuleResponse]
readPrec :: ReadPrec CreateSipRuleResponse
$creadPrec :: ReadPrec CreateSipRuleResponse
readList :: ReadS [CreateSipRuleResponse]
$creadList :: ReadS [CreateSipRuleResponse]
readsPrec :: Int -> ReadS CreateSipRuleResponse
$creadsPrec :: Int -> ReadS CreateSipRuleResponse
Prelude.Read, Int -> CreateSipRuleResponse -> ShowS
[CreateSipRuleResponse] -> ShowS
CreateSipRuleResponse -> String
(Int -> CreateSipRuleResponse -> ShowS)
-> (CreateSipRuleResponse -> String)
-> ([CreateSipRuleResponse] -> ShowS)
-> Show CreateSipRuleResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateSipRuleResponse] -> ShowS
$cshowList :: [CreateSipRuleResponse] -> ShowS
show :: CreateSipRuleResponse -> String
$cshow :: CreateSipRuleResponse -> String
showsPrec :: Int -> CreateSipRuleResponse -> ShowS
$cshowsPrec :: Int -> CreateSipRuleResponse -> ShowS
Prelude.Show, (forall x. CreateSipRuleResponse -> Rep CreateSipRuleResponse x)
-> (forall x. Rep CreateSipRuleResponse x -> CreateSipRuleResponse)
-> Generic CreateSipRuleResponse
forall x. Rep CreateSipRuleResponse x -> CreateSipRuleResponse
forall x. CreateSipRuleResponse -> Rep CreateSipRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateSipRuleResponse x -> CreateSipRuleResponse
$cfrom :: forall x. CreateSipRuleResponse -> Rep CreateSipRuleResponse x
Prelude.Generic)
newCreateSipRuleResponse ::
Prelude.Int ->
CreateSipRuleResponse
newCreateSipRuleResponse :: Int -> CreateSipRuleResponse
newCreateSipRuleResponse Int
pHttpStatus_ =
CreateSipRuleResponse' :: Maybe SipRule -> Int -> CreateSipRuleResponse
CreateSipRuleResponse'
{ $sel:sipRule:CreateSipRuleResponse' :: Maybe SipRule
sipRule = Maybe SipRule
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateSipRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createSipRuleResponse_sipRule :: Lens.Lens' CreateSipRuleResponse (Prelude.Maybe SipRule)
createSipRuleResponse_sipRule :: (Maybe SipRule -> f (Maybe SipRule))
-> CreateSipRuleResponse -> f CreateSipRuleResponse
createSipRuleResponse_sipRule = (CreateSipRuleResponse -> Maybe SipRule)
-> (CreateSipRuleResponse
-> Maybe SipRule -> CreateSipRuleResponse)
-> Lens
CreateSipRuleResponse
CreateSipRuleResponse
(Maybe SipRule)
(Maybe SipRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSipRuleResponse' {Maybe SipRule
sipRule :: Maybe SipRule
$sel:sipRule:CreateSipRuleResponse' :: CreateSipRuleResponse -> Maybe SipRule
sipRule} -> Maybe SipRule
sipRule) (\s :: CreateSipRuleResponse
s@CreateSipRuleResponse' {} Maybe SipRule
a -> CreateSipRuleResponse
s {$sel:sipRule:CreateSipRuleResponse' :: Maybe SipRule
sipRule = Maybe SipRule
a} :: CreateSipRuleResponse)
createSipRuleResponse_httpStatus :: Lens.Lens' CreateSipRuleResponse Prelude.Int
createSipRuleResponse_httpStatus :: (Int -> f Int) -> CreateSipRuleResponse -> f CreateSipRuleResponse
createSipRuleResponse_httpStatus = (CreateSipRuleResponse -> Int)
-> (CreateSipRuleResponse -> Int -> CreateSipRuleResponse)
-> Lens CreateSipRuleResponse CreateSipRuleResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateSipRuleResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateSipRuleResponse' :: CreateSipRuleResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateSipRuleResponse
s@CreateSipRuleResponse' {} Int
a -> CreateSipRuleResponse
s {$sel:httpStatus:CreateSipRuleResponse' :: Int
httpStatus = Int
a} :: CreateSipRuleResponse)
instance Prelude.NFData CreateSipRuleResponse