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

    -- * Request Lenses
    deleteThingGroup_expectedVersion,
    deleteThingGroup_thingGroupName,

    -- * Destructuring the Response
    DeleteThingGroupResponse (..),
    newDeleteThingGroupResponse,

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

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

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

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

instance Core.AWSRequest DeleteThingGroup where
  type
    AWSResponse DeleteThingGroup =
      DeleteThingGroupResponse
  request :: DeleteThingGroup -> Request DeleteThingGroup
request = Service -> DeleteThingGroup -> Request DeleteThingGroup
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteThingGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteThingGroup)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteThingGroup))
-> Logger
-> Service
-> Proxy DeleteThingGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteThingGroup)))
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 -> DeleteThingGroupResponse
DeleteThingGroupResponse'
            (Int -> DeleteThingGroupResponse)
-> Either String Int -> Either String DeleteThingGroupResponse
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 DeleteThingGroup

instance Prelude.NFData DeleteThingGroup

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

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

instance Core.ToQuery DeleteThingGroup where
  toQuery :: DeleteThingGroup -> QueryString
toQuery DeleteThingGroup' {Maybe Integer
Text
thingGroupName :: Text
expectedVersion :: Maybe Integer
$sel:thingGroupName:DeleteThingGroup' :: DeleteThingGroup -> Text
$sel:expectedVersion:DeleteThingGroup' :: DeleteThingGroup -> 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:/ 'newDeleteThingGroupResponse' smart constructor.
data DeleteThingGroupResponse = DeleteThingGroupResponse'
  { -- | The response's http status code.
    DeleteThingGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteThingGroupResponse -> DeleteThingGroupResponse -> Bool
(DeleteThingGroupResponse -> DeleteThingGroupResponse -> Bool)
-> (DeleteThingGroupResponse -> DeleteThingGroupResponse -> Bool)
-> Eq DeleteThingGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteThingGroupResponse -> DeleteThingGroupResponse -> Bool
$c/= :: DeleteThingGroupResponse -> DeleteThingGroupResponse -> Bool
== :: DeleteThingGroupResponse -> DeleteThingGroupResponse -> Bool
$c== :: DeleteThingGroupResponse -> DeleteThingGroupResponse -> Bool
Prelude.Eq, ReadPrec [DeleteThingGroupResponse]
ReadPrec DeleteThingGroupResponse
Int -> ReadS DeleteThingGroupResponse
ReadS [DeleteThingGroupResponse]
(Int -> ReadS DeleteThingGroupResponse)
-> ReadS [DeleteThingGroupResponse]
-> ReadPrec DeleteThingGroupResponse
-> ReadPrec [DeleteThingGroupResponse]
-> Read DeleteThingGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteThingGroupResponse]
$creadListPrec :: ReadPrec [DeleteThingGroupResponse]
readPrec :: ReadPrec DeleteThingGroupResponse
$creadPrec :: ReadPrec DeleteThingGroupResponse
readList :: ReadS [DeleteThingGroupResponse]
$creadList :: ReadS [DeleteThingGroupResponse]
readsPrec :: Int -> ReadS DeleteThingGroupResponse
$creadsPrec :: Int -> ReadS DeleteThingGroupResponse
Prelude.Read, Int -> DeleteThingGroupResponse -> ShowS
[DeleteThingGroupResponse] -> ShowS
DeleteThingGroupResponse -> String
(Int -> DeleteThingGroupResponse -> ShowS)
-> (DeleteThingGroupResponse -> String)
-> ([DeleteThingGroupResponse] -> ShowS)
-> Show DeleteThingGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteThingGroupResponse] -> ShowS
$cshowList :: [DeleteThingGroupResponse] -> ShowS
show :: DeleteThingGroupResponse -> String
$cshow :: DeleteThingGroupResponse -> String
showsPrec :: Int -> DeleteThingGroupResponse -> ShowS
$cshowsPrec :: Int -> DeleteThingGroupResponse -> ShowS
Prelude.Show, (forall x.
 DeleteThingGroupResponse -> Rep DeleteThingGroupResponse x)
-> (forall x.
    Rep DeleteThingGroupResponse x -> DeleteThingGroupResponse)
-> Generic DeleteThingGroupResponse
forall x.
Rep DeleteThingGroupResponse x -> DeleteThingGroupResponse
forall x.
DeleteThingGroupResponse -> Rep DeleteThingGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteThingGroupResponse x -> DeleteThingGroupResponse
$cfrom :: forall x.
DeleteThingGroupResponse -> Rep DeleteThingGroupResponse x
Prelude.Generic)

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

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

instance Prelude.NFData DeleteThingGroupResponse