{-# 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.StopNotebookInstance
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Terminates the ML compute instance. Before terminating the instance,
-- SageMaker disconnects the ML storage volume from it. SageMaker preserves
-- the ML storage volume. SageMaker stops charging you for the ML compute
-- instance when you call @StopNotebookInstance@.
--
-- To access data on the ML storage volume for a notebook instance that has
-- been terminated, call the @StartNotebookInstance@ API.
-- @StartNotebookInstance@ launches another ML compute instance, configures
-- it, and attaches the preserved ML storage volume so you can continue
-- your work.
module Amazonka.SageMaker.StopNotebookInstance
  ( -- * Creating a Request
    StopNotebookInstance (..),
    newStopNotebookInstance,

    -- * Request Lenses
    stopNotebookInstance_notebookInstanceName,

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

-- |
-- Create a value of 'StopNotebookInstance' 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:
--
-- 'notebookInstanceName', 'stopNotebookInstance_notebookInstanceName' - The name of the notebook instance to terminate.
newStopNotebookInstance ::
  -- | 'notebookInstanceName'
  Prelude.Text ->
  StopNotebookInstance
newStopNotebookInstance :: Text -> StopNotebookInstance
newStopNotebookInstance Text
pNotebookInstanceName_ =
  StopNotebookInstance'
    { $sel:notebookInstanceName:StopNotebookInstance' :: Text
notebookInstanceName =
        Text
pNotebookInstanceName_
    }

-- | The name of the notebook instance to terminate.
stopNotebookInstance_notebookInstanceName :: Lens.Lens' StopNotebookInstance Prelude.Text
stopNotebookInstance_notebookInstanceName :: Lens' StopNotebookInstance Text
stopNotebookInstance_notebookInstanceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopNotebookInstance' {Text
notebookInstanceName :: Text
$sel:notebookInstanceName:StopNotebookInstance' :: StopNotebookInstance -> Text
notebookInstanceName} -> Text
notebookInstanceName) (\s :: StopNotebookInstance
s@StopNotebookInstance' {} Text
a -> StopNotebookInstance
s {$sel:notebookInstanceName:StopNotebookInstance' :: Text
notebookInstanceName = Text
a} :: StopNotebookInstance)

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

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

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

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

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

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

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

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

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