{-# 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-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)
--
-- Terminates the ML compute instance. Before terminating the instance,
-- Amazon SageMaker disconnects the ML storage volume from it. Amazon
-- SageMaker preserves the ML storage volume. Amazon 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.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:/ 'newStopNotebookInstance' smart constructor.
data StopNotebookInstance = StopNotebookInstance'
  { -- | The name of the notebook instance to terminate.
    StopNotebookInstance -> Text
notebookInstanceName :: Prelude.Text
  }
  deriving (StopNotebookInstance -> StopNotebookInstance -> Bool
(StopNotebookInstance -> StopNotebookInstance -> Bool)
-> (StopNotebookInstance -> StopNotebookInstance -> Bool)
-> Eq StopNotebookInstance
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]
(Int -> ReadS StopNotebookInstance)
-> ReadS [StopNotebookInstance]
-> ReadPrec StopNotebookInstance
-> ReadPrec [StopNotebookInstance]
-> Read 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
(Int -> StopNotebookInstance -> ShowS)
-> (StopNotebookInstance -> String)
-> ([StopNotebookInstance] -> ShowS)
-> Show StopNotebookInstance
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. StopNotebookInstance -> Rep StopNotebookInstance x)
-> (forall x. Rep StopNotebookInstance x -> StopNotebookInstance)
-> Generic StopNotebookInstance
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' :: Text -> StopNotebookInstance
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 :: (Text -> f Text) -> StopNotebookInstance -> f StopNotebookInstance
stopNotebookInstance_notebookInstanceName = (StopNotebookInstance -> Text)
-> (StopNotebookInstance -> Text -> StopNotebookInstance)
-> Lens StopNotebookInstance StopNotebookInstance Text Text
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 :: StopNotebookInstance -> Request StopNotebookInstance
request = Service -> StopNotebookInstance -> Request StopNotebookInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopNotebookInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopNotebookInstance)))
response =
    AWSResponse StopNotebookInstance
-> Logger
-> Service
-> Proxy StopNotebookInstance
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StopNotebookInstance)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse StopNotebookInstance
StopNotebookInstanceResponse
StopNotebookInstanceResponse'

instance Prelude.Hashable StopNotebookInstance

instance Prelude.NFData StopNotebookInstance

instance Core.ToHeaders StopNotebookInstance where
  toHeaders :: StopNotebookInstance -> [Header]
toHeaders =
    [Header] -> StopNotebookInstance -> [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.StopNotebookInstance" ::
                          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 StopNotebookInstance where
  toJSON :: StopNotebookInstance -> Value
toJSON StopNotebookInstance' {Text
notebookInstanceName :: Text
$sel:notebookInstanceName:StopNotebookInstance' :: StopNotebookInstance -> 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
"NotebookInstanceName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
notebookInstanceName
              )
          ]
      )

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

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

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