{-# 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.Athena.DeleteWorkGroup
-- 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 the workgroup with the specified name. The primary workgroup
-- cannot be deleted.
module Amazonka.Athena.DeleteWorkGroup
  ( -- * Creating a Request
    DeleteWorkGroup (..),
    newDeleteWorkGroup,

    -- * Request Lenses
    deleteWorkGroup_recursiveDeleteOption,
    deleteWorkGroup_workGroup,

    -- * Destructuring the Response
    DeleteWorkGroupResponse (..),
    newDeleteWorkGroupResponse,

    -- * Response Lenses
    deleteWorkGroupResponse_httpStatus,
  )
where

import Amazonka.Athena.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteWorkGroup' smart constructor.
data DeleteWorkGroup = DeleteWorkGroup'
  { -- | The option to delete the workgroup and its contents even if the
    -- workgroup contains any named queries or query executions.
    DeleteWorkGroup -> Maybe Bool
recursiveDeleteOption :: Prelude.Maybe Prelude.Bool,
    -- | The unique name of the workgroup to delete.
    DeleteWorkGroup -> Text
workGroup :: Prelude.Text
  }
  deriving (DeleteWorkGroup -> DeleteWorkGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteWorkGroup -> DeleteWorkGroup -> Bool
$c/= :: DeleteWorkGroup -> DeleteWorkGroup -> Bool
== :: DeleteWorkGroup -> DeleteWorkGroup -> Bool
$c== :: DeleteWorkGroup -> DeleteWorkGroup -> Bool
Prelude.Eq, ReadPrec [DeleteWorkGroup]
ReadPrec DeleteWorkGroup
Int -> ReadS DeleteWorkGroup
ReadS [DeleteWorkGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteWorkGroup]
$creadListPrec :: ReadPrec [DeleteWorkGroup]
readPrec :: ReadPrec DeleteWorkGroup
$creadPrec :: ReadPrec DeleteWorkGroup
readList :: ReadS [DeleteWorkGroup]
$creadList :: ReadS [DeleteWorkGroup]
readsPrec :: Int -> ReadS DeleteWorkGroup
$creadsPrec :: Int -> ReadS DeleteWorkGroup
Prelude.Read, Int -> DeleteWorkGroup -> ShowS
[DeleteWorkGroup] -> ShowS
DeleteWorkGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteWorkGroup] -> ShowS
$cshowList :: [DeleteWorkGroup] -> ShowS
show :: DeleteWorkGroup -> String
$cshow :: DeleteWorkGroup -> String
showsPrec :: Int -> DeleteWorkGroup -> ShowS
$cshowsPrec :: Int -> DeleteWorkGroup -> ShowS
Prelude.Show, forall x. Rep DeleteWorkGroup x -> DeleteWorkGroup
forall x. DeleteWorkGroup -> Rep DeleteWorkGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteWorkGroup x -> DeleteWorkGroup
$cfrom :: forall x. DeleteWorkGroup -> Rep DeleteWorkGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteWorkGroup' 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:
--
-- 'recursiveDeleteOption', 'deleteWorkGroup_recursiveDeleteOption' - The option to delete the workgroup and its contents even if the
-- workgroup contains any named queries or query executions.
--
-- 'workGroup', 'deleteWorkGroup_workGroup' - The unique name of the workgroup to delete.
newDeleteWorkGroup ::
  -- | 'workGroup'
  Prelude.Text ->
  DeleteWorkGroup
newDeleteWorkGroup :: Text -> DeleteWorkGroup
newDeleteWorkGroup Text
pWorkGroup_ =
  DeleteWorkGroup'
    { $sel:recursiveDeleteOption:DeleteWorkGroup' :: Maybe Bool
recursiveDeleteOption =
        forall a. Maybe a
Prelude.Nothing,
      $sel:workGroup:DeleteWorkGroup' :: Text
workGroup = Text
pWorkGroup_
    }

-- | The option to delete the workgroup and its contents even if the
-- workgroup contains any named queries or query executions.
deleteWorkGroup_recursiveDeleteOption :: Lens.Lens' DeleteWorkGroup (Prelude.Maybe Prelude.Bool)
deleteWorkGroup_recursiveDeleteOption :: Lens' DeleteWorkGroup (Maybe Bool)
deleteWorkGroup_recursiveDeleteOption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkGroup' {Maybe Bool
recursiveDeleteOption :: Maybe Bool
$sel:recursiveDeleteOption:DeleteWorkGroup' :: DeleteWorkGroup -> Maybe Bool
recursiveDeleteOption} -> Maybe Bool
recursiveDeleteOption) (\s :: DeleteWorkGroup
s@DeleteWorkGroup' {} Maybe Bool
a -> DeleteWorkGroup
s {$sel:recursiveDeleteOption:DeleteWorkGroup' :: Maybe Bool
recursiveDeleteOption = Maybe Bool
a} :: DeleteWorkGroup)

-- | The unique name of the workgroup to delete.
deleteWorkGroup_workGroup :: Lens.Lens' DeleteWorkGroup Prelude.Text
deleteWorkGroup_workGroup :: Lens' DeleteWorkGroup Text
deleteWorkGroup_workGroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkGroup' {Text
workGroup :: Text
$sel:workGroup:DeleteWorkGroup' :: DeleteWorkGroup -> Text
workGroup} -> Text
workGroup) (\s :: DeleteWorkGroup
s@DeleteWorkGroup' {} Text
a -> DeleteWorkGroup
s {$sel:workGroup:DeleteWorkGroup' :: Text
workGroup = Text
a} :: DeleteWorkGroup)

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

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

instance Data.ToHeaders DeleteWorkGroup where
  toHeaders :: DeleteWorkGroup -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AmazonAthena.DeleteWorkGroup" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteWorkGroup where
  toJSON :: DeleteWorkGroup -> Value
toJSON DeleteWorkGroup' {Maybe Bool
Text
workGroup :: Text
recursiveDeleteOption :: Maybe Bool
$sel:workGroup:DeleteWorkGroup' :: DeleteWorkGroup -> Text
$sel:recursiveDeleteOption:DeleteWorkGroup' :: DeleteWorkGroup -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RecursiveDeleteOption" 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
recursiveDeleteOption,
            forall a. a -> Maybe a
Prelude.Just (Key
"WorkGroup" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workGroup)
          ]
      )

instance Data.ToPath DeleteWorkGroup where
  toPath :: DeleteWorkGroup -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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