{-# 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.CreateThing
(
CreateThing (..),
newCreateThing,
createThing_thingTypeName,
createThing_attributePayload,
createThing_billingGroupName,
createThing_thingName,
CreateThingResponse (..),
newCreateThingResponse,
createThingResponse_thingArn,
createThingResponse_thingName,
createThingResponse_thingId,
createThingResponse_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 CreateThing = CreateThing'
{
CreateThing -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text,
CreateThing -> Maybe AttributePayload
attributePayload :: Prelude.Maybe AttributePayload,
CreateThing -> Maybe Text
billingGroupName :: Prelude.Maybe Prelude.Text,
CreateThing -> Text
thingName :: Prelude.Text
}
deriving (CreateThing -> CreateThing -> Bool
(CreateThing -> CreateThing -> Bool)
-> (CreateThing -> CreateThing -> Bool) -> Eq CreateThing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateThing -> CreateThing -> Bool
$c/= :: CreateThing -> CreateThing -> Bool
== :: CreateThing -> CreateThing -> Bool
$c== :: CreateThing -> CreateThing -> Bool
Prelude.Eq, ReadPrec [CreateThing]
ReadPrec CreateThing
Int -> ReadS CreateThing
ReadS [CreateThing]
(Int -> ReadS CreateThing)
-> ReadS [CreateThing]
-> ReadPrec CreateThing
-> ReadPrec [CreateThing]
-> Read CreateThing
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateThing]
$creadListPrec :: ReadPrec [CreateThing]
readPrec :: ReadPrec CreateThing
$creadPrec :: ReadPrec CreateThing
readList :: ReadS [CreateThing]
$creadList :: ReadS [CreateThing]
readsPrec :: Int -> ReadS CreateThing
$creadsPrec :: Int -> ReadS CreateThing
Prelude.Read, Int -> CreateThing -> ShowS
[CreateThing] -> ShowS
CreateThing -> String
(Int -> CreateThing -> ShowS)
-> (CreateThing -> String)
-> ([CreateThing] -> ShowS)
-> Show CreateThing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateThing] -> ShowS
$cshowList :: [CreateThing] -> ShowS
show :: CreateThing -> String
$cshow :: CreateThing -> String
showsPrec :: Int -> CreateThing -> ShowS
$cshowsPrec :: Int -> CreateThing -> ShowS
Prelude.Show, (forall x. CreateThing -> Rep CreateThing x)
-> (forall x. Rep CreateThing x -> CreateThing)
-> Generic CreateThing
forall x. Rep CreateThing x -> CreateThing
forall x. CreateThing -> Rep CreateThing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateThing x -> CreateThing
$cfrom :: forall x. CreateThing -> Rep CreateThing x
Prelude.Generic)
newCreateThing ::
Prelude.Text ->
CreateThing
newCreateThing :: Text -> CreateThing
newCreateThing Text
pThingName_ =
CreateThing' :: Maybe Text
-> Maybe AttributePayload -> Maybe Text -> Text -> CreateThing
CreateThing'
{ $sel:thingTypeName:CreateThing' :: Maybe Text
thingTypeName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:attributePayload:CreateThing' :: Maybe AttributePayload
attributePayload = Maybe AttributePayload
forall a. Maybe a
Prelude.Nothing,
$sel:billingGroupName:CreateThing' :: Maybe Text
billingGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:thingName:CreateThing' :: Text
thingName = Text
pThingName_
}
createThing_thingTypeName :: Lens.Lens' CreateThing (Prelude.Maybe Prelude.Text)
createThing_thingTypeName :: (Maybe Text -> f (Maybe Text)) -> CreateThing -> f CreateThing
createThing_thingTypeName = (CreateThing -> Maybe Text)
-> (CreateThing -> Maybe Text -> CreateThing)
-> Lens CreateThing CreateThing (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThing' {Maybe Text
thingTypeName :: Maybe Text
$sel:thingTypeName:CreateThing' :: CreateThing -> Maybe Text
thingTypeName} -> Maybe Text
thingTypeName) (\s :: CreateThing
s@CreateThing' {} Maybe Text
a -> CreateThing
s {$sel:thingTypeName:CreateThing' :: Maybe Text
thingTypeName = Maybe Text
a} :: CreateThing)
createThing_attributePayload :: Lens.Lens' CreateThing (Prelude.Maybe AttributePayload)
createThing_attributePayload :: (Maybe AttributePayload -> f (Maybe AttributePayload))
-> CreateThing -> f CreateThing
createThing_attributePayload = (CreateThing -> Maybe AttributePayload)
-> (CreateThing -> Maybe AttributePayload -> CreateThing)
-> Lens
CreateThing
CreateThing
(Maybe AttributePayload)
(Maybe AttributePayload)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThing' {Maybe AttributePayload
attributePayload :: Maybe AttributePayload
$sel:attributePayload:CreateThing' :: CreateThing -> Maybe AttributePayload
attributePayload} -> Maybe AttributePayload
attributePayload) (\s :: CreateThing
s@CreateThing' {} Maybe AttributePayload
a -> CreateThing
s {$sel:attributePayload:CreateThing' :: Maybe AttributePayload
attributePayload = Maybe AttributePayload
a} :: CreateThing)
createThing_billingGroupName :: Lens.Lens' CreateThing (Prelude.Maybe Prelude.Text)
createThing_billingGroupName :: (Maybe Text -> f (Maybe Text)) -> CreateThing -> f CreateThing
createThing_billingGroupName = (CreateThing -> Maybe Text)
-> (CreateThing -> Maybe Text -> CreateThing)
-> Lens CreateThing CreateThing (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThing' {Maybe Text
billingGroupName :: Maybe Text
$sel:billingGroupName:CreateThing' :: CreateThing -> Maybe Text
billingGroupName} -> Maybe Text
billingGroupName) (\s :: CreateThing
s@CreateThing' {} Maybe Text
a -> CreateThing
s {$sel:billingGroupName:CreateThing' :: Maybe Text
billingGroupName = Maybe Text
a} :: CreateThing)
createThing_thingName :: Lens.Lens' CreateThing Prelude.Text
createThing_thingName :: (Text -> f Text) -> CreateThing -> f CreateThing
createThing_thingName = (CreateThing -> Text)
-> (CreateThing -> Text -> CreateThing)
-> Lens CreateThing CreateThing Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThing' {Text
thingName :: Text
$sel:thingName:CreateThing' :: CreateThing -> Text
thingName} -> Text
thingName) (\s :: CreateThing
s@CreateThing' {} Text
a -> CreateThing
s {$sel:thingName:CreateThing' :: Text
thingName = Text
a} :: CreateThing)
instance Core.AWSRequest CreateThing where
type AWSResponse CreateThing = CreateThingResponse
request :: CreateThing -> Request CreateThing
request = Service -> CreateThing -> Request CreateThing
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateThing
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateThing)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateThing))
-> Logger
-> Service
-> Proxy CreateThing
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateThing)))
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
-> Maybe Text -> Maybe Text -> Int -> CreateThingResponse
CreateThingResponse'
(Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CreateThingResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> Int -> CreateThingResponse)
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
"thingArn")
Either
String (Maybe Text -> Maybe Text -> Int -> CreateThingResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateThingResponse)
forall (f :: * -> *) a b. Applicative f => 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
"thingName")
Either String (Maybe Text -> Int -> CreateThingResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateThingResponse)
forall (f :: * -> *) a b. Applicative f => 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
"thingId")
Either String (Int -> CreateThingResponse)
-> Either String Int -> Either String CreateThingResponse
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 CreateThing
instance Prelude.NFData CreateThing
instance Core.ToHeaders CreateThing where
toHeaders :: CreateThing -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateThing -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateThing where
toJSON :: CreateThing -> Value
toJSON CreateThing' {Maybe Text
Maybe AttributePayload
Text
thingName :: Text
billingGroupName :: Maybe Text
attributePayload :: Maybe AttributePayload
thingTypeName :: Maybe Text
$sel:thingName:CreateThing' :: CreateThing -> Text
$sel:billingGroupName:CreateThing' :: CreateThing -> Maybe Text
$sel:attributePayload:CreateThing' :: CreateThing -> Maybe AttributePayload
$sel:thingTypeName:CreateThing' :: CreateThing -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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
"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,
(Text
"billingGroupName" 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
billingGroupName
]
)
instance Core.ToPath CreateThing where
toPath :: CreateThing -> ByteString
toPath CreateThing' {Maybe Text
Maybe AttributePayload
Text
thingName :: Text
billingGroupName :: Maybe Text
attributePayload :: Maybe AttributePayload
thingTypeName :: Maybe Text
$sel:thingName:CreateThing' :: CreateThing -> Text
$sel:billingGroupName:CreateThing' :: CreateThing -> Maybe Text
$sel:attributePayload:CreateThing' :: CreateThing -> Maybe AttributePayload
$sel:thingTypeName:CreateThing' :: CreateThing -> Maybe Text
..} =
[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 CreateThing where
toQuery :: CreateThing -> QueryString
toQuery = QueryString -> CreateThing -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateThingResponse = CreateThingResponse'
{
CreateThingResponse -> Maybe Text
thingArn :: Prelude.Maybe Prelude.Text,
CreateThingResponse -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text,
CreateThingResponse -> Maybe Text
thingId :: Prelude.Maybe Prelude.Text,
CreateThingResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateThingResponse -> CreateThingResponse -> Bool
(CreateThingResponse -> CreateThingResponse -> Bool)
-> (CreateThingResponse -> CreateThingResponse -> Bool)
-> Eq CreateThingResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateThingResponse -> CreateThingResponse -> Bool
$c/= :: CreateThingResponse -> CreateThingResponse -> Bool
== :: CreateThingResponse -> CreateThingResponse -> Bool
$c== :: CreateThingResponse -> CreateThingResponse -> Bool
Prelude.Eq, ReadPrec [CreateThingResponse]
ReadPrec CreateThingResponse
Int -> ReadS CreateThingResponse
ReadS [CreateThingResponse]
(Int -> ReadS CreateThingResponse)
-> ReadS [CreateThingResponse]
-> ReadPrec CreateThingResponse
-> ReadPrec [CreateThingResponse]
-> Read CreateThingResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateThingResponse]
$creadListPrec :: ReadPrec [CreateThingResponse]
readPrec :: ReadPrec CreateThingResponse
$creadPrec :: ReadPrec CreateThingResponse
readList :: ReadS [CreateThingResponse]
$creadList :: ReadS [CreateThingResponse]
readsPrec :: Int -> ReadS CreateThingResponse
$creadsPrec :: Int -> ReadS CreateThingResponse
Prelude.Read, Int -> CreateThingResponse -> ShowS
[CreateThingResponse] -> ShowS
CreateThingResponse -> String
(Int -> CreateThingResponse -> ShowS)
-> (CreateThingResponse -> String)
-> ([CreateThingResponse] -> ShowS)
-> Show CreateThingResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateThingResponse] -> ShowS
$cshowList :: [CreateThingResponse] -> ShowS
show :: CreateThingResponse -> String
$cshow :: CreateThingResponse -> String
showsPrec :: Int -> CreateThingResponse -> ShowS
$cshowsPrec :: Int -> CreateThingResponse -> ShowS
Prelude.Show, (forall x. CreateThingResponse -> Rep CreateThingResponse x)
-> (forall x. Rep CreateThingResponse x -> CreateThingResponse)
-> Generic CreateThingResponse
forall x. Rep CreateThingResponse x -> CreateThingResponse
forall x. CreateThingResponse -> Rep CreateThingResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateThingResponse x -> CreateThingResponse
$cfrom :: forall x. CreateThingResponse -> Rep CreateThingResponse x
Prelude.Generic)
newCreateThingResponse ::
Prelude.Int ->
CreateThingResponse
newCreateThingResponse :: Int -> CreateThingResponse
newCreateThingResponse Int
pHttpStatus_ =
CreateThingResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CreateThingResponse
CreateThingResponse'
{ $sel:thingArn:CreateThingResponse' :: Maybe Text
thingArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:thingName:CreateThingResponse' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:thingId:CreateThingResponse' :: Maybe Text
thingId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateThingResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createThingResponse_thingArn :: Lens.Lens' CreateThingResponse (Prelude.Maybe Prelude.Text)
createThingResponse_thingArn :: (Maybe Text -> f (Maybe Text))
-> CreateThingResponse -> f CreateThingResponse
createThingResponse_thingArn = (CreateThingResponse -> Maybe Text)
-> (CreateThingResponse -> Maybe Text -> CreateThingResponse)
-> Lens
CreateThingResponse CreateThingResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingResponse' {Maybe Text
thingArn :: Maybe Text
$sel:thingArn:CreateThingResponse' :: CreateThingResponse -> Maybe Text
thingArn} -> Maybe Text
thingArn) (\s :: CreateThingResponse
s@CreateThingResponse' {} Maybe Text
a -> CreateThingResponse
s {$sel:thingArn:CreateThingResponse' :: Maybe Text
thingArn = Maybe Text
a} :: CreateThingResponse)
createThingResponse_thingName :: Lens.Lens' CreateThingResponse (Prelude.Maybe Prelude.Text)
createThingResponse_thingName :: (Maybe Text -> f (Maybe Text))
-> CreateThingResponse -> f CreateThingResponse
createThingResponse_thingName = (CreateThingResponse -> Maybe Text)
-> (CreateThingResponse -> Maybe Text -> CreateThingResponse)
-> Lens
CreateThingResponse CreateThingResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingResponse' {Maybe Text
thingName :: Maybe Text
$sel:thingName:CreateThingResponse' :: CreateThingResponse -> Maybe Text
thingName} -> Maybe Text
thingName) (\s :: CreateThingResponse
s@CreateThingResponse' {} Maybe Text
a -> CreateThingResponse
s {$sel:thingName:CreateThingResponse' :: Maybe Text
thingName = Maybe Text
a} :: CreateThingResponse)
createThingResponse_thingId :: Lens.Lens' CreateThingResponse (Prelude.Maybe Prelude.Text)
createThingResponse_thingId :: (Maybe Text -> f (Maybe Text))
-> CreateThingResponse -> f CreateThingResponse
createThingResponse_thingId = (CreateThingResponse -> Maybe Text)
-> (CreateThingResponse -> Maybe Text -> CreateThingResponse)
-> Lens
CreateThingResponse CreateThingResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingResponse' {Maybe Text
thingId :: Maybe Text
$sel:thingId:CreateThingResponse' :: CreateThingResponse -> Maybe Text
thingId} -> Maybe Text
thingId) (\s :: CreateThingResponse
s@CreateThingResponse' {} Maybe Text
a -> CreateThingResponse
s {$sel:thingId:CreateThingResponse' :: Maybe Text
thingId = Maybe Text
a} :: CreateThingResponse)
createThingResponse_httpStatus :: Lens.Lens' CreateThingResponse Prelude.Int
createThingResponse_httpStatus :: (Int -> f Int) -> CreateThingResponse -> f CreateThingResponse
createThingResponse_httpStatus = (CreateThingResponse -> Int)
-> (CreateThingResponse -> Int -> CreateThingResponse)
-> Lens CreateThingResponse CreateThingResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateThingResponse' :: CreateThingResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateThingResponse
s@CreateThingResponse' {} Int
a -> CreateThingResponse
s {$sel:httpStatus:CreateThingResponse' :: Int
httpStatus = Int
a} :: CreateThingResponse)
instance Prelude.NFData CreateThingResponse