{-# 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.DeleteDynamicThingGroup
-- 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 a dynamic thing group.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions DeleteDynamicThingGroup>
-- action.
module Amazonka.IoT.DeleteDynamicThingGroup
  ( -- * Creating a Request
    DeleteDynamicThingGroup (..),
    newDeleteDynamicThingGroup,

    -- * Request Lenses
    deleteDynamicThingGroup_expectedVersion,
    deleteDynamicThingGroup_thingGroupName,

    -- * Destructuring the Response
    DeleteDynamicThingGroupResponse (..),
    newDeleteDynamicThingGroupResponse,

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

-- | /See:/ 'newDeleteDynamicThingGroup' smart constructor.
data DeleteDynamicThingGroup = DeleteDynamicThingGroup'
  { -- | The expected version of the dynamic thing group to delete.
    DeleteDynamicThingGroup -> Maybe Integer
expectedVersion :: Prelude.Maybe Prelude.Integer,
    -- | The name of the dynamic thing group to delete.
    DeleteDynamicThingGroup -> Text
thingGroupName :: Prelude.Text
  }
  deriving (DeleteDynamicThingGroup -> DeleteDynamicThingGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDynamicThingGroup -> DeleteDynamicThingGroup -> Bool
$c/= :: DeleteDynamicThingGroup -> DeleteDynamicThingGroup -> Bool
== :: DeleteDynamicThingGroup -> DeleteDynamicThingGroup -> Bool
$c== :: DeleteDynamicThingGroup -> DeleteDynamicThingGroup -> Bool
Prelude.Eq, ReadPrec [DeleteDynamicThingGroup]
ReadPrec DeleteDynamicThingGroup
Int -> ReadS DeleteDynamicThingGroup
ReadS [DeleteDynamicThingGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDynamicThingGroup]
$creadListPrec :: ReadPrec [DeleteDynamicThingGroup]
readPrec :: ReadPrec DeleteDynamicThingGroup
$creadPrec :: ReadPrec DeleteDynamicThingGroup
readList :: ReadS [DeleteDynamicThingGroup]
$creadList :: ReadS [DeleteDynamicThingGroup]
readsPrec :: Int -> ReadS DeleteDynamicThingGroup
$creadsPrec :: Int -> ReadS DeleteDynamicThingGroup
Prelude.Read, Int -> DeleteDynamicThingGroup -> ShowS
[DeleteDynamicThingGroup] -> ShowS
DeleteDynamicThingGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDynamicThingGroup] -> ShowS
$cshowList :: [DeleteDynamicThingGroup] -> ShowS
show :: DeleteDynamicThingGroup -> String
$cshow :: DeleteDynamicThingGroup -> String
showsPrec :: Int -> DeleteDynamicThingGroup -> ShowS
$cshowsPrec :: Int -> DeleteDynamicThingGroup -> ShowS
Prelude.Show, forall x. Rep DeleteDynamicThingGroup x -> DeleteDynamicThingGroup
forall x. DeleteDynamicThingGroup -> Rep DeleteDynamicThingGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDynamicThingGroup x -> DeleteDynamicThingGroup
$cfrom :: forall x. DeleteDynamicThingGroup -> Rep DeleteDynamicThingGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDynamicThingGroup' 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:
--
-- 'expectedVersion', 'deleteDynamicThingGroup_expectedVersion' - The expected version of the dynamic thing group to delete.
--
-- 'thingGroupName', 'deleteDynamicThingGroup_thingGroupName' - The name of the dynamic thing group to delete.
newDeleteDynamicThingGroup ::
  -- | 'thingGroupName'
  Prelude.Text ->
  DeleteDynamicThingGroup
newDeleteDynamicThingGroup :: Text -> DeleteDynamicThingGroup
newDeleteDynamicThingGroup Text
pThingGroupName_ =
  DeleteDynamicThingGroup'
    { $sel:expectedVersion:DeleteDynamicThingGroup' :: Maybe Integer
expectedVersion =
        forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupName:DeleteDynamicThingGroup' :: Text
thingGroupName = Text
pThingGroupName_
    }

-- | The expected version of the dynamic thing group to delete.
deleteDynamicThingGroup_expectedVersion :: Lens.Lens' DeleteDynamicThingGroup (Prelude.Maybe Prelude.Integer)
deleteDynamicThingGroup_expectedVersion :: Lens' DeleteDynamicThingGroup (Maybe Integer)
deleteDynamicThingGroup_expectedVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDynamicThingGroup' {Maybe Integer
expectedVersion :: Maybe Integer
$sel:expectedVersion:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Maybe Integer
expectedVersion} -> Maybe Integer
expectedVersion) (\s :: DeleteDynamicThingGroup
s@DeleteDynamicThingGroup' {} Maybe Integer
a -> DeleteDynamicThingGroup
s {$sel:expectedVersion:DeleteDynamicThingGroup' :: Maybe Integer
expectedVersion = Maybe Integer
a} :: DeleteDynamicThingGroup)

-- | The name of the dynamic thing group to delete.
deleteDynamicThingGroup_thingGroupName :: Lens.Lens' DeleteDynamicThingGroup Prelude.Text
deleteDynamicThingGroup_thingGroupName :: Lens' DeleteDynamicThingGroup Text
deleteDynamicThingGroup_thingGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDynamicThingGroup' {Text
thingGroupName :: Text
$sel:thingGroupName:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Text
thingGroupName} -> Text
thingGroupName) (\s :: DeleteDynamicThingGroup
s@DeleteDynamicThingGroup' {} Text
a -> DeleteDynamicThingGroup
s {$sel:thingGroupName:DeleteDynamicThingGroup' :: Text
thingGroupName = Text
a} :: DeleteDynamicThingGroup)

instance Core.AWSRequest DeleteDynamicThingGroup where
  type
    AWSResponse DeleteDynamicThingGroup =
      DeleteDynamicThingGroupResponse
  request :: (Service -> Service)
-> DeleteDynamicThingGroup -> Request DeleteDynamicThingGroup
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 DeleteDynamicThingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDynamicThingGroup)))
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 -> DeleteDynamicThingGroupResponse
DeleteDynamicThingGroupResponse'
            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 DeleteDynamicThingGroup where
  hashWithSalt :: Int -> DeleteDynamicThingGroup -> Int
hashWithSalt Int
_salt DeleteDynamicThingGroup' {Maybe Integer
Text
thingGroupName :: Text
expectedVersion :: Maybe Integer
$sel:thingGroupName:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Text
$sel:expectedVersion:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
expectedVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
thingGroupName

instance Prelude.NFData DeleteDynamicThingGroup where
  rnf :: DeleteDynamicThingGroup -> ()
rnf DeleteDynamicThingGroup' {Maybe Integer
Text
thingGroupName :: Text
expectedVersion :: Maybe Integer
$sel:thingGroupName:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Text
$sel:expectedVersion:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
expectedVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
thingGroupName

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

instance Data.ToPath DeleteDynamicThingGroup where
  toPath :: DeleteDynamicThingGroup -> ByteString
toPath DeleteDynamicThingGroup' {Maybe Integer
Text
thingGroupName :: Text
expectedVersion :: Maybe Integer
$sel:thingGroupName:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Text
$sel:expectedVersion:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Maybe Integer
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/dynamic-thing-groups/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
thingGroupName]

instance Data.ToQuery DeleteDynamicThingGroup where
  toQuery :: DeleteDynamicThingGroup -> QueryString
toQuery DeleteDynamicThingGroup' {Maybe Integer
Text
thingGroupName :: Text
expectedVersion :: Maybe Integer
$sel:thingGroupName:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Text
$sel:expectedVersion:DeleteDynamicThingGroup' :: DeleteDynamicThingGroup -> Maybe Integer
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"expectedVersion" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Integer
expectedVersion]

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

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

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

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