{-# 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.IoT1ClickDevices.InvokeDeviceMethod
(
InvokeDeviceMethod (..),
newInvokeDeviceMethod,
invokeDeviceMethod_deviceMethodParameters,
invokeDeviceMethod_deviceMethod,
invokeDeviceMethod_deviceId,
InvokeDeviceMethodResponse (..),
newInvokeDeviceMethodResponse,
invokeDeviceMethodResponse_deviceMethodResponse,
invokeDeviceMethodResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoT1ClickDevices.Types
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 InvokeDeviceMethod = InvokeDeviceMethod'
{
InvokeDeviceMethod -> Maybe Text
deviceMethodParameters :: Prelude.Maybe Prelude.Text,
InvokeDeviceMethod -> Maybe DeviceMethod
deviceMethod :: Prelude.Maybe DeviceMethod,
InvokeDeviceMethod -> Text
deviceId :: Prelude.Text
}
deriving (InvokeDeviceMethod -> InvokeDeviceMethod -> Bool
(InvokeDeviceMethod -> InvokeDeviceMethod -> Bool)
-> (InvokeDeviceMethod -> InvokeDeviceMethod -> Bool)
-> Eq InvokeDeviceMethod
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InvokeDeviceMethod -> InvokeDeviceMethod -> Bool
$c/= :: InvokeDeviceMethod -> InvokeDeviceMethod -> Bool
== :: InvokeDeviceMethod -> InvokeDeviceMethod -> Bool
$c== :: InvokeDeviceMethod -> InvokeDeviceMethod -> Bool
Prelude.Eq, ReadPrec [InvokeDeviceMethod]
ReadPrec InvokeDeviceMethod
Int -> ReadS InvokeDeviceMethod
ReadS [InvokeDeviceMethod]
(Int -> ReadS InvokeDeviceMethod)
-> ReadS [InvokeDeviceMethod]
-> ReadPrec InvokeDeviceMethod
-> ReadPrec [InvokeDeviceMethod]
-> Read InvokeDeviceMethod
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InvokeDeviceMethod]
$creadListPrec :: ReadPrec [InvokeDeviceMethod]
readPrec :: ReadPrec InvokeDeviceMethod
$creadPrec :: ReadPrec InvokeDeviceMethod
readList :: ReadS [InvokeDeviceMethod]
$creadList :: ReadS [InvokeDeviceMethod]
readsPrec :: Int -> ReadS InvokeDeviceMethod
$creadsPrec :: Int -> ReadS InvokeDeviceMethod
Prelude.Read, Int -> InvokeDeviceMethod -> ShowS
[InvokeDeviceMethod] -> ShowS
InvokeDeviceMethod -> String
(Int -> InvokeDeviceMethod -> ShowS)
-> (InvokeDeviceMethod -> String)
-> ([InvokeDeviceMethod] -> ShowS)
-> Show InvokeDeviceMethod
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvokeDeviceMethod] -> ShowS
$cshowList :: [InvokeDeviceMethod] -> ShowS
show :: InvokeDeviceMethod -> String
$cshow :: InvokeDeviceMethod -> String
showsPrec :: Int -> InvokeDeviceMethod -> ShowS
$cshowsPrec :: Int -> InvokeDeviceMethod -> ShowS
Prelude.Show, (forall x. InvokeDeviceMethod -> Rep InvokeDeviceMethod x)
-> (forall x. Rep InvokeDeviceMethod x -> InvokeDeviceMethod)
-> Generic InvokeDeviceMethod
forall x. Rep InvokeDeviceMethod x -> InvokeDeviceMethod
forall x. InvokeDeviceMethod -> Rep InvokeDeviceMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InvokeDeviceMethod x -> InvokeDeviceMethod
$cfrom :: forall x. InvokeDeviceMethod -> Rep InvokeDeviceMethod x
Prelude.Generic)
newInvokeDeviceMethod ::
Prelude.Text ->
InvokeDeviceMethod
newInvokeDeviceMethod :: Text -> InvokeDeviceMethod
newInvokeDeviceMethod Text
pDeviceId_ =
InvokeDeviceMethod' :: Maybe Text -> Maybe DeviceMethod -> Text -> InvokeDeviceMethod
InvokeDeviceMethod'
{ $sel:deviceMethodParameters:InvokeDeviceMethod' :: Maybe Text
deviceMethodParameters =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:deviceMethod:InvokeDeviceMethod' :: Maybe DeviceMethod
deviceMethod = Maybe DeviceMethod
forall a. Maybe a
Prelude.Nothing,
$sel:deviceId:InvokeDeviceMethod' :: Text
deviceId = Text
pDeviceId_
}
invokeDeviceMethod_deviceMethodParameters :: Lens.Lens' InvokeDeviceMethod (Prelude.Maybe Prelude.Text)
invokeDeviceMethod_deviceMethodParameters :: (Maybe Text -> f (Maybe Text))
-> InvokeDeviceMethod -> f InvokeDeviceMethod
invokeDeviceMethod_deviceMethodParameters = (InvokeDeviceMethod -> Maybe Text)
-> (InvokeDeviceMethod -> Maybe Text -> InvokeDeviceMethod)
-> Lens
InvokeDeviceMethod InvokeDeviceMethod (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeDeviceMethod' {Maybe Text
deviceMethodParameters :: Maybe Text
$sel:deviceMethodParameters:InvokeDeviceMethod' :: InvokeDeviceMethod -> Maybe Text
deviceMethodParameters} -> Maybe Text
deviceMethodParameters) (\s :: InvokeDeviceMethod
s@InvokeDeviceMethod' {} Maybe Text
a -> InvokeDeviceMethod
s {$sel:deviceMethodParameters:InvokeDeviceMethod' :: Maybe Text
deviceMethodParameters = Maybe Text
a} :: InvokeDeviceMethod)
invokeDeviceMethod_deviceMethod :: Lens.Lens' InvokeDeviceMethod (Prelude.Maybe DeviceMethod)
invokeDeviceMethod_deviceMethod :: (Maybe DeviceMethod -> f (Maybe DeviceMethod))
-> InvokeDeviceMethod -> f InvokeDeviceMethod
invokeDeviceMethod_deviceMethod = (InvokeDeviceMethod -> Maybe DeviceMethod)
-> (InvokeDeviceMethod -> Maybe DeviceMethod -> InvokeDeviceMethod)
-> Lens
InvokeDeviceMethod
InvokeDeviceMethod
(Maybe DeviceMethod)
(Maybe DeviceMethod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeDeviceMethod' {Maybe DeviceMethod
deviceMethod :: Maybe DeviceMethod
$sel:deviceMethod:InvokeDeviceMethod' :: InvokeDeviceMethod -> Maybe DeviceMethod
deviceMethod} -> Maybe DeviceMethod
deviceMethod) (\s :: InvokeDeviceMethod
s@InvokeDeviceMethod' {} Maybe DeviceMethod
a -> InvokeDeviceMethod
s {$sel:deviceMethod:InvokeDeviceMethod' :: Maybe DeviceMethod
deviceMethod = Maybe DeviceMethod
a} :: InvokeDeviceMethod)
invokeDeviceMethod_deviceId :: Lens.Lens' InvokeDeviceMethod Prelude.Text
invokeDeviceMethod_deviceId :: (Text -> f Text) -> InvokeDeviceMethod -> f InvokeDeviceMethod
invokeDeviceMethod_deviceId = (InvokeDeviceMethod -> Text)
-> (InvokeDeviceMethod -> Text -> InvokeDeviceMethod)
-> Lens InvokeDeviceMethod InvokeDeviceMethod Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeDeviceMethod' {Text
deviceId :: Text
$sel:deviceId:InvokeDeviceMethod' :: InvokeDeviceMethod -> Text
deviceId} -> Text
deviceId) (\s :: InvokeDeviceMethod
s@InvokeDeviceMethod' {} Text
a -> InvokeDeviceMethod
s {$sel:deviceId:InvokeDeviceMethod' :: Text
deviceId = Text
a} :: InvokeDeviceMethod)
instance Core.AWSRequest InvokeDeviceMethod where
type
AWSResponse InvokeDeviceMethod =
InvokeDeviceMethodResponse
request :: InvokeDeviceMethod -> Request InvokeDeviceMethod
request = Service -> InvokeDeviceMethod -> Request InvokeDeviceMethod
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy InvokeDeviceMethod
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InvokeDeviceMethod)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse InvokeDeviceMethod))
-> Logger
-> Service
-> Proxy InvokeDeviceMethod
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InvokeDeviceMethod)))
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 Text -> Int -> InvokeDeviceMethodResponse
InvokeDeviceMethodResponse'
(Maybe Text -> Int -> InvokeDeviceMethodResponse)
-> Either String (Maybe Text)
-> Either String (Int -> InvokeDeviceMethodResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deviceMethodResponse")
Either String (Int -> InvokeDeviceMethodResponse)
-> Either String Int -> Either String InvokeDeviceMethodResponse
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 InvokeDeviceMethod
instance Prelude.NFData InvokeDeviceMethod
instance Core.ToHeaders InvokeDeviceMethod where
toHeaders :: InvokeDeviceMethod -> ResponseHeaders
toHeaders =
ResponseHeaders -> InvokeDeviceMethod -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 InvokeDeviceMethod where
toJSON :: InvokeDeviceMethod -> Value
toJSON InvokeDeviceMethod' {Maybe Text
Maybe DeviceMethod
Text
deviceId :: Text
deviceMethod :: Maybe DeviceMethod
deviceMethodParameters :: Maybe Text
$sel:deviceId:InvokeDeviceMethod' :: InvokeDeviceMethod -> Text
$sel:deviceMethod:InvokeDeviceMethod' :: InvokeDeviceMethod -> Maybe DeviceMethod
$sel:deviceMethodParameters:InvokeDeviceMethod' :: InvokeDeviceMethod -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"deviceMethodParameters" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deviceMethodParameters,
(Text
"deviceMethod" Text -> DeviceMethod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DeviceMethod -> Pair) -> Maybe DeviceMethod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DeviceMethod
deviceMethod
]
)
instance Core.ToPath InvokeDeviceMethod where
toPath :: InvokeDeviceMethod -> ByteString
toPath InvokeDeviceMethod' {Maybe Text
Maybe DeviceMethod
Text
deviceId :: Text
deviceMethod :: Maybe DeviceMethod
deviceMethodParameters :: Maybe Text
$sel:deviceId:InvokeDeviceMethod' :: InvokeDeviceMethod -> Text
$sel:deviceMethod:InvokeDeviceMethod' :: InvokeDeviceMethod -> Maybe DeviceMethod
$sel:deviceMethodParameters:InvokeDeviceMethod' :: InvokeDeviceMethod -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/devices/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
deviceId, ByteString
"/methods"]
instance Core.ToQuery InvokeDeviceMethod where
toQuery :: InvokeDeviceMethod -> QueryString
toQuery = QueryString -> InvokeDeviceMethod -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data InvokeDeviceMethodResponse = InvokeDeviceMethodResponse'
{
InvokeDeviceMethodResponse -> Maybe Text
deviceMethodResponse :: Prelude.Maybe Prelude.Text,
InvokeDeviceMethodResponse -> Int
httpStatus :: Prelude.Int
}
deriving (InvokeDeviceMethodResponse -> InvokeDeviceMethodResponse -> Bool
(InvokeDeviceMethodResponse -> InvokeDeviceMethodResponse -> Bool)
-> (InvokeDeviceMethodResponse
-> InvokeDeviceMethodResponse -> Bool)
-> Eq InvokeDeviceMethodResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InvokeDeviceMethodResponse -> InvokeDeviceMethodResponse -> Bool
$c/= :: InvokeDeviceMethodResponse -> InvokeDeviceMethodResponse -> Bool
== :: InvokeDeviceMethodResponse -> InvokeDeviceMethodResponse -> Bool
$c== :: InvokeDeviceMethodResponse -> InvokeDeviceMethodResponse -> Bool
Prelude.Eq, ReadPrec [InvokeDeviceMethodResponse]
ReadPrec InvokeDeviceMethodResponse
Int -> ReadS InvokeDeviceMethodResponse
ReadS [InvokeDeviceMethodResponse]
(Int -> ReadS InvokeDeviceMethodResponse)
-> ReadS [InvokeDeviceMethodResponse]
-> ReadPrec InvokeDeviceMethodResponse
-> ReadPrec [InvokeDeviceMethodResponse]
-> Read InvokeDeviceMethodResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InvokeDeviceMethodResponse]
$creadListPrec :: ReadPrec [InvokeDeviceMethodResponse]
readPrec :: ReadPrec InvokeDeviceMethodResponse
$creadPrec :: ReadPrec InvokeDeviceMethodResponse
readList :: ReadS [InvokeDeviceMethodResponse]
$creadList :: ReadS [InvokeDeviceMethodResponse]
readsPrec :: Int -> ReadS InvokeDeviceMethodResponse
$creadsPrec :: Int -> ReadS InvokeDeviceMethodResponse
Prelude.Read, Int -> InvokeDeviceMethodResponse -> ShowS
[InvokeDeviceMethodResponse] -> ShowS
InvokeDeviceMethodResponse -> String
(Int -> InvokeDeviceMethodResponse -> ShowS)
-> (InvokeDeviceMethodResponse -> String)
-> ([InvokeDeviceMethodResponse] -> ShowS)
-> Show InvokeDeviceMethodResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InvokeDeviceMethodResponse] -> ShowS
$cshowList :: [InvokeDeviceMethodResponse] -> ShowS
show :: InvokeDeviceMethodResponse -> String
$cshow :: InvokeDeviceMethodResponse -> String
showsPrec :: Int -> InvokeDeviceMethodResponse -> ShowS
$cshowsPrec :: Int -> InvokeDeviceMethodResponse -> ShowS
Prelude.Show, (forall x.
InvokeDeviceMethodResponse -> Rep InvokeDeviceMethodResponse x)
-> (forall x.
Rep InvokeDeviceMethodResponse x -> InvokeDeviceMethodResponse)
-> Generic InvokeDeviceMethodResponse
forall x.
Rep InvokeDeviceMethodResponse x -> InvokeDeviceMethodResponse
forall x.
InvokeDeviceMethodResponse -> Rep InvokeDeviceMethodResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InvokeDeviceMethodResponse x -> InvokeDeviceMethodResponse
$cfrom :: forall x.
InvokeDeviceMethodResponse -> Rep InvokeDeviceMethodResponse x
Prelude.Generic)
newInvokeDeviceMethodResponse ::
Prelude.Int ->
InvokeDeviceMethodResponse
newInvokeDeviceMethodResponse :: Int -> InvokeDeviceMethodResponse
newInvokeDeviceMethodResponse Int
pHttpStatus_ =
InvokeDeviceMethodResponse' :: Maybe Text -> Int -> InvokeDeviceMethodResponse
InvokeDeviceMethodResponse'
{ $sel:deviceMethodResponse:InvokeDeviceMethodResponse' :: Maybe Text
deviceMethodResponse =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:InvokeDeviceMethodResponse' :: Int
httpStatus = Int
pHttpStatus_
}
invokeDeviceMethodResponse_deviceMethodResponse :: Lens.Lens' InvokeDeviceMethodResponse (Prelude.Maybe Prelude.Text)
invokeDeviceMethodResponse_deviceMethodResponse :: (Maybe Text -> f (Maybe Text))
-> InvokeDeviceMethodResponse -> f InvokeDeviceMethodResponse
invokeDeviceMethodResponse_deviceMethodResponse = (InvokeDeviceMethodResponse -> Maybe Text)
-> (InvokeDeviceMethodResponse
-> Maybe Text -> InvokeDeviceMethodResponse)
-> Lens
InvokeDeviceMethodResponse
InvokeDeviceMethodResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeDeviceMethodResponse' {Maybe Text
deviceMethodResponse :: Maybe Text
$sel:deviceMethodResponse:InvokeDeviceMethodResponse' :: InvokeDeviceMethodResponse -> Maybe Text
deviceMethodResponse} -> Maybe Text
deviceMethodResponse) (\s :: InvokeDeviceMethodResponse
s@InvokeDeviceMethodResponse' {} Maybe Text
a -> InvokeDeviceMethodResponse
s {$sel:deviceMethodResponse:InvokeDeviceMethodResponse' :: Maybe Text
deviceMethodResponse = Maybe Text
a} :: InvokeDeviceMethodResponse)
invokeDeviceMethodResponse_httpStatus :: Lens.Lens' InvokeDeviceMethodResponse Prelude.Int
invokeDeviceMethodResponse_httpStatus :: (Int -> f Int)
-> InvokeDeviceMethodResponse -> f InvokeDeviceMethodResponse
invokeDeviceMethodResponse_httpStatus = (InvokeDeviceMethodResponse -> Int)
-> (InvokeDeviceMethodResponse
-> Int -> InvokeDeviceMethodResponse)
-> Lens
InvokeDeviceMethodResponse InvokeDeviceMethodResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InvokeDeviceMethodResponse' {Int
httpStatus :: Int
$sel:httpStatus:InvokeDeviceMethodResponse' :: InvokeDeviceMethodResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: InvokeDeviceMethodResponse
s@InvokeDeviceMethodResponse' {} Int
a -> InvokeDeviceMethodResponse
s {$sel:httpStatus:InvokeDeviceMethodResponse' :: Int
httpStatus = Int
a} :: InvokeDeviceMethodResponse)
instance Prelude.NFData InvokeDeviceMethodResponse