{-# 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.GetContactMethods
(
GetContactMethods (..),
newGetContactMethods,
getContactMethods_protocols,
GetContactMethodsResponse (..),
newGetContactMethodsResponse,
getContactMethodsResponse_contactMethods,
getContactMethodsResponse_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 GetContactMethods = GetContactMethods'
{
GetContactMethods -> Maybe [ContactProtocol]
protocols :: Prelude.Maybe [ContactProtocol]
}
deriving (GetContactMethods -> GetContactMethods -> Bool
(GetContactMethods -> GetContactMethods -> Bool)
-> (GetContactMethods -> GetContactMethods -> Bool)
-> Eq GetContactMethods
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContactMethods -> GetContactMethods -> Bool
$c/= :: GetContactMethods -> GetContactMethods -> Bool
== :: GetContactMethods -> GetContactMethods -> Bool
$c== :: GetContactMethods -> GetContactMethods -> Bool
Prelude.Eq, ReadPrec [GetContactMethods]
ReadPrec GetContactMethods
Int -> ReadS GetContactMethods
ReadS [GetContactMethods]
(Int -> ReadS GetContactMethods)
-> ReadS [GetContactMethods]
-> ReadPrec GetContactMethods
-> ReadPrec [GetContactMethods]
-> Read GetContactMethods
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContactMethods]
$creadListPrec :: ReadPrec [GetContactMethods]
readPrec :: ReadPrec GetContactMethods
$creadPrec :: ReadPrec GetContactMethods
readList :: ReadS [GetContactMethods]
$creadList :: ReadS [GetContactMethods]
readsPrec :: Int -> ReadS GetContactMethods
$creadsPrec :: Int -> ReadS GetContactMethods
Prelude.Read, Int -> GetContactMethods -> ShowS
[GetContactMethods] -> ShowS
GetContactMethods -> String
(Int -> GetContactMethods -> ShowS)
-> (GetContactMethods -> String)
-> ([GetContactMethods] -> ShowS)
-> Show GetContactMethods
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContactMethods] -> ShowS
$cshowList :: [GetContactMethods] -> ShowS
show :: GetContactMethods -> String
$cshow :: GetContactMethods -> String
showsPrec :: Int -> GetContactMethods -> ShowS
$cshowsPrec :: Int -> GetContactMethods -> ShowS
Prelude.Show, (forall x. GetContactMethods -> Rep GetContactMethods x)
-> (forall x. Rep GetContactMethods x -> GetContactMethods)
-> Generic GetContactMethods
forall x. Rep GetContactMethods x -> GetContactMethods
forall x. GetContactMethods -> Rep GetContactMethods x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetContactMethods x -> GetContactMethods
$cfrom :: forall x. GetContactMethods -> Rep GetContactMethods x
Prelude.Generic)
newGetContactMethods ::
GetContactMethods
newGetContactMethods :: GetContactMethods
newGetContactMethods =
GetContactMethods' :: Maybe [ContactProtocol] -> GetContactMethods
GetContactMethods' {$sel:protocols:GetContactMethods' :: Maybe [ContactProtocol]
protocols = Maybe [ContactProtocol]
forall a. Maybe a
Prelude.Nothing}
getContactMethods_protocols :: Lens.Lens' GetContactMethods (Prelude.Maybe [ContactProtocol])
getContactMethods_protocols :: (Maybe [ContactProtocol] -> f (Maybe [ContactProtocol]))
-> GetContactMethods -> f GetContactMethods
getContactMethods_protocols = (GetContactMethods -> Maybe [ContactProtocol])
-> (GetContactMethods
-> Maybe [ContactProtocol] -> GetContactMethods)
-> Lens
GetContactMethods
GetContactMethods
(Maybe [ContactProtocol])
(Maybe [ContactProtocol])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactMethods' {Maybe [ContactProtocol]
protocols :: Maybe [ContactProtocol]
$sel:protocols:GetContactMethods' :: GetContactMethods -> Maybe [ContactProtocol]
protocols} -> Maybe [ContactProtocol]
protocols) (\s :: GetContactMethods
s@GetContactMethods' {} Maybe [ContactProtocol]
a -> GetContactMethods
s {$sel:protocols:GetContactMethods' :: Maybe [ContactProtocol]
protocols = Maybe [ContactProtocol]
a} :: GetContactMethods) ((Maybe [ContactProtocol] -> f (Maybe [ContactProtocol]))
-> GetContactMethods -> f GetContactMethods)
-> ((Maybe [ContactProtocol] -> f (Maybe [ContactProtocol]))
-> Maybe [ContactProtocol] -> f (Maybe [ContactProtocol]))
-> (Maybe [ContactProtocol] -> f (Maybe [ContactProtocol]))
-> GetContactMethods
-> f GetContactMethods
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[ContactProtocol]
[ContactProtocol]
[ContactProtocol]
[ContactProtocol]
-> Iso
(Maybe [ContactProtocol])
(Maybe [ContactProtocol])
(Maybe [ContactProtocol])
(Maybe [ContactProtocol])
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
[ContactProtocol]
[ContactProtocol]
[ContactProtocol]
[ContactProtocol]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest GetContactMethods where
type
AWSResponse GetContactMethods =
GetContactMethodsResponse
request :: GetContactMethods -> Request GetContactMethods
request = Service -> GetContactMethods -> Request GetContactMethods
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetContactMethods
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetContactMethods)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetContactMethods))
-> Logger
-> Service
-> Proxy GetContactMethods
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetContactMethods)))
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 [ContactMethod] -> Int -> GetContactMethodsResponse
GetContactMethodsResponse'
(Maybe [ContactMethod] -> Int -> GetContactMethodsResponse)
-> Either String (Maybe [ContactMethod])
-> Either String (Int -> GetContactMethodsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe (Maybe [ContactMethod]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"contactMethods" Either String (Maybe (Maybe [ContactMethod]))
-> Maybe [ContactMethod] -> Either String (Maybe [ContactMethod])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ContactMethod]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> GetContactMethodsResponse)
-> Either String Int -> Either String GetContactMethodsResponse
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 GetContactMethods
instance Prelude.NFData GetContactMethods
instance Core.ToHeaders GetContactMethods where
toHeaders :: GetContactMethods -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetContactMethods -> 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.GetContactMethods" ::
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 GetContactMethods where
toJSON :: GetContactMethods -> Value
toJSON GetContactMethods' {Maybe [ContactProtocol]
protocols :: Maybe [ContactProtocol]
$sel:protocols:GetContactMethods' :: GetContactMethods -> Maybe [ContactProtocol]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Key
"protocols" Key -> [ContactProtocol] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=) ([ContactProtocol] -> Pair)
-> Maybe [ContactProtocol] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ContactProtocol]
protocols]
)
instance Core.ToPath GetContactMethods where
toPath :: GetContactMethods -> ByteString
toPath = ByteString -> GetContactMethods -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetContactMethods where
toQuery :: GetContactMethods -> QueryString
toQuery = QueryString -> GetContactMethods -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetContactMethodsResponse = GetContactMethodsResponse'
{
GetContactMethodsResponse -> Maybe [ContactMethod]
contactMethods :: Prelude.Maybe [ContactMethod],
GetContactMethodsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetContactMethodsResponse -> GetContactMethodsResponse -> Bool
(GetContactMethodsResponse -> GetContactMethodsResponse -> Bool)
-> (GetContactMethodsResponse -> GetContactMethodsResponse -> Bool)
-> Eq GetContactMethodsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContactMethodsResponse -> GetContactMethodsResponse -> Bool
$c/= :: GetContactMethodsResponse -> GetContactMethodsResponse -> Bool
== :: GetContactMethodsResponse -> GetContactMethodsResponse -> Bool
$c== :: GetContactMethodsResponse -> GetContactMethodsResponse -> Bool
Prelude.Eq, ReadPrec [GetContactMethodsResponse]
ReadPrec GetContactMethodsResponse
Int -> ReadS GetContactMethodsResponse
ReadS [GetContactMethodsResponse]
(Int -> ReadS GetContactMethodsResponse)
-> ReadS [GetContactMethodsResponse]
-> ReadPrec GetContactMethodsResponse
-> ReadPrec [GetContactMethodsResponse]
-> Read GetContactMethodsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContactMethodsResponse]
$creadListPrec :: ReadPrec [GetContactMethodsResponse]
readPrec :: ReadPrec GetContactMethodsResponse
$creadPrec :: ReadPrec GetContactMethodsResponse
readList :: ReadS [GetContactMethodsResponse]
$creadList :: ReadS [GetContactMethodsResponse]
readsPrec :: Int -> ReadS GetContactMethodsResponse
$creadsPrec :: Int -> ReadS GetContactMethodsResponse
Prelude.Read, Int -> GetContactMethodsResponse -> ShowS
[GetContactMethodsResponse] -> ShowS
GetContactMethodsResponse -> String
(Int -> GetContactMethodsResponse -> ShowS)
-> (GetContactMethodsResponse -> String)
-> ([GetContactMethodsResponse] -> ShowS)
-> Show GetContactMethodsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContactMethodsResponse] -> ShowS
$cshowList :: [GetContactMethodsResponse] -> ShowS
show :: GetContactMethodsResponse -> String
$cshow :: GetContactMethodsResponse -> String
showsPrec :: Int -> GetContactMethodsResponse -> ShowS
$cshowsPrec :: Int -> GetContactMethodsResponse -> ShowS
Prelude.Show, (forall x.
GetContactMethodsResponse -> Rep GetContactMethodsResponse x)
-> (forall x.
Rep GetContactMethodsResponse x -> GetContactMethodsResponse)
-> Generic GetContactMethodsResponse
forall x.
Rep GetContactMethodsResponse x -> GetContactMethodsResponse
forall x.
GetContactMethodsResponse -> Rep GetContactMethodsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContactMethodsResponse x -> GetContactMethodsResponse
$cfrom :: forall x.
GetContactMethodsResponse -> Rep GetContactMethodsResponse x
Prelude.Generic)
newGetContactMethodsResponse ::
Prelude.Int ->
GetContactMethodsResponse
newGetContactMethodsResponse :: Int -> GetContactMethodsResponse
newGetContactMethodsResponse Int
pHttpStatus_ =
GetContactMethodsResponse' :: Maybe [ContactMethod] -> Int -> GetContactMethodsResponse
GetContactMethodsResponse'
{ $sel:contactMethods:GetContactMethodsResponse' :: Maybe [ContactMethod]
contactMethods =
Maybe [ContactMethod]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetContactMethodsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getContactMethodsResponse_contactMethods :: Lens.Lens' GetContactMethodsResponse (Prelude.Maybe [ContactMethod])
getContactMethodsResponse_contactMethods :: (Maybe [ContactMethod] -> f (Maybe [ContactMethod]))
-> GetContactMethodsResponse -> f GetContactMethodsResponse
getContactMethodsResponse_contactMethods = (GetContactMethodsResponse -> Maybe [ContactMethod])
-> (GetContactMethodsResponse
-> Maybe [ContactMethod] -> GetContactMethodsResponse)
-> Lens
GetContactMethodsResponse
GetContactMethodsResponse
(Maybe [ContactMethod])
(Maybe [ContactMethod])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactMethodsResponse' {Maybe [ContactMethod]
contactMethods :: Maybe [ContactMethod]
$sel:contactMethods:GetContactMethodsResponse' :: GetContactMethodsResponse -> Maybe [ContactMethod]
contactMethods} -> Maybe [ContactMethod]
contactMethods) (\s :: GetContactMethodsResponse
s@GetContactMethodsResponse' {} Maybe [ContactMethod]
a -> GetContactMethodsResponse
s {$sel:contactMethods:GetContactMethodsResponse' :: Maybe [ContactMethod]
contactMethods = Maybe [ContactMethod]
a} :: GetContactMethodsResponse) ((Maybe [ContactMethod] -> f (Maybe [ContactMethod]))
-> GetContactMethodsResponse -> f GetContactMethodsResponse)
-> ((Maybe [ContactMethod] -> f (Maybe [ContactMethod]))
-> Maybe [ContactMethod] -> f (Maybe [ContactMethod]))
-> (Maybe [ContactMethod] -> f (Maybe [ContactMethod]))
-> GetContactMethodsResponse
-> f GetContactMethodsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[ContactMethod] [ContactMethod] [ContactMethod] [ContactMethod]
-> Iso
(Maybe [ContactMethod])
(Maybe [ContactMethod])
(Maybe [ContactMethod])
(Maybe [ContactMethod])
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
[ContactMethod] [ContactMethod] [ContactMethod] [ContactMethod]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getContactMethodsResponse_httpStatus :: Lens.Lens' GetContactMethodsResponse Prelude.Int
getContactMethodsResponse_httpStatus :: (Int -> f Int)
-> GetContactMethodsResponse -> f GetContactMethodsResponse
getContactMethodsResponse_httpStatus = (GetContactMethodsResponse -> Int)
-> (GetContactMethodsResponse -> Int -> GetContactMethodsResponse)
-> Lens GetContactMethodsResponse GetContactMethodsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContactMethodsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetContactMethodsResponse' :: GetContactMethodsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetContactMethodsResponse
s@GetContactMethodsResponse' {} Int
a -> GetContactMethodsResponse
s {$sel:httpStatus:GetContactMethodsResponse' :: Int
httpStatus = Int
a} :: GetContactMethodsResponse)
instance Prelude.NFData GetContactMethodsResponse