{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoT.DeleteThingType
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified thing type. You cannot delete a thing type if it
-- has things associated with it. To delete a thing type, first mark it as
-- deprecated by calling DeprecateThingType, then remove any associated
-- things by calling UpdateThing to change the thing type on any associated
-- thing, and finally use DeleteThingType to delete the thing type.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DeleteThingType>
-- action.
module Amazonka.IoT.DeleteThingType
  ( -- * Creating a Request
    DeleteThingType (..),
    newDeleteThingType,

    -- * Request Lenses
    deleteThingType_thingTypeName,

    -- * Destructuring the Response
    DeleteThingTypeResponse (..),
    newDeleteThingTypeResponse,

    -- * Response Lenses
    deleteThingTypeResponse_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

-- | The input for the DeleteThingType operation.
--
-- /See:/ 'newDeleteThingType' smart constructor.
data DeleteThingType = DeleteThingType'
  { -- | The name of the thing type.
    DeleteThingType -> Text
thingTypeName :: Prelude.Text
  }
  deriving (DeleteThingType -> DeleteThingType -> Bool
(DeleteThingType -> DeleteThingType -> Bool)
-> (DeleteThingType -> DeleteThingType -> Bool)
-> Eq DeleteThingType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteThingType -> DeleteThingType -> Bool
$c/= :: DeleteThingType -> DeleteThingType -> Bool
== :: DeleteThingType -> DeleteThingType -> Bool
$c== :: DeleteThingType -> DeleteThingType -> Bool
Prelude.Eq, ReadPrec [DeleteThingType]
ReadPrec DeleteThingType
Int -> ReadS DeleteThingType
ReadS [DeleteThingType]
(Int -> ReadS DeleteThingType)
-> ReadS [DeleteThingType]
-> ReadPrec DeleteThingType
-> ReadPrec [DeleteThingType]
-> Read DeleteThingType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteThingType]
$creadListPrec :: ReadPrec [DeleteThingType]
readPrec :: ReadPrec DeleteThingType
$creadPrec :: ReadPrec DeleteThingType
readList :: ReadS [DeleteThingType]
$creadList :: ReadS [DeleteThingType]
readsPrec :: Int -> ReadS DeleteThingType
$creadsPrec :: Int -> ReadS DeleteThingType
Prelude.Read, Int -> DeleteThingType -> ShowS
[DeleteThingType] -> ShowS
DeleteThingType -> String
(Int -> DeleteThingType -> ShowS)
-> (DeleteThingType -> String)
-> ([DeleteThingType] -> ShowS)
-> Show DeleteThingType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteThingType] -> ShowS
$cshowList :: [DeleteThingType] -> ShowS
show :: DeleteThingType -> String
$cshow :: DeleteThingType -> String
showsPrec :: Int -> DeleteThingType -> ShowS
$cshowsPrec :: Int -> DeleteThingType -> ShowS
Prelude.Show, (forall x. DeleteThingType -> Rep DeleteThingType x)
-> (forall x. Rep DeleteThingType x -> DeleteThingType)
-> Generic DeleteThingType
forall x. Rep DeleteThingType x -> DeleteThingType
forall x. DeleteThingType -> Rep DeleteThingType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteThingType x -> DeleteThingType
$cfrom :: forall x. DeleteThingType -> Rep DeleteThingType x
Prelude.Generic)

-- |
-- Create a value of 'DeleteThingType' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'thingTypeName', 'deleteThingType_thingTypeName' - The name of the thing type.
newDeleteThingType ::
  -- | 'thingTypeName'
  Prelude.Text ->
  DeleteThingType
newDeleteThingType :: Text -> DeleteThingType
newDeleteThingType Text
pThingTypeName_ =
  DeleteThingType' :: Text -> DeleteThingType
DeleteThingType' {$sel:thingTypeName:DeleteThingType' :: Text
thingTypeName = Text
pThingTypeName_}

-- | The name of the thing type.
deleteThingType_thingTypeName :: Lens.Lens' DeleteThingType Prelude.Text
deleteThingType_thingTypeName :: (Text -> f Text) -> DeleteThingType -> f DeleteThingType
deleteThingType_thingTypeName = (DeleteThingType -> Text)
-> (DeleteThingType -> Text -> DeleteThingType)
-> Lens DeleteThingType DeleteThingType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteThingType' {Text
thingTypeName :: Text
$sel:thingTypeName:DeleteThingType' :: DeleteThingType -> Text
thingTypeName} -> Text
thingTypeName) (\s :: DeleteThingType
s@DeleteThingType' {} Text
a -> DeleteThingType
s {$sel:thingTypeName:DeleteThingType' :: Text
thingTypeName = Text
a} :: DeleteThingType)

instance Core.AWSRequest DeleteThingType where
  type
    AWSResponse DeleteThingType =
      DeleteThingTypeResponse
  request :: DeleteThingType -> Request DeleteThingType
request = Service -> DeleteThingType -> Request DeleteThingType
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteThingType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteThingType)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteThingType))
-> Logger
-> Service
-> Proxy DeleteThingType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteThingType)))
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 -> DeleteThingTypeResponse
DeleteThingTypeResponse'
            (Int -> DeleteThingTypeResponse)
-> Either String Int -> Either String DeleteThingTypeResponse
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 DeleteThingType

instance Prelude.NFData DeleteThingType

instance Core.ToHeaders DeleteThingType where
  toHeaders :: DeleteThingType -> ResponseHeaders
toHeaders = ResponseHeaders -> DeleteThingType -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DeleteThingType where
  toPath :: DeleteThingType -> ByteString
toPath DeleteThingType' {Text
thingTypeName :: Text
$sel:thingTypeName:DeleteThingType' :: DeleteThingType -> Text
..} =
    [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 DeleteThingType where
  toQuery :: DeleteThingType -> QueryString
toQuery = QueryString -> DeleteThingType -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | The output for the DeleteThingType operation.
--
-- /See:/ 'newDeleteThingTypeResponse' smart constructor.
data DeleteThingTypeResponse = DeleteThingTypeResponse'
  { -- | The response's http status code.
    DeleteThingTypeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteThingTypeResponse -> DeleteThingTypeResponse -> Bool
(DeleteThingTypeResponse -> DeleteThingTypeResponse -> Bool)
-> (DeleteThingTypeResponse -> DeleteThingTypeResponse -> Bool)
-> Eq DeleteThingTypeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteThingTypeResponse -> DeleteThingTypeResponse -> Bool
$c/= :: DeleteThingTypeResponse -> DeleteThingTypeResponse -> Bool
== :: DeleteThingTypeResponse -> DeleteThingTypeResponse -> Bool
$c== :: DeleteThingTypeResponse -> DeleteThingTypeResponse -> Bool
Prelude.Eq, ReadPrec [DeleteThingTypeResponse]
ReadPrec DeleteThingTypeResponse
Int -> ReadS DeleteThingTypeResponse
ReadS [DeleteThingTypeResponse]
(Int -> ReadS DeleteThingTypeResponse)
-> ReadS [DeleteThingTypeResponse]
-> ReadPrec DeleteThingTypeResponse
-> ReadPrec [DeleteThingTypeResponse]
-> Read DeleteThingTypeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteThingTypeResponse]
$creadListPrec :: ReadPrec [DeleteThingTypeResponse]
readPrec :: ReadPrec DeleteThingTypeResponse
$creadPrec :: ReadPrec DeleteThingTypeResponse
readList :: ReadS [DeleteThingTypeResponse]
$creadList :: ReadS [DeleteThingTypeResponse]
readsPrec :: Int -> ReadS DeleteThingTypeResponse
$creadsPrec :: Int -> ReadS DeleteThingTypeResponse
Prelude.Read, Int -> DeleteThingTypeResponse -> ShowS
[DeleteThingTypeResponse] -> ShowS
DeleteThingTypeResponse -> String
(Int -> DeleteThingTypeResponse -> ShowS)
-> (DeleteThingTypeResponse -> String)
-> ([DeleteThingTypeResponse] -> ShowS)
-> Show DeleteThingTypeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteThingTypeResponse] -> ShowS
$cshowList :: [DeleteThingTypeResponse] -> ShowS
show :: DeleteThingTypeResponse -> String
$cshow :: DeleteThingTypeResponse -> String
showsPrec :: Int -> DeleteThingTypeResponse -> ShowS
$cshowsPrec :: Int -> DeleteThingTypeResponse -> ShowS
Prelude.Show, (forall x.
 DeleteThingTypeResponse -> Rep DeleteThingTypeResponse x)
-> (forall x.
    Rep DeleteThingTypeResponse x -> DeleteThingTypeResponse)
-> Generic DeleteThingTypeResponse
forall x. Rep DeleteThingTypeResponse x -> DeleteThingTypeResponse
forall x. DeleteThingTypeResponse -> Rep DeleteThingTypeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteThingTypeResponse x -> DeleteThingTypeResponse
$cfrom :: forall x. DeleteThingTypeResponse -> Rep DeleteThingTypeResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteThingTypeResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'deleteThingTypeResponse_httpStatus' - The response's http status code.
newDeleteThingTypeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteThingTypeResponse
newDeleteThingTypeResponse :: Int -> DeleteThingTypeResponse
newDeleteThingTypeResponse Int
pHttpStatus_ =
  DeleteThingTypeResponse' :: Int -> DeleteThingTypeResponse
DeleteThingTypeResponse' {$sel:httpStatus:DeleteThingTypeResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteThingTypeResponse_httpStatus :: Lens.Lens' DeleteThingTypeResponse Prelude.Int
deleteThingTypeResponse_httpStatus :: (Int -> f Int)
-> DeleteThingTypeResponse -> f DeleteThingTypeResponse
deleteThingTypeResponse_httpStatus = (DeleteThingTypeResponse -> Int)
-> (DeleteThingTypeResponse -> Int -> DeleteThingTypeResponse)
-> Lens DeleteThingTypeResponse DeleteThingTypeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteThingTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteThingTypeResponse' :: DeleteThingTypeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteThingTypeResponse
s@DeleteThingTypeResponse' {} Int
a -> DeleteThingTypeResponse
s {$sel:httpStatus:DeleteThingTypeResponse' :: Int
httpStatus = Int
a} :: DeleteThingTypeResponse)

instance Prelude.NFData DeleteThingTypeResponse