{-# 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.StopHyperParameterTuningJob
-- 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 running hyperparameter tuning job and all running training jobs
-- that the tuning job launched.
--
-- All model artifacts output from the training jobs are stored in Amazon
-- Simple Storage Service (Amazon S3). All data that the training jobs
-- write to Amazon CloudWatch Logs are still available in CloudWatch. After
-- the tuning job moves to the @Stopped@ state, it releases all reserved
-- resources for the tuning job.
module Amazonka.SageMaker.StopHyperParameterTuningJob
  ( -- * Creating a Request
    StopHyperParameterTuningJob (..),
    newStopHyperParameterTuningJob,

    -- * Request Lenses
    stopHyperParameterTuningJob_hyperParameterTuningJobName,

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

-- |
-- Create a value of 'StopHyperParameterTuningJob' 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:
--
-- 'hyperParameterTuningJobName', 'stopHyperParameterTuningJob_hyperParameterTuningJobName' - The name of the tuning job to stop.
newStopHyperParameterTuningJob ::
  -- | 'hyperParameterTuningJobName'
  Prelude.Text ->
  StopHyperParameterTuningJob
newStopHyperParameterTuningJob :: Text -> StopHyperParameterTuningJob
newStopHyperParameterTuningJob
  Text
pHyperParameterTuningJobName_ =
    StopHyperParameterTuningJob'
      { $sel:hyperParameterTuningJobName:StopHyperParameterTuningJob' :: Text
hyperParameterTuningJobName =
          Text
pHyperParameterTuningJobName_
      }

-- | The name of the tuning job to stop.
stopHyperParameterTuningJob_hyperParameterTuningJobName :: Lens.Lens' StopHyperParameterTuningJob Prelude.Text
stopHyperParameterTuningJob_hyperParameterTuningJobName :: Lens' StopHyperParameterTuningJob Text
stopHyperParameterTuningJob_hyperParameterTuningJobName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopHyperParameterTuningJob' {Text
hyperParameterTuningJobName :: Text
$sel:hyperParameterTuningJobName:StopHyperParameterTuningJob' :: StopHyperParameterTuningJob -> Text
hyperParameterTuningJobName} -> Text
hyperParameterTuningJobName) (\s :: StopHyperParameterTuningJob
s@StopHyperParameterTuningJob' {} Text
a -> StopHyperParameterTuningJob
s {$sel:hyperParameterTuningJobName:StopHyperParameterTuningJob' :: Text
hyperParameterTuningJobName = Text
a} :: StopHyperParameterTuningJob)

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

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

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

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

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

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

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

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

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