{-# 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-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)
--
-- 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.Lens as Lens
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
(DeleteWorkforce -> DeleteWorkforce -> Bool)
-> (DeleteWorkforce -> DeleteWorkforce -> Bool)
-> Eq DeleteWorkforce
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]
(Int -> ReadS DeleteWorkforce)
-> ReadS [DeleteWorkforce]
-> ReadPrec DeleteWorkforce
-> ReadPrec [DeleteWorkforce]
-> Read 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
(Int -> DeleteWorkforce -> ShowS)
-> (DeleteWorkforce -> String)
-> ([DeleteWorkforce] -> ShowS)
-> Show DeleteWorkforce
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. DeleteWorkforce -> Rep DeleteWorkforce x)
-> (forall x. Rep DeleteWorkforce x -> DeleteWorkforce)
-> Generic DeleteWorkforce
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' :: Text -> DeleteWorkforce
DeleteWorkforce' {$sel:workforceName:DeleteWorkforce' :: Text
workforceName = Text
pWorkforceName_}

-- | The name of the workforce.
deleteWorkforce_workforceName :: Lens.Lens' DeleteWorkforce Prelude.Text
deleteWorkforce_workforceName :: (Text -> f Text) -> DeleteWorkforce -> f DeleteWorkforce
deleteWorkforce_workforceName = (DeleteWorkforce -> Text)
-> (DeleteWorkforce -> Text -> DeleteWorkforce)
-> Lens DeleteWorkforce DeleteWorkforce Text Text
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 :: DeleteWorkforce -> Request DeleteWorkforce
request = Service -> DeleteWorkforce -> Request DeleteWorkforce
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteWorkforce
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWorkforce)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteWorkforce))
-> Logger
-> Service
-> Proxy DeleteWorkforce
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWorkforce)))
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 -> DeleteWorkforceResponse
DeleteWorkforceResponse'
            (Int -> DeleteWorkforceResponse)
-> Either String Int -> Either String DeleteWorkforceResponse
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 DeleteWorkforce

instance Prelude.NFData DeleteWorkforce

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

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

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

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