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

-- | /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
(DeleteDynamicThingGroup -> DeleteDynamicThingGroup -> Bool)
-> (DeleteDynamicThingGroup -> DeleteDynamicThingGroup -> Bool)
-> Eq DeleteDynamicThingGroup
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]
(Int -> ReadS DeleteDynamicThingGroup)
-> ReadS [DeleteDynamicThingGroup]
-> ReadPrec DeleteDynamicThingGroup
-> ReadPrec [DeleteDynamicThingGroup]
-> Read 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
(Int -> DeleteDynamicThingGroup -> ShowS)
-> (DeleteDynamicThingGroup -> String)
-> ([DeleteDynamicThingGroup] -> ShowS)
-> Show DeleteDynamicThingGroup
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.
 DeleteDynamicThingGroup -> Rep DeleteDynamicThingGroup x)
-> (forall x.
    Rep DeleteDynamicThingGroup x -> DeleteDynamicThingGroup)
-> Generic DeleteDynamicThingGroup
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' :: Maybe Integer -> Text -> DeleteDynamicThingGroup
DeleteDynamicThingGroup'
    { $sel:expectedVersion:DeleteDynamicThingGroup' :: Maybe Integer
expectedVersion =
        Maybe Integer
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 :: (Maybe Integer -> f (Maybe Integer))
-> DeleteDynamicThingGroup -> f DeleteDynamicThingGroup
deleteDynamicThingGroup_expectedVersion = (DeleteDynamicThingGroup -> Maybe Integer)
-> (DeleteDynamicThingGroup
    -> Maybe Integer -> DeleteDynamicThingGroup)
-> Lens
     DeleteDynamicThingGroup
     DeleteDynamicThingGroup
     (Maybe Integer)
     (Maybe Integer)
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 :: (Text -> f Text)
-> DeleteDynamicThingGroup -> f DeleteDynamicThingGroup
deleteDynamicThingGroup_thingGroupName = (DeleteDynamicThingGroup -> Text)
-> (DeleteDynamicThingGroup -> Text -> DeleteDynamicThingGroup)
-> Lens DeleteDynamicThingGroup DeleteDynamicThingGroup Text Text
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 :: DeleteDynamicThingGroup -> Request DeleteDynamicThingGroup
request = Service
-> DeleteDynamicThingGroup -> Request DeleteDynamicThingGroup
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDynamicThingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDynamicThingGroup)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteDynamicThingGroup))
-> Logger
-> Service
-> Proxy DeleteDynamicThingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteDynamicThingGroup)))
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 -> DeleteDynamicThingGroupResponse
DeleteDynamicThingGroupResponse'
            (Int -> DeleteDynamicThingGroupResponse)
-> Either String Int
-> Either String DeleteDynamicThingGroupResponse
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 DeleteDynamicThingGroup

instance Prelude.NFData DeleteDynamicThingGroup

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

instance Core.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
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/dynamic-thing-groups/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
thingGroupName]

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"expectedVersion" ByteString -> Maybe Integer -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(DeleteDynamicThingGroupResponse
 -> DeleteDynamicThingGroupResponse -> Bool)
-> (DeleteDynamicThingGroupResponse
    -> DeleteDynamicThingGroupResponse -> Bool)
-> Eq DeleteDynamicThingGroupResponse
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]
(Int -> ReadS DeleteDynamicThingGroupResponse)
-> ReadS [DeleteDynamicThingGroupResponse]
-> ReadPrec DeleteDynamicThingGroupResponse
-> ReadPrec [DeleteDynamicThingGroupResponse]
-> Read 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
(Int -> DeleteDynamicThingGroupResponse -> ShowS)
-> (DeleteDynamicThingGroupResponse -> String)
-> ([DeleteDynamicThingGroupResponse] -> ShowS)
-> Show DeleteDynamicThingGroupResponse
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.
 DeleteDynamicThingGroupResponse
 -> Rep DeleteDynamicThingGroupResponse x)
-> (forall x.
    Rep DeleteDynamicThingGroupResponse x
    -> DeleteDynamicThingGroupResponse)
-> Generic DeleteDynamicThingGroupResponse
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' :: Int -> DeleteDynamicThingGroupResponse
DeleteDynamicThingGroupResponse'
    { $sel:httpStatus:DeleteDynamicThingGroupResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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