{-# 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.DeprecateThingType
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deprecates a thing type. You can not associate new things with
-- deprecated thing type.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DeprecateThingType>
-- action.
module Amazonka.IoT.DeprecateThingType
  ( -- * Creating a Request
    DeprecateThingType (..),
    newDeprecateThingType,

    -- * Request Lenses
    deprecateThingType_undoDeprecate,
    deprecateThingType_thingTypeName,

    -- * Destructuring the Response
    DeprecateThingTypeResponse (..),
    newDeprecateThingTypeResponse,

    -- * Response Lenses
    deprecateThingTypeResponse_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 DeprecateThingType operation.
--
-- /See:/ 'newDeprecateThingType' smart constructor.
data DeprecateThingType = DeprecateThingType'
  { -- | Whether to undeprecate a deprecated thing type. If __true__, the thing
    -- type will not be deprecated anymore and you can associate it with
    -- things.
    DeprecateThingType -> Maybe Bool
undoDeprecate :: Prelude.Maybe Prelude.Bool,
    -- | The name of the thing type to deprecate.
    DeprecateThingType -> Text
thingTypeName :: Prelude.Text
  }
  deriving (DeprecateThingType -> DeprecateThingType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeprecateThingType -> DeprecateThingType -> Bool
$c/= :: DeprecateThingType -> DeprecateThingType -> Bool
== :: DeprecateThingType -> DeprecateThingType -> Bool
$c== :: DeprecateThingType -> DeprecateThingType -> Bool
Prelude.Eq, ReadPrec [DeprecateThingType]
ReadPrec DeprecateThingType
Int -> ReadS DeprecateThingType
ReadS [DeprecateThingType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeprecateThingType]
$creadListPrec :: ReadPrec [DeprecateThingType]
readPrec :: ReadPrec DeprecateThingType
$creadPrec :: ReadPrec DeprecateThingType
readList :: ReadS [DeprecateThingType]
$creadList :: ReadS [DeprecateThingType]
readsPrec :: Int -> ReadS DeprecateThingType
$creadsPrec :: Int -> ReadS DeprecateThingType
Prelude.Read, Int -> DeprecateThingType -> ShowS
[DeprecateThingType] -> ShowS
DeprecateThingType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeprecateThingType] -> ShowS
$cshowList :: [DeprecateThingType] -> ShowS
show :: DeprecateThingType -> String
$cshow :: DeprecateThingType -> String
showsPrec :: Int -> DeprecateThingType -> ShowS
$cshowsPrec :: Int -> DeprecateThingType -> ShowS
Prelude.Show, forall x. Rep DeprecateThingType x -> DeprecateThingType
forall x. DeprecateThingType -> Rep DeprecateThingType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeprecateThingType x -> DeprecateThingType
$cfrom :: forall x. DeprecateThingType -> Rep DeprecateThingType x
Prelude.Generic)

-- |
-- Create a value of 'DeprecateThingType' 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:
--
-- 'undoDeprecate', 'deprecateThingType_undoDeprecate' - Whether to undeprecate a deprecated thing type. If __true__, the thing
-- type will not be deprecated anymore and you can associate it with
-- things.
--
-- 'thingTypeName', 'deprecateThingType_thingTypeName' - The name of the thing type to deprecate.
newDeprecateThingType ::
  -- | 'thingTypeName'
  Prelude.Text ->
  DeprecateThingType
newDeprecateThingType :: Text -> DeprecateThingType
newDeprecateThingType Text
pThingTypeName_ =
  DeprecateThingType'
    { $sel:undoDeprecate:DeprecateThingType' :: Maybe Bool
undoDeprecate =
        forall a. Maybe a
Prelude.Nothing,
      $sel:thingTypeName:DeprecateThingType' :: Text
thingTypeName = Text
pThingTypeName_
    }

-- | Whether to undeprecate a deprecated thing type. If __true__, the thing
-- type will not be deprecated anymore and you can associate it with
-- things.
deprecateThingType_undoDeprecate :: Lens.Lens' DeprecateThingType (Prelude.Maybe Prelude.Bool)
deprecateThingType_undoDeprecate :: Lens' DeprecateThingType (Maybe Bool)
deprecateThingType_undoDeprecate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeprecateThingType' {Maybe Bool
undoDeprecate :: Maybe Bool
$sel:undoDeprecate:DeprecateThingType' :: DeprecateThingType -> Maybe Bool
undoDeprecate} -> Maybe Bool
undoDeprecate) (\s :: DeprecateThingType
s@DeprecateThingType' {} Maybe Bool
a -> DeprecateThingType
s {$sel:undoDeprecate:DeprecateThingType' :: Maybe Bool
undoDeprecate = Maybe Bool
a} :: DeprecateThingType)

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

instance Core.AWSRequest DeprecateThingType where
  type
    AWSResponse DeprecateThingType =
      DeprecateThingTypeResponse
  request :: (Service -> Service)
-> DeprecateThingType -> Request DeprecateThingType
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeprecateThingType
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeprecateThingType)))
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 -> DeprecateThingTypeResponse
DeprecateThingTypeResponse'
            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 DeprecateThingType where
  hashWithSalt :: Int -> DeprecateThingType -> Int
hashWithSalt Int
_salt DeprecateThingType' {Maybe Bool
Text
thingTypeName :: Text
undoDeprecate :: Maybe Bool
$sel:thingTypeName:DeprecateThingType' :: DeprecateThingType -> Text
$sel:undoDeprecate:DeprecateThingType' :: DeprecateThingType -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
undoDeprecate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thingTypeName

instance Prelude.NFData DeprecateThingType where
  rnf :: DeprecateThingType -> ()
rnf DeprecateThingType' {Maybe Bool
Text
thingTypeName :: Text
undoDeprecate :: Maybe Bool
$sel:thingTypeName:DeprecateThingType' :: DeprecateThingType -> Text
$sel:undoDeprecate:DeprecateThingType' :: DeprecateThingType -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
undoDeprecate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
thingTypeName

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

instance Data.ToJSON DeprecateThingType where
  toJSON :: DeprecateThingType -> Value
toJSON DeprecateThingType' {Maybe Bool
Text
thingTypeName :: Text
undoDeprecate :: Maybe Bool
$sel:thingTypeName:DeprecateThingType' :: DeprecateThingType -> Text
$sel:undoDeprecate:DeprecateThingType' :: DeprecateThingType -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"undoDeprecate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
undoDeprecate
          ]
      )

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

instance Data.ToQuery DeprecateThingType where
  toQuery :: DeprecateThingType -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DeprecateThingTypeResponse' 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', 'deprecateThingTypeResponse_httpStatus' - The response's http status code.
newDeprecateThingTypeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeprecateThingTypeResponse
newDeprecateThingTypeResponse :: Int -> DeprecateThingTypeResponse
newDeprecateThingTypeResponse Int
pHttpStatus_ =
  DeprecateThingTypeResponse'
    { $sel:httpStatus:DeprecateThingTypeResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData DeprecateThingTypeResponse where
  rnf :: DeprecateThingTypeResponse -> ()
rnf DeprecateThingTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeprecateThingTypeResponse' :: DeprecateThingTypeResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus