{-# 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-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)
--
-- 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 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 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
(DeprecateThingType -> DeprecateThingType -> Bool)
-> (DeprecateThingType -> DeprecateThingType -> Bool)
-> Eq DeprecateThingType
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]
(Int -> ReadS DeprecateThingType)
-> ReadS [DeprecateThingType]
-> ReadPrec DeprecateThingType
-> ReadPrec [DeprecateThingType]
-> Read 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
(Int -> DeprecateThingType -> ShowS)
-> (DeprecateThingType -> String)
-> ([DeprecateThingType] -> ShowS)
-> Show DeprecateThingType
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. DeprecateThingType -> Rep DeprecateThingType x)
-> (forall x. Rep DeprecateThingType x -> DeprecateThingType)
-> Generic DeprecateThingType
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' :: Maybe Bool -> Text -> DeprecateThingType
DeprecateThingType'
    { $sel:undoDeprecate:DeprecateThingType' :: Maybe Bool
undoDeprecate =
        Maybe Bool
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 :: (Maybe Bool -> f (Maybe Bool))
-> DeprecateThingType -> f DeprecateThingType
deprecateThingType_undoDeprecate = (DeprecateThingType -> Maybe Bool)
-> (DeprecateThingType -> Maybe Bool -> DeprecateThingType)
-> Lens
     DeprecateThingType DeprecateThingType (Maybe Bool) (Maybe Bool)
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 :: (Text -> f Text) -> DeprecateThingType -> f DeprecateThingType
deprecateThingType_thingTypeName = (DeprecateThingType -> Text)
-> (DeprecateThingType -> Text -> DeprecateThingType)
-> Lens DeprecateThingType DeprecateThingType Text Text
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 :: DeprecateThingType -> Request DeprecateThingType
request = Service -> DeprecateThingType -> Request DeprecateThingType
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeprecateThingType
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeprecateThingType)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeprecateThingType))
-> Logger
-> Service
-> Proxy DeprecateThingType
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeprecateThingType)))
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 -> DeprecateThingTypeResponse
DeprecateThingTypeResponse'
            (Int -> DeprecateThingTypeResponse)
-> Either String Int -> Either String DeprecateThingTypeResponse
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 DeprecateThingType

instance Prelude.NFData DeprecateThingType

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"undoDeprecate" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
undoDeprecate
          ]
      )

instance Core.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
..} =
    [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,
        ByteString
"/deprecate"
      ]

instance Core.ToQuery DeprecateThingType where
  toQuery :: DeprecateThingType -> QueryString
toQuery = QueryString -> DeprecateThingType -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeprecateThingTypeResponse -> DeprecateThingTypeResponse -> Bool)
-> (DeprecateThingTypeResponse
    -> DeprecateThingTypeResponse -> Bool)
-> Eq DeprecateThingTypeResponse
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]
(Int -> ReadS DeprecateThingTypeResponse)
-> ReadS [DeprecateThingTypeResponse]
-> ReadPrec DeprecateThingTypeResponse
-> ReadPrec [DeprecateThingTypeResponse]
-> Read 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
(Int -> DeprecateThingTypeResponse -> ShowS)
-> (DeprecateThingTypeResponse -> String)
-> ([DeprecateThingTypeResponse] -> ShowS)
-> Show DeprecateThingTypeResponse
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.
 DeprecateThingTypeResponse -> Rep DeprecateThingTypeResponse x)
-> (forall x.
    Rep DeprecateThingTypeResponse x -> DeprecateThingTypeResponse)
-> Generic DeprecateThingTypeResponse
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' :: Int -> DeprecateThingTypeResponse
DeprecateThingTypeResponse'
    { $sel:httpStatus:DeprecateThingTypeResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deprecateThingTypeResponse_httpStatus :: Lens.Lens' DeprecateThingTypeResponse Prelude.Int
deprecateThingTypeResponse_httpStatus :: (Int -> f Int)
-> DeprecateThingTypeResponse -> f DeprecateThingTypeResponse
deprecateThingTypeResponse_httpStatus = (DeprecateThingTypeResponse -> Int)
-> (DeprecateThingTypeResponse
    -> Int -> DeprecateThingTypeResponse)
-> Lens
     DeprecateThingTypeResponse DeprecateThingTypeResponse Int Int
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