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

instance Prelude.NFData DeleteWorkGroup

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RecursiveDeleteOption" 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
recursiveDeleteOption,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"WorkGroup" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
workGroup)
          ]
      )

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

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

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