{-# 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.DescribeDevice
(
DescribeDevice (..),
newDescribeDevice,
describeDevice_deviceId,
DescribeDeviceResponse (..),
newDescribeDeviceResponse,
describeDeviceResponse_deviceDescription,
describeDeviceResponse_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 DescribeDevice = DescribeDevice'
{
DescribeDevice -> Text
deviceId :: Prelude.Text
}
deriving (DescribeDevice -> DescribeDevice -> Bool
(DescribeDevice -> DescribeDevice -> Bool)
-> (DescribeDevice -> DescribeDevice -> Bool) -> Eq DescribeDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDevice -> DescribeDevice -> Bool
$c/= :: DescribeDevice -> DescribeDevice -> Bool
== :: DescribeDevice -> DescribeDevice -> Bool
$c== :: DescribeDevice -> DescribeDevice -> Bool
Prelude.Eq, ReadPrec [DescribeDevice]
ReadPrec DescribeDevice
Int -> ReadS DescribeDevice
ReadS [DescribeDevice]
(Int -> ReadS DescribeDevice)
-> ReadS [DescribeDevice]
-> ReadPrec DescribeDevice
-> ReadPrec [DescribeDevice]
-> Read DescribeDevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDevice]
$creadListPrec :: ReadPrec [DescribeDevice]
readPrec :: ReadPrec DescribeDevice
$creadPrec :: ReadPrec DescribeDevice
readList :: ReadS [DescribeDevice]
$creadList :: ReadS [DescribeDevice]
readsPrec :: Int -> ReadS DescribeDevice
$creadsPrec :: Int -> ReadS DescribeDevice
Prelude.Read, Int -> DescribeDevice -> ShowS
[DescribeDevice] -> ShowS
DescribeDevice -> String
(Int -> DescribeDevice -> ShowS)
-> (DescribeDevice -> String)
-> ([DescribeDevice] -> ShowS)
-> Show DescribeDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDevice] -> ShowS
$cshowList :: [DescribeDevice] -> ShowS
show :: DescribeDevice -> String
$cshow :: DescribeDevice -> String
showsPrec :: Int -> DescribeDevice -> ShowS
$cshowsPrec :: Int -> DescribeDevice -> ShowS
Prelude.Show, (forall x. DescribeDevice -> Rep DescribeDevice x)
-> (forall x. Rep DescribeDevice x -> DescribeDevice)
-> Generic DescribeDevice
forall x. Rep DescribeDevice x -> DescribeDevice
forall x. DescribeDevice -> Rep DescribeDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeDevice x -> DescribeDevice
$cfrom :: forall x. DescribeDevice -> Rep DescribeDevice x
Prelude.Generic)
newDescribeDevice ::
Prelude.Text ->
DescribeDevice
newDescribeDevice :: Text -> DescribeDevice
newDescribeDevice Text
pDeviceId_ =
DescribeDevice' :: Text -> DescribeDevice
DescribeDevice' {$sel:deviceId:DescribeDevice' :: Text
deviceId = Text
pDeviceId_}
describeDevice_deviceId :: Lens.Lens' DescribeDevice Prelude.Text
describeDevice_deviceId :: (Text -> f Text) -> DescribeDevice -> f DescribeDevice
describeDevice_deviceId = (DescribeDevice -> Text)
-> (DescribeDevice -> Text -> DescribeDevice)
-> Lens DescribeDevice DescribeDevice Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDevice' {Text
deviceId :: Text
$sel:deviceId:DescribeDevice' :: DescribeDevice -> Text
deviceId} -> Text
deviceId) (\s :: DescribeDevice
s@DescribeDevice' {} Text
a -> DescribeDevice
s {$sel:deviceId:DescribeDevice' :: Text
deviceId = Text
a} :: DescribeDevice)
instance Core.AWSRequest DescribeDevice where
type
AWSResponse DescribeDevice =
DescribeDeviceResponse
request :: DescribeDevice -> Request DescribeDevice
request = Service -> DescribeDevice -> Request DescribeDevice
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy DescribeDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeDevice)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DescribeDevice))
-> Logger
-> Service
-> Proxy DescribeDevice
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeDevice)))
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 DeviceDescription -> Int -> DescribeDeviceResponse
DescribeDeviceResponse'
(Maybe DeviceDescription -> Int -> DescribeDeviceResponse)
-> Either String (Maybe DeviceDescription)
-> Either String (Int -> DescribeDeviceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DeviceDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deviceDescription")
Either String (Int -> DescribeDeviceResponse)
-> Either String Int -> Either String DescribeDeviceResponse
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 DescribeDevice
instance Prelude.NFData DescribeDevice
instance Core.ToHeaders DescribeDevice where
toHeaders :: DescribeDevice -> ResponseHeaders
toHeaders =
ResponseHeaders -> DescribeDevice -> 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.ToPath DescribeDevice where
toPath :: DescribeDevice -> ByteString
toPath DescribeDevice' {Text
deviceId :: Text
$sel:deviceId:DescribeDevice' :: DescribeDevice -> 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]
instance Core.ToQuery DescribeDevice where
toQuery :: DescribeDevice -> QueryString
toQuery = QueryString -> DescribeDevice -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DescribeDeviceResponse = DescribeDeviceResponse'
{
DescribeDeviceResponse -> Maybe DeviceDescription
deviceDescription :: Prelude.Maybe DeviceDescription,
DescribeDeviceResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DescribeDeviceResponse -> DescribeDeviceResponse -> Bool
(DescribeDeviceResponse -> DescribeDeviceResponse -> Bool)
-> (DescribeDeviceResponse -> DescribeDeviceResponse -> Bool)
-> Eq DescribeDeviceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDeviceResponse -> DescribeDeviceResponse -> Bool
$c/= :: DescribeDeviceResponse -> DescribeDeviceResponse -> Bool
== :: DescribeDeviceResponse -> DescribeDeviceResponse -> Bool
$c== :: DescribeDeviceResponse -> DescribeDeviceResponse -> Bool
Prelude.Eq, ReadPrec [DescribeDeviceResponse]
ReadPrec DescribeDeviceResponse
Int -> ReadS DescribeDeviceResponse
ReadS [DescribeDeviceResponse]
(Int -> ReadS DescribeDeviceResponse)
-> ReadS [DescribeDeviceResponse]
-> ReadPrec DescribeDeviceResponse
-> ReadPrec [DescribeDeviceResponse]
-> Read DescribeDeviceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDeviceResponse]
$creadListPrec :: ReadPrec [DescribeDeviceResponse]
readPrec :: ReadPrec DescribeDeviceResponse
$creadPrec :: ReadPrec DescribeDeviceResponse
readList :: ReadS [DescribeDeviceResponse]
$creadList :: ReadS [DescribeDeviceResponse]
readsPrec :: Int -> ReadS DescribeDeviceResponse
$creadsPrec :: Int -> ReadS DescribeDeviceResponse
Prelude.Read, Int -> DescribeDeviceResponse -> ShowS
[DescribeDeviceResponse] -> ShowS
DescribeDeviceResponse -> String
(Int -> DescribeDeviceResponse -> ShowS)
-> (DescribeDeviceResponse -> String)
-> ([DescribeDeviceResponse] -> ShowS)
-> Show DescribeDeviceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDeviceResponse] -> ShowS
$cshowList :: [DescribeDeviceResponse] -> ShowS
show :: DescribeDeviceResponse -> String
$cshow :: DescribeDeviceResponse -> String
showsPrec :: Int -> DescribeDeviceResponse -> ShowS
$cshowsPrec :: Int -> DescribeDeviceResponse -> ShowS
Prelude.Show, (forall x. DescribeDeviceResponse -> Rep DescribeDeviceResponse x)
-> (forall x.
Rep DescribeDeviceResponse x -> DescribeDeviceResponse)
-> Generic DescribeDeviceResponse
forall x. Rep DescribeDeviceResponse x -> DescribeDeviceResponse
forall x. DescribeDeviceResponse -> Rep DescribeDeviceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeDeviceResponse x -> DescribeDeviceResponse
$cfrom :: forall x. DescribeDeviceResponse -> Rep DescribeDeviceResponse x
Prelude.Generic)
newDescribeDeviceResponse ::
Prelude.Int ->
DescribeDeviceResponse
newDescribeDeviceResponse :: Int -> DescribeDeviceResponse
newDescribeDeviceResponse Int
pHttpStatus_ =
DescribeDeviceResponse' :: Maybe DeviceDescription -> Int -> DescribeDeviceResponse
DescribeDeviceResponse'
{ $sel:deviceDescription:DescribeDeviceResponse' :: Maybe DeviceDescription
deviceDescription =
Maybe DeviceDescription
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeDeviceResponse' :: Int
httpStatus = Int
pHttpStatus_
}
describeDeviceResponse_deviceDescription :: Lens.Lens' DescribeDeviceResponse (Prelude.Maybe DeviceDescription)
describeDeviceResponse_deviceDescription :: (Maybe DeviceDescription -> f (Maybe DeviceDescription))
-> DescribeDeviceResponse -> f DescribeDeviceResponse
describeDeviceResponse_deviceDescription = (DescribeDeviceResponse -> Maybe DeviceDescription)
-> (DescribeDeviceResponse
-> Maybe DeviceDescription -> DescribeDeviceResponse)
-> Lens
DescribeDeviceResponse
DescribeDeviceResponse
(Maybe DeviceDescription)
(Maybe DeviceDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDeviceResponse' {Maybe DeviceDescription
deviceDescription :: Maybe DeviceDescription
$sel:deviceDescription:DescribeDeviceResponse' :: DescribeDeviceResponse -> Maybe DeviceDescription
deviceDescription} -> Maybe DeviceDescription
deviceDescription) (\s :: DescribeDeviceResponse
s@DescribeDeviceResponse' {} Maybe DeviceDescription
a -> DescribeDeviceResponse
s {$sel:deviceDescription:DescribeDeviceResponse' :: Maybe DeviceDescription
deviceDescription = Maybe DeviceDescription
a} :: DescribeDeviceResponse)
describeDeviceResponse_httpStatus :: Lens.Lens' DescribeDeviceResponse Prelude.Int
describeDeviceResponse_httpStatus :: (Int -> f Int)
-> DescribeDeviceResponse -> f DescribeDeviceResponse
describeDeviceResponse_httpStatus = (DescribeDeviceResponse -> Int)
-> (DescribeDeviceResponse -> Int -> DescribeDeviceResponse)
-> Lens DescribeDeviceResponse DescribeDeviceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDeviceResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeDeviceResponse' :: DescribeDeviceResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeDeviceResponse
s@DescribeDeviceResponse' {} Int
a -> DescribeDeviceResponse
s {$sel:httpStatus:DescribeDeviceResponse' :: Int
httpStatus = Int
a} :: DescribeDeviceResponse)
instance Prelude.NFData DescribeDeviceResponse