{-# 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.IoT.UpdateThing
(
UpdateThing (..),
newUpdateThing,
updateThing_removeThingType,
updateThing_thingTypeName,
updateThing_expectedVersion,
updateThing_attributePayload,
updateThing_thingName,
UpdateThingResponse (..),
newUpdateThingResponse,
updateThingResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoT.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 UpdateThing = UpdateThing'
{
UpdateThing -> Maybe Bool
removeThingType :: Prelude.Maybe Prelude.Bool,
UpdateThing -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text,
UpdateThing -> Maybe Integer
expectedVersion :: Prelude.Maybe Prelude.Integer,
UpdateThing -> Maybe AttributePayload
attributePayload :: Prelude.Maybe AttributePayload,
UpdateThing -> Text
thingName :: Prelude.Text
}
deriving (UpdateThing -> UpdateThing -> Bool
(UpdateThing -> UpdateThing -> Bool)
-> (UpdateThing -> UpdateThing -> Bool) -> Eq UpdateThing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateThing -> UpdateThing -> Bool
$c/= :: UpdateThing -> UpdateThing -> Bool
== :: UpdateThing -> UpdateThing -> Bool
$c== :: UpdateThing -> UpdateThing -> Bool
Prelude.Eq, ReadPrec [UpdateThing]
ReadPrec UpdateThing
Int -> ReadS UpdateThing
ReadS [UpdateThing]
(Int -> ReadS UpdateThing)
-> ReadS [UpdateThing]
-> ReadPrec UpdateThing
-> ReadPrec [UpdateThing]
-> Read UpdateThing
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateThing]
$creadListPrec :: ReadPrec [UpdateThing]
readPrec :: ReadPrec UpdateThing
$creadPrec :: ReadPrec UpdateThing
readList :: ReadS [UpdateThing]
$creadList :: ReadS [UpdateThing]
readsPrec :: Int -> ReadS UpdateThing
$creadsPrec :: Int -> ReadS UpdateThing
Prelude.Read, Int -> UpdateThing -> ShowS
[UpdateThing] -> ShowS
UpdateThing -> String
(Int -> UpdateThing -> ShowS)
-> (UpdateThing -> String)
-> ([UpdateThing] -> ShowS)
-> Show UpdateThing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateThing] -> ShowS
$cshowList :: [UpdateThing] -> ShowS
show :: UpdateThing -> String
$cshow :: UpdateThing -> String
showsPrec :: Int -> UpdateThing -> ShowS
$cshowsPrec :: Int -> UpdateThing -> ShowS
Prelude.Show, (forall x. UpdateThing -> Rep UpdateThing x)
-> (forall x. Rep UpdateThing x -> UpdateThing)
-> Generic UpdateThing
forall x. Rep UpdateThing x -> UpdateThing
forall x. UpdateThing -> Rep UpdateThing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateThing x -> UpdateThing
$cfrom :: forall x. UpdateThing -> Rep UpdateThing x
Prelude.Generic)
newUpdateThing ::
Prelude.Text ->
UpdateThing
newUpdateThing :: Text -> UpdateThing
newUpdateThing Text
pThingName_ =
UpdateThing' :: Maybe Bool
-> Maybe Text
-> Maybe Integer
-> Maybe AttributePayload
-> Text
-> UpdateThing
UpdateThing'
{ $sel:removeThingType:UpdateThing' :: Maybe Bool
removeThingType = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:thingTypeName:UpdateThing' :: Maybe Text
thingTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:expectedVersion:UpdateThing' :: Maybe Integer
expectedVersion = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
$sel:attributePayload:UpdateThing' :: Maybe AttributePayload
attributePayload = Maybe AttributePayload
forall a. Maybe a
Prelude.Nothing,
$sel:thingName:UpdateThing' :: Text
thingName = Text
pThingName_
}
updateThing_removeThingType :: Lens.Lens' UpdateThing (Prelude.Maybe Prelude.Bool)
updateThing_removeThingType :: (Maybe Bool -> f (Maybe Bool)) -> UpdateThing -> f UpdateThing
updateThing_removeThingType = (UpdateThing -> Maybe Bool)
-> (UpdateThing -> Maybe Bool -> UpdateThing)
-> Lens UpdateThing UpdateThing (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateThing' {Maybe Bool
removeThingType :: Maybe Bool
$sel:removeThingType:UpdateThing' :: UpdateThing -> Maybe Bool
removeThingType} -> Maybe Bool
removeThingType) (\s :: UpdateThing
s@UpdateThing' {} Maybe Bool
a -> UpdateThing
s {$sel:removeThingType:UpdateThing' :: Maybe Bool
removeThingType = Maybe Bool
a} :: UpdateThing)
updateThing_thingTypeName :: Lens.Lens' UpdateThing (Prelude.Maybe Prelude.Text)
updateThing_thingTypeName :: (Maybe Text -> f (Maybe Text)) -> UpdateThing -> f UpdateThing
updateThing_thingTypeName = (UpdateThing -> Maybe Text)
-> (UpdateThing -> Maybe Text -> UpdateThing)
-> Lens UpdateThing UpdateThing (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateThing' {Maybe Text
thingTypeName :: Maybe Text
$sel:thingTypeName:UpdateThing' :: UpdateThing -> Maybe Text
thingTypeName} -> Maybe Text
thingTypeName) (\s :: UpdateThing
s@UpdateThing' {} Maybe Text
a -> UpdateThing
s {$sel:thingTypeName:UpdateThing' :: Maybe Text
thingTypeName = Maybe Text
a} :: UpdateThing)
updateThing_expectedVersion :: Lens.Lens' UpdateThing (Prelude.Maybe Prelude.Integer)
updateThing_expectedVersion :: (Maybe Integer -> f (Maybe Integer))
-> UpdateThing -> f UpdateThing
updateThing_expectedVersion = (UpdateThing -> Maybe Integer)
-> (UpdateThing -> Maybe Integer -> UpdateThing)
-> Lens UpdateThing UpdateThing (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateThing' {Maybe Integer
expectedVersion :: Maybe Integer
$sel:expectedVersion:UpdateThing' :: UpdateThing -> Maybe Integer
expectedVersion} -> Maybe Integer
expectedVersion) (\s :: UpdateThing
s@UpdateThing' {} Maybe Integer
a -> UpdateThing
s {$sel:expectedVersion:UpdateThing' :: Maybe Integer
expectedVersion = Maybe Integer
a} :: UpdateThing)
updateThing_attributePayload :: Lens.Lens' UpdateThing (Prelude.Maybe AttributePayload)
updateThing_attributePayload :: (Maybe AttributePayload -> f (Maybe AttributePayload))
-> UpdateThing -> f UpdateThing
updateThing_attributePayload = (UpdateThing -> Maybe AttributePayload)
-> (UpdateThing -> Maybe AttributePayload -> UpdateThing)
-> Lens
UpdateThing
UpdateThing
(Maybe AttributePayload)
(Maybe AttributePayload)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateThing' {Maybe AttributePayload
attributePayload :: Maybe AttributePayload
$sel:attributePayload:UpdateThing' :: UpdateThing -> Maybe AttributePayload
attributePayload} -> Maybe AttributePayload
attributePayload) (\s :: UpdateThing
s@UpdateThing' {} Maybe AttributePayload
a -> UpdateThing
s {$sel:attributePayload:UpdateThing' :: Maybe AttributePayload
attributePayload = Maybe AttributePayload
a} :: UpdateThing)
updateThing_thingName :: Lens.Lens' UpdateThing Prelude.Text
updateThing_thingName :: (Text -> f Text) -> UpdateThing -> f UpdateThing
updateThing_thingName = (UpdateThing -> Text)
-> (UpdateThing -> Text -> UpdateThing)
-> Lens UpdateThing UpdateThing Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateThing' {Text
thingName :: Text
$sel:thingName:UpdateThing' :: UpdateThing -> Text
thingName} -> Text
thingName) (\s :: UpdateThing
s@UpdateThing' {} Text
a -> UpdateThing
s {$sel:thingName:UpdateThing' :: Text
thingName = Text
a} :: UpdateThing)
instance Core.AWSRequest UpdateThing where
type AWSResponse UpdateThing = UpdateThingResponse
request :: UpdateThing -> Request UpdateThing
request = Service -> UpdateThing -> Request UpdateThing
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdateThing
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateThing)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse UpdateThing))
-> Logger
-> Service
-> Proxy UpdateThing
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateThing)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> UpdateThingResponse
UpdateThingResponse'
(Int -> UpdateThingResponse)
-> Either String Int -> Either String UpdateThingResponse
forall (f :: * -> *) a b. Functor 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 UpdateThing
instance Prelude.NFData UpdateThing
instance Core.ToHeaders UpdateThing where
toHeaders :: UpdateThing -> ResponseHeaders
toHeaders = ResponseHeaders -> UpdateThing -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON UpdateThing where
toJSON :: UpdateThing -> Value
toJSON UpdateThing' {Maybe Bool
Maybe Integer
Maybe Text
Maybe AttributePayload
Text
thingName :: Text
attributePayload :: Maybe AttributePayload
expectedVersion :: Maybe Integer
thingTypeName :: Maybe Text
removeThingType :: Maybe Bool
$sel:thingName:UpdateThing' :: UpdateThing -> Text
$sel:attributePayload:UpdateThing' :: UpdateThing -> Maybe AttributePayload
$sel:expectedVersion:UpdateThing' :: UpdateThing -> Maybe Integer
$sel:thingTypeName:UpdateThing' :: UpdateThing -> Maybe Text
$sel:removeThingType:UpdateThing' :: UpdateThing -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"removeThingType" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
removeThingType,
(Text
"thingTypeName" 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
thingTypeName,
(Text
"expectedVersion" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
expectedVersion,
(Text
"attributePayload" Text -> AttributePayload -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(AttributePayload -> Pair) -> Maybe AttributePayload -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributePayload
attributePayload
]
)
instance Core.ToPath UpdateThing where
toPath :: UpdateThing -> ByteString
toPath UpdateThing' {Maybe Bool
Maybe Integer
Maybe Text
Maybe AttributePayload
Text
thingName :: Text
attributePayload :: Maybe AttributePayload
expectedVersion :: Maybe Integer
thingTypeName :: Maybe Text
removeThingType :: Maybe Bool
$sel:thingName:UpdateThing' :: UpdateThing -> Text
$sel:attributePayload:UpdateThing' :: UpdateThing -> Maybe AttributePayload
$sel:expectedVersion:UpdateThing' :: UpdateThing -> Maybe Integer
$sel:thingTypeName:UpdateThing' :: UpdateThing -> Maybe Text
$sel:removeThingType:UpdateThing' :: UpdateThing -> Maybe Bool
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/things/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
thingName]
instance Core.ToQuery UpdateThing where
toQuery :: UpdateThing -> QueryString
toQuery = QueryString -> UpdateThing -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdateThingResponse = UpdateThingResponse'
{
UpdateThingResponse -> Int
httpStatus :: Prelude.Int
}
deriving (UpdateThingResponse -> UpdateThingResponse -> Bool
(UpdateThingResponse -> UpdateThingResponse -> Bool)
-> (UpdateThingResponse -> UpdateThingResponse -> Bool)
-> Eq UpdateThingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateThingResponse -> UpdateThingResponse -> Bool
$c/= :: UpdateThingResponse -> UpdateThingResponse -> Bool
== :: UpdateThingResponse -> UpdateThingResponse -> Bool
$c== :: UpdateThingResponse -> UpdateThingResponse -> Bool
Prelude.Eq, ReadPrec [UpdateThingResponse]
ReadPrec UpdateThingResponse
Int -> ReadS UpdateThingResponse
ReadS [UpdateThingResponse]
(Int -> ReadS UpdateThingResponse)
-> ReadS [UpdateThingResponse]
-> ReadPrec UpdateThingResponse
-> ReadPrec [UpdateThingResponse]
-> Read UpdateThingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateThingResponse]
$creadListPrec :: ReadPrec [UpdateThingResponse]
readPrec :: ReadPrec UpdateThingResponse
$creadPrec :: ReadPrec UpdateThingResponse
readList :: ReadS [UpdateThingResponse]
$creadList :: ReadS [UpdateThingResponse]
readsPrec :: Int -> ReadS UpdateThingResponse
$creadsPrec :: Int -> ReadS UpdateThingResponse
Prelude.Read, Int -> UpdateThingResponse -> ShowS
[UpdateThingResponse] -> ShowS
UpdateThingResponse -> String
(Int -> UpdateThingResponse -> ShowS)
-> (UpdateThingResponse -> String)
-> ([UpdateThingResponse] -> ShowS)
-> Show UpdateThingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateThingResponse] -> ShowS
$cshowList :: [UpdateThingResponse] -> ShowS
show :: UpdateThingResponse -> String
$cshow :: UpdateThingResponse -> String
showsPrec :: Int -> UpdateThingResponse -> ShowS
$cshowsPrec :: Int -> UpdateThingResponse -> ShowS
Prelude.Show, (forall x. UpdateThingResponse -> Rep UpdateThingResponse x)
-> (forall x. Rep UpdateThingResponse x -> UpdateThingResponse)
-> Generic UpdateThingResponse
forall x. Rep UpdateThingResponse x -> UpdateThingResponse
forall x. UpdateThingResponse -> Rep UpdateThingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateThingResponse x -> UpdateThingResponse
$cfrom :: forall x. UpdateThingResponse -> Rep UpdateThingResponse x
Prelude.Generic)
newUpdateThingResponse ::
Prelude.Int ->
UpdateThingResponse
newUpdateThingResponse :: Int -> UpdateThingResponse
newUpdateThingResponse Int
pHttpStatus_ =
UpdateThingResponse' :: Int -> UpdateThingResponse
UpdateThingResponse' {$sel:httpStatus:UpdateThingResponse' :: Int
httpStatus = Int
pHttpStatus_}
updateThingResponse_httpStatus :: Lens.Lens' UpdateThingResponse Prelude.Int
updateThingResponse_httpStatus :: (Int -> f Int) -> UpdateThingResponse -> f UpdateThingResponse
updateThingResponse_httpStatus = (UpdateThingResponse -> Int)
-> (UpdateThingResponse -> Int -> UpdateThingResponse)
-> Lens UpdateThingResponse UpdateThingResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateThingResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateThingResponse' :: UpdateThingResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateThingResponse
s@UpdateThingResponse' {} Int
a -> UpdateThingResponse
s {$sel:httpStatus:UpdateThingResponse' :: Int
httpStatus = Int
a} :: UpdateThingResponse)
instance Prelude.NFData UpdateThingResponse