{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoT.Types
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
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]
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
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. 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' {$sel:thingTypeName:DeleteThingType' :: Text
thingTypeName = Text
pThingTypeName_}

-- | The name of the thing type.
deleteThingType_thingTypeName :: Lens.Lens' DeleteThingType Prelude.Text
deleteThingType_thingTypeName :: Lens' DeleteThingType Text
deleteThingType_thingTypeName = 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 :: (Service -> Service) -> DeleteThingType -> Request DeleteThingType
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteThingType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteThingType)))
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 -> DeleteThingTypeResponse
DeleteThingTypeResponse'
            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 DeleteThingType where
  hashWithSalt :: Int -> DeleteThingType -> Int
hashWithSalt Int
_salt DeleteThingType' {Text
thingTypeName :: Text
$sel:thingTypeName:DeleteThingType' :: DeleteThingType -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thingTypeName

instance Prelude.NFData DeleteThingType where
  rnf :: DeleteThingType -> ()
rnf DeleteThingType' {Text
thingTypeName :: Text
$sel:thingTypeName:DeleteThingType' :: DeleteThingType -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
thingTypeName

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

instance Data.ToPath DeleteThingType where
  toPath :: DeleteThingType -> ByteString
toPath DeleteThingType' {Text
thingTypeName :: Text
$sel:thingTypeName:DeleteThingType' :: DeleteThingType -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/thing-types/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
thingTypeName]

instance Data.ToQuery DeleteThingType where
  toQuery :: DeleteThingType -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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' {$sel:httpStatus:DeleteThingTypeResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteThingTypeResponse_httpStatus :: Lens.Lens' DeleteThingTypeResponse Prelude.Int
deleteThingTypeResponse_httpStatus :: Lens' DeleteThingTypeResponse Int
deleteThingTypeResponse_httpStatus = 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 where
  rnf :: DeleteThingTypeResponse -> ()
rnf DeleteThingTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteThingTypeResponse' :: DeleteThingTypeResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus