{-# 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.RedshiftServerLess.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 a workgroup.
module Amazonka.RedshiftServerLess.DeleteWorkgroup
  ( -- * Creating a Request
    DeleteWorkgroup (..),
    newDeleteWorkgroup,

    -- * Request Lenses
    deleteWorkgroup_workgroupName,

    -- * Destructuring the Response
    DeleteWorkgroupResponse (..),
    newDeleteWorkgroupResponse,

    -- * Response Lenses
    deleteWorkgroupResponse_httpStatus,
    deleteWorkgroupResponse_workgroup,
  )
where

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 Amazonka.RedshiftServerLess.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteWorkgroup' smart constructor.
data DeleteWorkgroup = DeleteWorkgroup'
  { -- | The name of the workgroup to be deleted.
    DeleteWorkgroup -> Text
workgroupName :: 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:
--
-- 'workgroupName', 'deleteWorkgroup_workgroupName' - The name of the workgroup to be deleted.
newDeleteWorkgroup ::
  -- | 'workgroupName'
  Prelude.Text ->
  DeleteWorkgroup
newDeleteWorkgroup :: Text -> DeleteWorkgroup
newDeleteWorkgroup Text
pWorkgroupName_ =
  DeleteWorkgroup' {$sel:workgroupName:DeleteWorkgroup' :: Text
workgroupName = Text
pWorkgroupName_}

-- | The name of the workgroup to be deleted.
deleteWorkgroup_workgroupName :: Lens.Lens' DeleteWorkgroup Prelude.Text
deleteWorkgroup_workgroupName :: Lens' DeleteWorkgroup Text
deleteWorkgroup_workgroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkgroup' {Text
workgroupName :: Text
$sel:workgroupName:DeleteWorkgroup' :: DeleteWorkgroup -> Text
workgroupName} -> Text
workgroupName) (\s :: DeleteWorkgroup
s@DeleteWorkgroup' {} Text
a -> DeleteWorkgroup
s {$sel:workgroupName:DeleteWorkgroup' :: Text
workgroupName = 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 -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Workgroup -> 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"workgroup")
      )

instance Prelude.Hashable DeleteWorkgroup where
  hashWithSalt :: Int -> DeleteWorkgroup -> Int
hashWithSalt Int
_salt DeleteWorkgroup' {Text
workgroupName :: Text
$sel:workgroupName:DeleteWorkgroup' :: DeleteWorkgroup -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
workgroupName

instance Prelude.NFData DeleteWorkgroup where
  rnf :: DeleteWorkgroup -> ()
rnf DeleteWorkgroup' {Text
workgroupName :: Text
$sel:workgroupName:DeleteWorkgroup' :: DeleteWorkgroup -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
workgroupName

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
"RedshiftServerless.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' {Text
workgroupName :: Text
$sel:workgroupName:DeleteWorkgroup' :: DeleteWorkgroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"workgroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workgroupName)
          ]
      )

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,
    -- | The deleted workgroup object.
    DeleteWorkgroupResponse -> Workgroup
workgroup :: Workgroup
  }
  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.
--
-- 'workgroup', 'deleteWorkgroupResponse_workgroup' - The deleted workgroup object.
newDeleteWorkgroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'workgroup'
  Workgroup ->
  DeleteWorkgroupResponse
newDeleteWorkgroupResponse :: Int -> Workgroup -> DeleteWorkgroupResponse
newDeleteWorkgroupResponse Int
pHttpStatus_ Workgroup
pWorkgroup_ =
  DeleteWorkgroupResponse'
    { $sel:httpStatus:DeleteWorkgroupResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:workgroup:DeleteWorkgroupResponse' :: Workgroup
workgroup = Workgroup
pWorkgroup_
    }

-- | 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)

-- | The deleted workgroup object.
deleteWorkgroupResponse_workgroup :: Lens.Lens' DeleteWorkgroupResponse Workgroup
deleteWorkgroupResponse_workgroup :: Lens' DeleteWorkgroupResponse Workgroup
deleteWorkgroupResponse_workgroup = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkgroupResponse' {Workgroup
workgroup :: Workgroup
$sel:workgroup:DeleteWorkgroupResponse' :: DeleteWorkgroupResponse -> Workgroup
workgroup} -> Workgroup
workgroup) (\s :: DeleteWorkgroupResponse
s@DeleteWorkgroupResponse' {} Workgroup
a -> DeleteWorkgroupResponse
s {$sel:workgroup:DeleteWorkgroupResponse' :: Workgroup
workgroup = Workgroup
a} :: DeleteWorkgroupResponse)

instance Prelude.NFData DeleteWorkgroupResponse where
  rnf :: DeleteWorkgroupResponse -> ()
rnf DeleteWorkgroupResponse' {Int
Workgroup
workgroup :: Workgroup
httpStatus :: Int
$sel:workgroup:DeleteWorkgroupResponse' :: DeleteWorkgroupResponse -> Workgroup
$sel:httpStatus:DeleteWorkgroupResponse' :: DeleteWorkgroupResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Workgroup
workgroup