{-# 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.UpdateDeviceState
(
UpdateDeviceState (..),
newUpdateDeviceState,
updateDeviceState_enabled,
updateDeviceState_deviceId,
UpdateDeviceStateResponse (..),
newUpdateDeviceStateResponse,
updateDeviceStateResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT1ClickDevices.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data UpdateDeviceState = UpdateDeviceState'
{
UpdateDeviceState -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
UpdateDeviceState -> Text
deviceId :: Prelude.Text
}
deriving (UpdateDeviceState -> UpdateDeviceState -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDeviceState -> UpdateDeviceState -> Bool
$c/= :: UpdateDeviceState -> UpdateDeviceState -> Bool
== :: UpdateDeviceState -> UpdateDeviceState -> Bool
$c== :: UpdateDeviceState -> UpdateDeviceState -> Bool
Prelude.Eq, ReadPrec [UpdateDeviceState]
ReadPrec UpdateDeviceState
Int -> ReadS UpdateDeviceState
ReadS [UpdateDeviceState]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDeviceState]
$creadListPrec :: ReadPrec [UpdateDeviceState]
readPrec :: ReadPrec UpdateDeviceState
$creadPrec :: ReadPrec UpdateDeviceState
readList :: ReadS [UpdateDeviceState]
$creadList :: ReadS [UpdateDeviceState]
readsPrec :: Int -> ReadS UpdateDeviceState
$creadsPrec :: Int -> ReadS UpdateDeviceState
Prelude.Read, Int -> UpdateDeviceState -> ShowS
[UpdateDeviceState] -> ShowS
UpdateDeviceState -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDeviceState] -> ShowS
$cshowList :: [UpdateDeviceState] -> ShowS
show :: UpdateDeviceState -> String
$cshow :: UpdateDeviceState -> String
showsPrec :: Int -> UpdateDeviceState -> ShowS
$cshowsPrec :: Int -> UpdateDeviceState -> ShowS
Prelude.Show, forall x. Rep UpdateDeviceState x -> UpdateDeviceState
forall x. UpdateDeviceState -> Rep UpdateDeviceState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDeviceState x -> UpdateDeviceState
$cfrom :: forall x. UpdateDeviceState -> Rep UpdateDeviceState x
Prelude.Generic)
newUpdateDeviceState ::
Prelude.Text ->
UpdateDeviceState
newUpdateDeviceState :: Text -> UpdateDeviceState
newUpdateDeviceState Text
pDeviceId_ =
UpdateDeviceState'
{ $sel:enabled:UpdateDeviceState' :: Maybe Bool
enabled = forall a. Maybe a
Prelude.Nothing,
$sel:deviceId:UpdateDeviceState' :: Text
deviceId = Text
pDeviceId_
}
updateDeviceState_enabled :: Lens.Lens' UpdateDeviceState (Prelude.Maybe Prelude.Bool)
updateDeviceState_enabled :: Lens' UpdateDeviceState (Maybe Bool)
updateDeviceState_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeviceState' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:UpdateDeviceState' :: UpdateDeviceState -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: UpdateDeviceState
s@UpdateDeviceState' {} Maybe Bool
a -> UpdateDeviceState
s {$sel:enabled:UpdateDeviceState' :: Maybe Bool
enabled = Maybe Bool
a} :: UpdateDeviceState)
updateDeviceState_deviceId :: Lens.Lens' UpdateDeviceState Prelude.Text
updateDeviceState_deviceId :: Lens' UpdateDeviceState Text
updateDeviceState_deviceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeviceState' {Text
deviceId :: Text
$sel:deviceId:UpdateDeviceState' :: UpdateDeviceState -> Text
deviceId} -> Text
deviceId) (\s :: UpdateDeviceState
s@UpdateDeviceState' {} Text
a -> UpdateDeviceState
s {$sel:deviceId:UpdateDeviceState' :: Text
deviceId = Text
a} :: UpdateDeviceState)
instance Core.AWSRequest UpdateDeviceState where
type
AWSResponse UpdateDeviceState =
UpdateDeviceStateResponse
request :: (Service -> Service)
-> UpdateDeviceState -> Request UpdateDeviceState
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateDeviceState
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse UpdateDeviceState)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> UpdateDeviceStateResponse
UpdateDeviceStateResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable UpdateDeviceState where
hashWithSalt :: Int -> UpdateDeviceState -> Int
hashWithSalt Int
_salt UpdateDeviceState' {Maybe Bool
Text
deviceId :: Text
enabled :: Maybe Bool
$sel:deviceId:UpdateDeviceState' :: UpdateDeviceState -> Text
$sel:enabled:UpdateDeviceState' :: UpdateDeviceState -> Maybe Bool
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enabled
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
deviceId
instance Prelude.NFData UpdateDeviceState where
rnf :: UpdateDeviceState -> ()
rnf UpdateDeviceState' {Maybe Bool
Text
deviceId :: Text
enabled :: Maybe Bool
$sel:deviceId:UpdateDeviceState' :: UpdateDeviceState -> Text
$sel:enabled:UpdateDeviceState' :: UpdateDeviceState -> Maybe Bool
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enabled
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
deviceId
instance Data.ToHeaders UpdateDeviceState where
toHeaders :: UpdateDeviceState -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON UpdateDeviceState where
toJSON :: UpdateDeviceState -> Value
toJSON UpdateDeviceState' {Maybe Bool
Text
deviceId :: Text
enabled :: Maybe Bool
$sel:deviceId:UpdateDeviceState' :: UpdateDeviceState -> Text
$sel:enabled:UpdateDeviceState' :: UpdateDeviceState -> Maybe Bool
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Key
"enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled]
)
instance Data.ToPath UpdateDeviceState where
toPath :: UpdateDeviceState -> ByteString
toPath UpdateDeviceState' {Maybe Bool
Text
deviceId :: Text
enabled :: Maybe Bool
$sel:deviceId:UpdateDeviceState' :: UpdateDeviceState -> Text
$sel:enabled:UpdateDeviceState' :: UpdateDeviceState -> Maybe Bool
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/devices/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
deviceId, ByteString
"/state"]
instance Data.ToQuery UpdateDeviceState where
toQuery :: UpdateDeviceState -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data UpdateDeviceStateResponse = UpdateDeviceStateResponse'
{
UpdateDeviceStateResponse -> Int
httpStatus :: Prelude.Int
}
deriving (UpdateDeviceStateResponse -> UpdateDeviceStateResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDeviceStateResponse -> UpdateDeviceStateResponse -> Bool
$c/= :: UpdateDeviceStateResponse -> UpdateDeviceStateResponse -> Bool
== :: UpdateDeviceStateResponse -> UpdateDeviceStateResponse -> Bool
$c== :: UpdateDeviceStateResponse -> UpdateDeviceStateResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDeviceStateResponse]
ReadPrec UpdateDeviceStateResponse
Int -> ReadS UpdateDeviceStateResponse
ReadS [UpdateDeviceStateResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDeviceStateResponse]
$creadListPrec :: ReadPrec [UpdateDeviceStateResponse]
readPrec :: ReadPrec UpdateDeviceStateResponse
$creadPrec :: ReadPrec UpdateDeviceStateResponse
readList :: ReadS [UpdateDeviceStateResponse]
$creadList :: ReadS [UpdateDeviceStateResponse]
readsPrec :: Int -> ReadS UpdateDeviceStateResponse
$creadsPrec :: Int -> ReadS UpdateDeviceStateResponse
Prelude.Read, Int -> UpdateDeviceStateResponse -> ShowS
[UpdateDeviceStateResponse] -> ShowS
UpdateDeviceStateResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDeviceStateResponse] -> ShowS
$cshowList :: [UpdateDeviceStateResponse] -> ShowS
show :: UpdateDeviceStateResponse -> String
$cshow :: UpdateDeviceStateResponse -> String
showsPrec :: Int -> UpdateDeviceStateResponse -> ShowS
$cshowsPrec :: Int -> UpdateDeviceStateResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateDeviceStateResponse x -> UpdateDeviceStateResponse
forall x.
UpdateDeviceStateResponse -> Rep UpdateDeviceStateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDeviceStateResponse x -> UpdateDeviceStateResponse
$cfrom :: forall x.
UpdateDeviceStateResponse -> Rep UpdateDeviceStateResponse x
Prelude.Generic)
newUpdateDeviceStateResponse ::
Prelude.Int ->
UpdateDeviceStateResponse
newUpdateDeviceStateResponse :: Int -> UpdateDeviceStateResponse
newUpdateDeviceStateResponse Int
pHttpStatus_ =
UpdateDeviceStateResponse'
{ $sel:httpStatus:UpdateDeviceStateResponse' :: Int
httpStatus =
Int
pHttpStatus_
}
updateDeviceStateResponse_httpStatus :: Lens.Lens' UpdateDeviceStateResponse Prelude.Int
updateDeviceStateResponse_httpStatus :: Lens' UpdateDeviceStateResponse Int
updateDeviceStateResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDeviceStateResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateDeviceStateResponse' :: UpdateDeviceStateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateDeviceStateResponse
s@UpdateDeviceStateResponse' {} Int
a -> UpdateDeviceStateResponse
s {$sel:httpStatus:UpdateDeviceStateResponse' :: Int
httpStatus = Int
a} :: UpdateDeviceStateResponse)
instance Prelude.NFData UpdateDeviceStateResponse where
rnf :: UpdateDeviceStateResponse -> ()
rnf UpdateDeviceStateResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateDeviceStateResponse' :: UpdateDeviceStateResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus