{-# 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-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)
--
-- 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.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:/ 'newStopCompilationJob' smart constructor.
data StopCompilationJob = StopCompilationJob'
  { -- | The name of the model compilation job to stop.
    StopCompilationJob -> Text
compilationJobName :: Prelude.Text
  }
  deriving (StopCompilationJob -> StopCompilationJob -> Bool
(StopCompilationJob -> StopCompilationJob -> Bool)
-> (StopCompilationJob -> StopCompilationJob -> Bool)
-> Eq StopCompilationJob
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]
(Int -> ReadS StopCompilationJob)
-> ReadS [StopCompilationJob]
-> ReadPrec StopCompilationJob
-> ReadPrec [StopCompilationJob]
-> Read 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
(Int -> StopCompilationJob -> ShowS)
-> (StopCompilationJob -> String)
-> ([StopCompilationJob] -> ShowS)
-> Show StopCompilationJob
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. StopCompilationJob -> Rep StopCompilationJob x)
-> (forall x. Rep StopCompilationJob x -> StopCompilationJob)
-> Generic StopCompilationJob
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' :: Text -> StopCompilationJob
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 :: (Text -> f Text) -> StopCompilationJob -> f StopCompilationJob
stopCompilationJob_compilationJobName = (StopCompilationJob -> Text)
-> (StopCompilationJob -> Text -> StopCompilationJob)
-> Lens StopCompilationJob StopCompilationJob Text Text
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 :: StopCompilationJob -> Request StopCompilationJob
request = Service -> StopCompilationJob -> Request StopCompilationJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopCompilationJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopCompilationJob)))
response =
    AWSResponse StopCompilationJob
-> Logger
-> Service
-> Proxy StopCompilationJob
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopCompilationJob)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse StopCompilationJob
StopCompilationJobResponse
StopCompilationJobResponse'

instance Prelude.Hashable StopCompilationJob

instance Prelude.NFData StopCompilationJob

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

instance Core.ToJSON StopCompilationJob where
  toJSON :: StopCompilationJob -> Value
toJSON StopCompilationJob' {Text
compilationJobName :: Text
$sel:compilationJobName:StopCompilationJob' :: StopCompilationJob -> 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
"CompilationJobName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
compilationJobName)
          ]
      )

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

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

-- | /See:/ 'newStopCompilationJobResponse' smart constructor.
data StopCompilationJobResponse = StopCompilationJobResponse'
  {
  }
  deriving (StopCompilationJobResponse -> StopCompilationJobResponse -> Bool
(StopCompilationJobResponse -> StopCompilationJobResponse -> Bool)
-> (StopCompilationJobResponse
    -> StopCompilationJobResponse -> Bool)
-> Eq StopCompilationJobResponse
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]
(Int -> ReadS StopCompilationJobResponse)
-> ReadS [StopCompilationJobResponse]
-> ReadPrec StopCompilationJobResponse
-> ReadPrec [StopCompilationJobResponse]
-> Read 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
(Int -> StopCompilationJobResponse -> ShowS)
-> (StopCompilationJobResponse -> String)
-> ([StopCompilationJobResponse] -> ShowS)
-> Show StopCompilationJobResponse
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.
 StopCompilationJobResponse -> Rep StopCompilationJobResponse x)
-> (forall x.
    Rep StopCompilationJobResponse x -> StopCompilationJobResponse)
-> Generic StopCompilationJobResponse
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