{-# 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.Lightsail.CreateContactMethod
(
CreateContactMethod (..),
newCreateContactMethod,
createContactMethod_protocol,
createContactMethod_contactEndpoint,
CreateContactMethodResponse (..),
newCreateContactMethodResponse,
createContactMethodResponse_operations,
createContactMethodResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateContactMethod = CreateContactMethod'
{
CreateContactMethod -> ContactProtocol
protocol :: ContactProtocol,
CreateContactMethod -> Text
contactEndpoint :: Prelude.Text
}
deriving (CreateContactMethod -> CreateContactMethod -> Bool
(CreateContactMethod -> CreateContactMethod -> Bool)
-> (CreateContactMethod -> CreateContactMethod -> Bool)
-> Eq CreateContactMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContactMethod -> CreateContactMethod -> Bool
$c/= :: CreateContactMethod -> CreateContactMethod -> Bool
== :: CreateContactMethod -> CreateContactMethod -> Bool
$c== :: CreateContactMethod -> CreateContactMethod -> Bool
Prelude.Eq, ReadPrec [CreateContactMethod]
ReadPrec CreateContactMethod
Int -> ReadS CreateContactMethod
ReadS [CreateContactMethod]
(Int -> ReadS CreateContactMethod)
-> ReadS [CreateContactMethod]
-> ReadPrec CreateContactMethod
-> ReadPrec [CreateContactMethod]
-> Read CreateContactMethod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContactMethod]
$creadListPrec :: ReadPrec [CreateContactMethod]
readPrec :: ReadPrec CreateContactMethod
$creadPrec :: ReadPrec CreateContactMethod
readList :: ReadS [CreateContactMethod]
$creadList :: ReadS [CreateContactMethod]
readsPrec :: Int -> ReadS CreateContactMethod
$creadsPrec :: Int -> ReadS CreateContactMethod
Prelude.Read, Int -> CreateContactMethod -> ShowS
[CreateContactMethod] -> ShowS
CreateContactMethod -> String
(Int -> CreateContactMethod -> ShowS)
-> (CreateContactMethod -> String)
-> ([CreateContactMethod] -> ShowS)
-> Show CreateContactMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContactMethod] -> ShowS
$cshowList :: [CreateContactMethod] -> ShowS
show :: CreateContactMethod -> String
$cshow :: CreateContactMethod -> String
showsPrec :: Int -> CreateContactMethod -> ShowS
$cshowsPrec :: Int -> CreateContactMethod -> ShowS
Prelude.Show, (forall x. CreateContactMethod -> Rep CreateContactMethod x)
-> (forall x. Rep CreateContactMethod x -> CreateContactMethod)
-> Generic CreateContactMethod
forall x. Rep CreateContactMethod x -> CreateContactMethod
forall x. CreateContactMethod -> Rep CreateContactMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateContactMethod x -> CreateContactMethod
$cfrom :: forall x. CreateContactMethod -> Rep CreateContactMethod x
Prelude.Generic)
newCreateContactMethod ::
ContactProtocol ->
Prelude.Text ->
CreateContactMethod
newCreateContactMethod :: ContactProtocol -> Text -> CreateContactMethod
newCreateContactMethod ContactProtocol
pProtocol_ Text
pContactEndpoint_ =
CreateContactMethod' :: ContactProtocol -> Text -> CreateContactMethod
CreateContactMethod'
{ $sel:protocol:CreateContactMethod' :: ContactProtocol
protocol = ContactProtocol
pProtocol_,
$sel:contactEndpoint:CreateContactMethod' :: Text
contactEndpoint = Text
pContactEndpoint_
}
createContactMethod_protocol :: Lens.Lens' CreateContactMethod ContactProtocol
createContactMethod_protocol :: (ContactProtocol -> f ContactProtocol)
-> CreateContactMethod -> f CreateContactMethod
createContactMethod_protocol = (CreateContactMethod -> ContactProtocol)
-> (CreateContactMethod -> ContactProtocol -> CreateContactMethod)
-> Lens
CreateContactMethod
CreateContactMethod
ContactProtocol
ContactProtocol
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactMethod' {ContactProtocol
protocol :: ContactProtocol
$sel:protocol:CreateContactMethod' :: CreateContactMethod -> ContactProtocol
protocol} -> ContactProtocol
protocol) (\s :: CreateContactMethod
s@CreateContactMethod' {} ContactProtocol
a -> CreateContactMethod
s {$sel:protocol:CreateContactMethod' :: ContactProtocol
protocol = ContactProtocol
a} :: CreateContactMethod)
createContactMethod_contactEndpoint :: Lens.Lens' CreateContactMethod Prelude.Text
createContactMethod_contactEndpoint :: (Text -> f Text) -> CreateContactMethod -> f CreateContactMethod
createContactMethod_contactEndpoint = (CreateContactMethod -> Text)
-> (CreateContactMethod -> Text -> CreateContactMethod)
-> Lens CreateContactMethod CreateContactMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactMethod' {Text
contactEndpoint :: Text
$sel:contactEndpoint:CreateContactMethod' :: CreateContactMethod -> Text
contactEndpoint} -> Text
contactEndpoint) (\s :: CreateContactMethod
s@CreateContactMethod' {} Text
a -> CreateContactMethod
s {$sel:contactEndpoint:CreateContactMethod' :: Text
contactEndpoint = Text
a} :: CreateContactMethod)
instance Core.AWSRequest CreateContactMethod where
type
AWSResponse CreateContactMethod =
CreateContactMethodResponse
request :: CreateContactMethod -> Request CreateContactMethod
request = Service -> CreateContactMethod -> Request CreateContactMethod
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateContactMethod
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateContactMethod)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateContactMethod))
-> Logger
-> Service
-> Proxy CreateContactMethod
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateContactMethod)))
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 [Operation] -> Int -> CreateContactMethodResponse
CreateContactMethodResponse'
(Maybe [Operation] -> Int -> CreateContactMethodResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> CreateContactMethodResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> CreateContactMethodResponse)
-> Either String Int -> Either String CreateContactMethodResponse
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 CreateContactMethod
instance Prelude.NFData CreateContactMethod
instance Core.ToHeaders CreateContactMethod where
toHeaders :: CreateContactMethod -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateContactMethod -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.CreateContactMethod" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateContactMethod where
toJSON :: CreateContactMethod -> Value
toJSON CreateContactMethod' {Text
ContactProtocol
contactEndpoint :: Text
protocol :: ContactProtocol
$sel:contactEndpoint:CreateContactMethod' :: CreateContactMethod -> Text
$sel:protocol:CreateContactMethod' :: CreateContactMethod -> ContactProtocol
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"protocol" Text -> ContactProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ContactProtocol
protocol),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"contactEndpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactEndpoint)
]
)
instance Core.ToPath CreateContactMethod where
toPath :: CreateContactMethod -> ByteString
toPath = ByteString -> CreateContactMethod -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery CreateContactMethod where
toQuery :: CreateContactMethod -> QueryString
toQuery = QueryString -> CreateContactMethod -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateContactMethodResponse = CreateContactMethodResponse'
{
CreateContactMethodResponse -> Maybe [Operation]
operations :: Prelude.Maybe [Operation],
CreateContactMethodResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateContactMethodResponse -> CreateContactMethodResponse -> Bool
(CreateContactMethodResponse
-> CreateContactMethodResponse -> Bool)
-> (CreateContactMethodResponse
-> CreateContactMethodResponse -> Bool)
-> Eq CreateContactMethodResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateContactMethodResponse -> CreateContactMethodResponse -> Bool
$c/= :: CreateContactMethodResponse -> CreateContactMethodResponse -> Bool
== :: CreateContactMethodResponse -> CreateContactMethodResponse -> Bool
$c== :: CreateContactMethodResponse -> CreateContactMethodResponse -> Bool
Prelude.Eq, ReadPrec [CreateContactMethodResponse]
ReadPrec CreateContactMethodResponse
Int -> ReadS CreateContactMethodResponse
ReadS [CreateContactMethodResponse]
(Int -> ReadS CreateContactMethodResponse)
-> ReadS [CreateContactMethodResponse]
-> ReadPrec CreateContactMethodResponse
-> ReadPrec [CreateContactMethodResponse]
-> Read CreateContactMethodResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateContactMethodResponse]
$creadListPrec :: ReadPrec [CreateContactMethodResponse]
readPrec :: ReadPrec CreateContactMethodResponse
$creadPrec :: ReadPrec CreateContactMethodResponse
readList :: ReadS [CreateContactMethodResponse]
$creadList :: ReadS [CreateContactMethodResponse]
readsPrec :: Int -> ReadS CreateContactMethodResponse
$creadsPrec :: Int -> ReadS CreateContactMethodResponse
Prelude.Read, Int -> CreateContactMethodResponse -> ShowS
[CreateContactMethodResponse] -> ShowS
CreateContactMethodResponse -> String
(Int -> CreateContactMethodResponse -> ShowS)
-> (CreateContactMethodResponse -> String)
-> ([CreateContactMethodResponse] -> ShowS)
-> Show CreateContactMethodResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateContactMethodResponse] -> ShowS
$cshowList :: [CreateContactMethodResponse] -> ShowS
show :: CreateContactMethodResponse -> String
$cshow :: CreateContactMethodResponse -> String
showsPrec :: Int -> CreateContactMethodResponse -> ShowS
$cshowsPrec :: Int -> CreateContactMethodResponse -> ShowS
Prelude.Show, (forall x.
CreateContactMethodResponse -> Rep CreateContactMethodResponse x)
-> (forall x.
Rep CreateContactMethodResponse x -> CreateContactMethodResponse)
-> Generic CreateContactMethodResponse
forall x.
Rep CreateContactMethodResponse x -> CreateContactMethodResponse
forall x.
CreateContactMethodResponse -> Rep CreateContactMethodResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateContactMethodResponse x -> CreateContactMethodResponse
$cfrom :: forall x.
CreateContactMethodResponse -> Rep CreateContactMethodResponse x
Prelude.Generic)
newCreateContactMethodResponse ::
Prelude.Int ->
CreateContactMethodResponse
newCreateContactMethodResponse :: Int -> CreateContactMethodResponse
newCreateContactMethodResponse Int
pHttpStatus_ =
CreateContactMethodResponse' :: Maybe [Operation] -> Int -> CreateContactMethodResponse
CreateContactMethodResponse'
{ $sel:operations:CreateContactMethodResponse' :: Maybe [Operation]
operations =
Maybe [Operation]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateContactMethodResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createContactMethodResponse_operations :: Lens.Lens' CreateContactMethodResponse (Prelude.Maybe [Operation])
createContactMethodResponse_operations :: (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateContactMethodResponse -> f CreateContactMethodResponse
createContactMethodResponse_operations = (CreateContactMethodResponse -> Maybe [Operation])
-> (CreateContactMethodResponse
-> Maybe [Operation] -> CreateContactMethodResponse)
-> Lens
CreateContactMethodResponse
CreateContactMethodResponse
(Maybe [Operation])
(Maybe [Operation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactMethodResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:CreateContactMethodResponse' :: CreateContactMethodResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: CreateContactMethodResponse
s@CreateContactMethodResponse' {} Maybe [Operation]
a -> CreateContactMethodResponse
s {$sel:operations:CreateContactMethodResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: CreateContactMethodResponse) ((Maybe [Operation] -> f (Maybe [Operation]))
-> CreateContactMethodResponse -> f CreateContactMethodResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
-> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> CreateContactMethodResponse
-> f CreateContactMethodResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
(Maybe [Operation])
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 AnIso [Operation] [Operation] [Operation] [Operation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createContactMethodResponse_httpStatus :: Lens.Lens' CreateContactMethodResponse Prelude.Int
createContactMethodResponse_httpStatus :: (Int -> f Int)
-> CreateContactMethodResponse -> f CreateContactMethodResponse
createContactMethodResponse_httpStatus = (CreateContactMethodResponse -> Int)
-> (CreateContactMethodResponse
-> Int -> CreateContactMethodResponse)
-> Lens
CreateContactMethodResponse CreateContactMethodResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateContactMethodResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateContactMethodResponse' :: CreateContactMethodResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateContactMethodResponse
s@CreateContactMethodResponse' {} Int
a -> CreateContactMethodResponse
s {$sel:httpStatus:CreateContactMethodResponse' :: Int
httpStatus = Int
a} :: CreateContactMethodResponse)
instance Prelude.NFData CreateContactMethodResponse