{-# 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.SageMaker.DeleteWorkforce
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Use this operation to delete a workforce.
--
-- If you want to create a new workforce in an Amazon Web Services Region
-- where a workforce already exists, use this operation to delete the
-- existing workforce and then use to create a new workforce.
--
-- If a private workforce contains one or more work teams, you must use the
-- operation to delete all work teams before you delete the workforce. If
-- you try to delete a workforce that contains one or more work teams, you
-- will recieve a @ResourceInUse@ error.
module Amazonka.SageMaker.DeleteWorkforce
  ( -- * Creating a Request
    DeleteWorkforce (..),
    newDeleteWorkforce,

    -- * Request Lenses
    deleteWorkforce_workforceName,

    -- * Destructuring the Response
    DeleteWorkforceResponse (..),
    newDeleteWorkforceResponse,

    -- * Response Lenses
    deleteWorkforceResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SageMaker.Types

-- | /See:/ 'newDeleteWorkforce' smart constructor.
data DeleteWorkforce = DeleteWorkforce'
  { -- | The name of the workforce.
    DeleteWorkforce -> Text
workforceName :: Prelude.Text
  }
  deriving (DeleteWorkforce -> DeleteWorkforce -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteWorkforce -> DeleteWorkforce -> Bool
$c/= :: DeleteWorkforce -> DeleteWorkforce -> Bool
== :: DeleteWorkforce -> DeleteWorkforce -> Bool
$c== :: DeleteWorkforce -> DeleteWorkforce -> Bool
Prelude.Eq, ReadPrec [DeleteWorkforce]
ReadPrec DeleteWorkforce
Int -> ReadS DeleteWorkforce
ReadS [DeleteWorkforce]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteWorkforce]
$creadListPrec :: ReadPrec [DeleteWorkforce]
readPrec :: ReadPrec DeleteWorkforce
$creadPrec :: ReadPrec DeleteWorkforce
readList :: ReadS [DeleteWorkforce]
$creadList :: ReadS [DeleteWorkforce]
readsPrec :: Int -> ReadS DeleteWorkforce
$creadsPrec :: Int -> ReadS DeleteWorkforce
Prelude.Read, Int -> DeleteWorkforce -> ShowS
[DeleteWorkforce] -> ShowS
DeleteWorkforce -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteWorkforce] -> ShowS
$cshowList :: [DeleteWorkforce] -> ShowS
show :: DeleteWorkforce -> String
$cshow :: DeleteWorkforce -> String
showsPrec :: Int -> DeleteWorkforce -> ShowS
$cshowsPrec :: Int -> DeleteWorkforce -> ShowS
Prelude.Show, forall x. Rep DeleteWorkforce x -> DeleteWorkforce
forall x. DeleteWorkforce -> Rep DeleteWorkforce x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteWorkforce x -> DeleteWorkforce
$cfrom :: forall x. DeleteWorkforce -> Rep DeleteWorkforce x
Prelude.Generic)

-- |
-- Create a value of 'DeleteWorkforce' 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:
--
-- 'workforceName', 'deleteWorkforce_workforceName' - The name of the workforce.
newDeleteWorkforce ::
  -- | 'workforceName'
  Prelude.Text ->
  DeleteWorkforce
newDeleteWorkforce :: Text -> DeleteWorkforce
newDeleteWorkforce Text
pWorkforceName_ =
  DeleteWorkforce' {$sel:workforceName:DeleteWorkforce' :: Text
workforceName = Text
pWorkforceName_}

-- | The name of the workforce.
deleteWorkforce_workforceName :: Lens.Lens' DeleteWorkforce Prelude.Text
deleteWorkforce_workforceName :: Lens' DeleteWorkforce Text
deleteWorkforce_workforceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWorkforce' {Text
workforceName :: Text
$sel:workforceName:DeleteWorkforce' :: DeleteWorkforce -> Text
workforceName} -> Text
workforceName) (\s :: DeleteWorkforce
s@DeleteWorkforce' {} Text
a -> DeleteWorkforce
s {$sel:workforceName:DeleteWorkforce' :: Text
workforceName = Text
a} :: DeleteWorkforce)

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

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

instance Data.ToHeaders DeleteWorkforce where
  toHeaders :: DeleteWorkforce -> 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
"SageMaker.DeleteWorkforce" :: 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 DeleteWorkforce where
  toJSON :: DeleteWorkforce -> Value
toJSON DeleteWorkforce' {Text
workforceName :: Text
$sel:workforceName:DeleteWorkforce' :: DeleteWorkforce -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"WorkforceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
workforceName)
          ]
      )

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

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

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

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

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

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