{-# 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.CreateThingType
(
CreateThingType (..),
newCreateThingType,
createThingType_thingTypeProperties,
createThingType_tags,
createThingType_thingTypeName,
CreateThingTypeResponse (..),
newCreateThingTypeResponse,
createThingTypeResponse_thingTypeName,
createThingTypeResponse_thingTypeId,
createThingTypeResponse_thingTypeArn,
createThingTypeResponse_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 CreateThingType = CreateThingType'
{
CreateThingType -> Maybe ThingTypeProperties
thingTypeProperties :: Prelude.Maybe ThingTypeProperties,
CreateThingType -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateThingType -> Text
thingTypeName :: Prelude.Text
}
deriving (CreateThingType -> CreateThingType -> Bool
(CreateThingType -> CreateThingType -> Bool)
-> (CreateThingType -> CreateThingType -> Bool)
-> Eq CreateThingType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateThingType -> CreateThingType -> Bool
$c/= :: CreateThingType -> CreateThingType -> Bool
== :: CreateThingType -> CreateThingType -> Bool
$c== :: CreateThingType -> CreateThingType -> Bool
Prelude.Eq, ReadPrec [CreateThingType]
ReadPrec CreateThingType
Int -> ReadS CreateThingType
ReadS [CreateThingType]
(Int -> ReadS CreateThingType)
-> ReadS [CreateThingType]
-> ReadPrec CreateThingType
-> ReadPrec [CreateThingType]
-> Read CreateThingType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateThingType]
$creadListPrec :: ReadPrec [CreateThingType]
readPrec :: ReadPrec CreateThingType
$creadPrec :: ReadPrec CreateThingType
readList :: ReadS [CreateThingType]
$creadList :: ReadS [CreateThingType]
readsPrec :: Int -> ReadS CreateThingType
$creadsPrec :: Int -> ReadS CreateThingType
Prelude.Read, Int -> CreateThingType -> ShowS
[CreateThingType] -> ShowS
CreateThingType -> String
(Int -> CreateThingType -> ShowS)
-> (CreateThingType -> String)
-> ([CreateThingType] -> ShowS)
-> Show CreateThingType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateThingType] -> ShowS
$cshowList :: [CreateThingType] -> ShowS
show :: CreateThingType -> String
$cshow :: CreateThingType -> String
showsPrec :: Int -> CreateThingType -> ShowS
$cshowsPrec :: Int -> CreateThingType -> ShowS
Prelude.Show, (forall x. CreateThingType -> Rep CreateThingType x)
-> (forall x. Rep CreateThingType x -> CreateThingType)
-> Generic CreateThingType
forall x. Rep CreateThingType x -> CreateThingType
forall x. CreateThingType -> Rep CreateThingType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateThingType x -> CreateThingType
$cfrom :: forall x. CreateThingType -> Rep CreateThingType x
Prelude.Generic)
newCreateThingType ::
Prelude.Text ->
CreateThingType
newCreateThingType :: Text -> CreateThingType
newCreateThingType Text
pThingTypeName_ =
CreateThingType' :: Maybe ThingTypeProperties -> Maybe [Tag] -> Text -> CreateThingType
CreateThingType'
{ $sel:thingTypeProperties:CreateThingType' :: Maybe ThingTypeProperties
thingTypeProperties =
Maybe ThingTypeProperties
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateThingType' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:thingTypeName:CreateThingType' :: Text
thingTypeName = Text
pThingTypeName_
}
createThingType_thingTypeProperties :: Lens.Lens' CreateThingType (Prelude.Maybe ThingTypeProperties)
createThingType_thingTypeProperties :: (Maybe ThingTypeProperties -> f (Maybe ThingTypeProperties))
-> CreateThingType -> f CreateThingType
createThingType_thingTypeProperties = (CreateThingType -> Maybe ThingTypeProperties)
-> (CreateThingType
-> Maybe ThingTypeProperties -> CreateThingType)
-> Lens
CreateThingType
CreateThingType
(Maybe ThingTypeProperties)
(Maybe ThingTypeProperties)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingType' {Maybe ThingTypeProperties
thingTypeProperties :: Maybe ThingTypeProperties
$sel:thingTypeProperties:CreateThingType' :: CreateThingType -> Maybe ThingTypeProperties
thingTypeProperties} -> Maybe ThingTypeProperties
thingTypeProperties) (\s :: CreateThingType
s@CreateThingType' {} Maybe ThingTypeProperties
a -> CreateThingType
s {$sel:thingTypeProperties:CreateThingType' :: Maybe ThingTypeProperties
thingTypeProperties = Maybe ThingTypeProperties
a} :: CreateThingType)
createThingType_tags :: Lens.Lens' CreateThingType (Prelude.Maybe [Tag])
createThingType_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateThingType -> f CreateThingType
createThingType_tags = (CreateThingType -> Maybe [Tag])
-> (CreateThingType -> Maybe [Tag] -> CreateThingType)
-> Lens CreateThingType CreateThingType (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingType' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateThingType' :: CreateThingType -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateThingType
s@CreateThingType' {} Maybe [Tag]
a -> CreateThingType
s {$sel:tags:CreateThingType' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateThingType) ((Maybe [Tag] -> f (Maybe [Tag]))
-> CreateThingType -> f CreateThingType)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateThingType
-> f CreateThingType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createThingType_thingTypeName :: Lens.Lens' CreateThingType Prelude.Text
createThingType_thingTypeName :: (Text -> f Text) -> CreateThingType -> f CreateThingType
createThingType_thingTypeName = (CreateThingType -> Text)
-> (CreateThingType -> Text -> CreateThingType)
-> Lens CreateThingType CreateThingType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingType' {Text
thingTypeName :: Text
$sel:thingTypeName:CreateThingType' :: CreateThingType -> Text
thingTypeName} -> Text
thingTypeName) (\s :: CreateThingType
s@CreateThingType' {} Text
a -> CreateThingType
s {$sel:thingTypeName:CreateThingType' :: Text
thingTypeName = Text
a} :: CreateThingType)
instance Core.AWSRequest CreateThingType where
type
AWSResponse CreateThingType =
CreateThingTypeResponse
request :: CreateThingType -> Request CreateThingType
request = Service -> CreateThingType -> Request CreateThingType
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateThingType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateThingType)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateThingType))
-> Logger
-> Service
-> Proxy CreateThingType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateThingType)))
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 -> CreateThingTypeResponse
CreateThingTypeResponse'
(Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CreateThingTypeResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Text -> Maybe Text -> Int -> CreateThingTypeResponse)
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
"thingTypeName")
Either
String (Maybe Text -> Maybe Text -> Int -> CreateThingTypeResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateThingTypeResponse)
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
"thingTypeId")
Either String (Maybe Text -> Int -> CreateThingTypeResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateThingTypeResponse)
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
"thingTypeArn")
Either String (Int -> CreateThingTypeResponse)
-> Either String Int -> Either String CreateThingTypeResponse
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 CreateThingType
instance Prelude.NFData CreateThingType
instance Core.ToHeaders CreateThingType where
toHeaders :: CreateThingType -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateThingType -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToJSON CreateThingType where
toJSON :: CreateThingType -> Value
toJSON CreateThingType' {Maybe [Tag]
Maybe ThingTypeProperties
Text
thingTypeName :: Text
tags :: Maybe [Tag]
thingTypeProperties :: Maybe ThingTypeProperties
$sel:thingTypeName:CreateThingType' :: CreateThingType -> Text
$sel:tags:CreateThingType' :: CreateThingType -> Maybe [Tag]
$sel:thingTypeProperties:CreateThingType' :: CreateThingType -> Maybe ThingTypeProperties
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"thingTypeProperties" Text -> ThingTypeProperties -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(ThingTypeProperties -> Pair)
-> Maybe ThingTypeProperties -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ThingTypeProperties
thingTypeProperties,
(Text
"tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags
]
)
instance Core.ToPath CreateThingType where
toPath :: CreateThingType -> ByteString
toPath CreateThingType' {Maybe [Tag]
Maybe ThingTypeProperties
Text
thingTypeName :: Text
tags :: Maybe [Tag]
thingTypeProperties :: Maybe ThingTypeProperties
$sel:thingTypeName:CreateThingType' :: CreateThingType -> Text
$sel:tags:CreateThingType' :: CreateThingType -> Maybe [Tag]
$sel:thingTypeProperties:CreateThingType' :: CreateThingType -> Maybe ThingTypeProperties
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/thing-types/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
thingTypeName]
instance Core.ToQuery CreateThingType where
toQuery :: CreateThingType -> QueryString
toQuery = QueryString -> CreateThingType -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateThingTypeResponse = CreateThingTypeResponse'
{
CreateThingTypeResponse -> Maybe Text
thingTypeName :: Prelude.Maybe Prelude.Text,
CreateThingTypeResponse -> Maybe Text
thingTypeId :: Prelude.Maybe Prelude.Text,
CreateThingTypeResponse -> Maybe Text
thingTypeArn :: Prelude.Maybe Prelude.Text,
CreateThingTypeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateThingTypeResponse -> CreateThingTypeResponse -> Bool
(CreateThingTypeResponse -> CreateThingTypeResponse -> Bool)
-> (CreateThingTypeResponse -> CreateThingTypeResponse -> Bool)
-> Eq CreateThingTypeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateThingTypeResponse -> CreateThingTypeResponse -> Bool
$c/= :: CreateThingTypeResponse -> CreateThingTypeResponse -> Bool
== :: CreateThingTypeResponse -> CreateThingTypeResponse -> Bool
$c== :: CreateThingTypeResponse -> CreateThingTypeResponse -> Bool
Prelude.Eq, ReadPrec [CreateThingTypeResponse]
ReadPrec CreateThingTypeResponse
Int -> ReadS CreateThingTypeResponse
ReadS [CreateThingTypeResponse]
(Int -> ReadS CreateThingTypeResponse)
-> ReadS [CreateThingTypeResponse]
-> ReadPrec CreateThingTypeResponse
-> ReadPrec [CreateThingTypeResponse]
-> Read CreateThingTypeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateThingTypeResponse]
$creadListPrec :: ReadPrec [CreateThingTypeResponse]
readPrec :: ReadPrec CreateThingTypeResponse
$creadPrec :: ReadPrec CreateThingTypeResponse
readList :: ReadS [CreateThingTypeResponse]
$creadList :: ReadS [CreateThingTypeResponse]
readsPrec :: Int -> ReadS CreateThingTypeResponse
$creadsPrec :: Int -> ReadS CreateThingTypeResponse
Prelude.Read, Int -> CreateThingTypeResponse -> ShowS
[CreateThingTypeResponse] -> ShowS
CreateThingTypeResponse -> String
(Int -> CreateThingTypeResponse -> ShowS)
-> (CreateThingTypeResponse -> String)
-> ([CreateThingTypeResponse] -> ShowS)
-> Show CreateThingTypeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateThingTypeResponse] -> ShowS
$cshowList :: [CreateThingTypeResponse] -> ShowS
show :: CreateThingTypeResponse -> String
$cshow :: CreateThingTypeResponse -> String
showsPrec :: Int -> CreateThingTypeResponse -> ShowS
$cshowsPrec :: Int -> CreateThingTypeResponse -> ShowS
Prelude.Show, (forall x.
CreateThingTypeResponse -> Rep CreateThingTypeResponse x)
-> (forall x.
Rep CreateThingTypeResponse x -> CreateThingTypeResponse)
-> Generic CreateThingTypeResponse
forall x. Rep CreateThingTypeResponse x -> CreateThingTypeResponse
forall x. CreateThingTypeResponse -> Rep CreateThingTypeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateThingTypeResponse x -> CreateThingTypeResponse
$cfrom :: forall x. CreateThingTypeResponse -> Rep CreateThingTypeResponse x
Prelude.Generic)
newCreateThingTypeResponse ::
Prelude.Int ->
CreateThingTypeResponse
newCreateThingTypeResponse :: Int -> CreateThingTypeResponse
newCreateThingTypeResponse Int
pHttpStatus_ =
CreateThingTypeResponse' :: Maybe Text
-> Maybe Text -> Maybe Text -> Int -> CreateThingTypeResponse
CreateThingTypeResponse'
{ $sel:thingTypeName:CreateThingTypeResponse' :: Maybe Text
thingTypeName =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:thingTypeId:CreateThingTypeResponse' :: Maybe Text
thingTypeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:thingTypeArn:CreateThingTypeResponse' :: Maybe Text
thingTypeArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateThingTypeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createThingTypeResponse_thingTypeName :: Lens.Lens' CreateThingTypeResponse (Prelude.Maybe Prelude.Text)
createThingTypeResponse_thingTypeName :: (Maybe Text -> f (Maybe Text))
-> CreateThingTypeResponse -> f CreateThingTypeResponse
createThingTypeResponse_thingTypeName = (CreateThingTypeResponse -> Maybe Text)
-> (CreateThingTypeResponse
-> Maybe Text -> CreateThingTypeResponse)
-> Lens
CreateThingTypeResponse
CreateThingTypeResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingTypeResponse' {Maybe Text
thingTypeName :: Maybe Text
$sel:thingTypeName:CreateThingTypeResponse' :: CreateThingTypeResponse -> Maybe Text
thingTypeName} -> Maybe Text
thingTypeName) (\s :: CreateThingTypeResponse
s@CreateThingTypeResponse' {} Maybe Text
a -> CreateThingTypeResponse
s {$sel:thingTypeName:CreateThingTypeResponse' :: Maybe Text
thingTypeName = Maybe Text
a} :: CreateThingTypeResponse)
createThingTypeResponse_thingTypeId :: Lens.Lens' CreateThingTypeResponse (Prelude.Maybe Prelude.Text)
createThingTypeResponse_thingTypeId :: (Maybe Text -> f (Maybe Text))
-> CreateThingTypeResponse -> f CreateThingTypeResponse
createThingTypeResponse_thingTypeId = (CreateThingTypeResponse -> Maybe Text)
-> (CreateThingTypeResponse
-> Maybe Text -> CreateThingTypeResponse)
-> Lens
CreateThingTypeResponse
CreateThingTypeResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingTypeResponse' {Maybe Text
thingTypeId :: Maybe Text
$sel:thingTypeId:CreateThingTypeResponse' :: CreateThingTypeResponse -> Maybe Text
thingTypeId} -> Maybe Text
thingTypeId) (\s :: CreateThingTypeResponse
s@CreateThingTypeResponse' {} Maybe Text
a -> CreateThingTypeResponse
s {$sel:thingTypeId:CreateThingTypeResponse' :: Maybe Text
thingTypeId = Maybe Text
a} :: CreateThingTypeResponse)
createThingTypeResponse_thingTypeArn :: Lens.Lens' CreateThingTypeResponse (Prelude.Maybe Prelude.Text)
createThingTypeResponse_thingTypeArn :: (Maybe Text -> f (Maybe Text))
-> CreateThingTypeResponse -> f CreateThingTypeResponse
createThingTypeResponse_thingTypeArn = (CreateThingTypeResponse -> Maybe Text)
-> (CreateThingTypeResponse
-> Maybe Text -> CreateThingTypeResponse)
-> Lens
CreateThingTypeResponse
CreateThingTypeResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingTypeResponse' {Maybe Text
thingTypeArn :: Maybe Text
$sel:thingTypeArn:CreateThingTypeResponse' :: CreateThingTypeResponse -> Maybe Text
thingTypeArn} -> Maybe Text
thingTypeArn) (\s :: CreateThingTypeResponse
s@CreateThingTypeResponse' {} Maybe Text
a -> CreateThingTypeResponse
s {$sel:thingTypeArn:CreateThingTypeResponse' :: Maybe Text
thingTypeArn = Maybe Text
a} :: CreateThingTypeResponse)
createThingTypeResponse_httpStatus :: Lens.Lens' CreateThingTypeResponse Prelude.Int
createThingTypeResponse_httpStatus :: (Int -> f Int)
-> CreateThingTypeResponse -> f CreateThingTypeResponse
createThingTypeResponse_httpStatus = (CreateThingTypeResponse -> Int)
-> (CreateThingTypeResponse -> Int -> CreateThingTypeResponse)
-> Lens CreateThingTypeResponse CreateThingTypeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThingTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateThingTypeResponse' :: CreateThingTypeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateThingTypeResponse
s@CreateThingTypeResponse' {} Int
a -> CreateThingTypeResponse
s {$sel:httpStatus:CreateThingTypeResponse' :: Int
httpStatus = Int
a} :: CreateThingTypeResponse)
instance Prelude.NFData CreateThingTypeResponse