{-# 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.StopCompilationJob
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Stops a model compilation job.
--
-- To stop a job, Amazon SageMaker sends the algorithm the SIGTERM signal.
-- This gracefully shuts the job down. If the job hasn\'t stopped, it sends
-- the SIGKILL signal.
--
-- When it receives a @StopCompilationJob@ request, Amazon SageMaker
-- changes the CompilationJobSummary$CompilationJobStatus of the job to
-- @Stopping@. After Amazon SageMaker stops the job, it sets the
-- CompilationJobSummary$CompilationJobStatus to @Stopped@.
module Amazonka.SageMaker.StopCompilationJob
  ( -- * Creating a Request
    StopCompilationJob (..),
    newStopCompilationJob,

    -- * Request Lenses
    stopCompilationJob_compilationJobName,

    -- * Destructuring the Response
    StopCompilationJobResponse (..),
    newStopCompilationJobResponse,
  )
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:/ 'newStopCompilationJob' smart constructor.
data StopCompilationJob = StopCompilationJob'
  { -- | The name of the model compilation job to stop.
    StopCompilationJob -> Text
compilationJobName :: Prelude.Text
  }
  deriving (StopCompilationJob -> StopCompilationJob -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopCompilationJob -> StopCompilationJob -> Bool
$c/= :: StopCompilationJob -> StopCompilationJob -> Bool
== :: StopCompilationJob -> StopCompilationJob -> Bool
$c== :: StopCompilationJob -> StopCompilationJob -> Bool
Prelude.Eq, ReadPrec [StopCompilationJob]
ReadPrec StopCompilationJob
Int -> ReadS StopCompilationJob
ReadS [StopCompilationJob]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopCompilationJob]
$creadListPrec :: ReadPrec [StopCompilationJob]
readPrec :: ReadPrec StopCompilationJob
$creadPrec :: ReadPrec StopCompilationJob
readList :: ReadS [StopCompilationJob]
$creadList :: ReadS [StopCompilationJob]
readsPrec :: Int -> ReadS StopCompilationJob
$creadsPrec :: Int -> ReadS StopCompilationJob
Prelude.Read, Int -> StopCompilationJob -> ShowS
[StopCompilationJob] -> ShowS
StopCompilationJob -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopCompilationJob] -> ShowS
$cshowList :: [StopCompilationJob] -> ShowS
show :: StopCompilationJob -> String
$cshow :: StopCompilationJob -> String
showsPrec :: Int -> StopCompilationJob -> ShowS
$cshowsPrec :: Int -> StopCompilationJob -> ShowS
Prelude.Show, forall x. Rep StopCompilationJob x -> StopCompilationJob
forall x. StopCompilationJob -> Rep StopCompilationJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopCompilationJob x -> StopCompilationJob
$cfrom :: forall x. StopCompilationJob -> Rep StopCompilationJob x
Prelude.Generic)

-- |
-- Create a value of 'StopCompilationJob' 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:
--
-- 'compilationJobName', 'stopCompilationJob_compilationJobName' - The name of the model compilation job to stop.
newStopCompilationJob ::
  -- | 'compilationJobName'
  Prelude.Text ->
  StopCompilationJob
newStopCompilationJob :: Text -> StopCompilationJob
newStopCompilationJob Text
pCompilationJobName_ =
  StopCompilationJob'
    { $sel:compilationJobName:StopCompilationJob' :: Text
compilationJobName =
        Text
pCompilationJobName_
    }

-- | The name of the model compilation job to stop.
stopCompilationJob_compilationJobName :: Lens.Lens' StopCompilationJob Prelude.Text
stopCompilationJob_compilationJobName :: Lens' StopCompilationJob Text
stopCompilationJob_compilationJobName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopCompilationJob' {Text
compilationJobName :: Text
$sel:compilationJobName:StopCompilationJob' :: StopCompilationJob -> Text
compilationJobName} -> Text
compilationJobName) (\s :: StopCompilationJob
s@StopCompilationJob' {} Text
a -> StopCompilationJob
s {$sel:compilationJobName:StopCompilationJob' :: Text
compilationJobName = Text
a} :: StopCompilationJob)

instance Core.AWSRequest StopCompilationJob where
  type
    AWSResponse StopCompilationJob =
      StopCompilationJobResponse
  request :: (Service -> Service)
-> StopCompilationJob -> Request StopCompilationJob
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 StopCompilationJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopCompilationJob)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull StopCompilationJobResponse
StopCompilationJobResponse'

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

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

instance Data.ToHeaders StopCompilationJob where
  toHeaders :: StopCompilationJob -> [Header]
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 -> [Header]
Data.=# ( ByteString
"SageMaker.StopCompilationJob" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StopCompilationJob where
  toJSON :: StopCompilationJob -> Value
toJSON StopCompilationJob' {Text
compilationJobName :: Text
$sel:compilationJobName:StopCompilationJob' :: StopCompilationJob -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"CompilationJobName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
compilationJobName)
          ]
      )

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

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

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

-- |
-- Create a value of 'StopCompilationJobResponse' 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.
newStopCompilationJobResponse ::
  StopCompilationJobResponse
newStopCompilationJobResponse :: StopCompilationJobResponse
newStopCompilationJobResponse =
  StopCompilationJobResponse
StopCompilationJobResponse'

instance Prelude.NFData StopCompilationJobResponse where
  rnf :: StopCompilationJobResponse -> ()
rnf StopCompilationJobResponse
_ = ()