{-# 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.DeleteContext
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes an context.
module Amazonka.SageMaker.DeleteContext
  ( -- * Creating a Request
    DeleteContext (..),
    newDeleteContext,

    -- * Request Lenses
    deleteContext_contextName,

    -- * Destructuring the Response
    DeleteContextResponse (..),
    newDeleteContextResponse,

    -- * Response Lenses
    deleteContextResponse_contextArn,
    deleteContextResponse_httpStatus,
  )
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:/ 'newDeleteContext' smart constructor.
data DeleteContext = DeleteContext'
  { -- | The name of the context to delete.
    DeleteContext -> Text
contextName :: Prelude.Text
  }
  deriving (DeleteContext -> DeleteContext -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteContext -> DeleteContext -> Bool
$c/= :: DeleteContext -> DeleteContext -> Bool
== :: DeleteContext -> DeleteContext -> Bool
$c== :: DeleteContext -> DeleteContext -> Bool
Prelude.Eq, ReadPrec [DeleteContext]
ReadPrec DeleteContext
Int -> ReadS DeleteContext
ReadS [DeleteContext]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteContext]
$creadListPrec :: ReadPrec [DeleteContext]
readPrec :: ReadPrec DeleteContext
$creadPrec :: ReadPrec DeleteContext
readList :: ReadS [DeleteContext]
$creadList :: ReadS [DeleteContext]
readsPrec :: Int -> ReadS DeleteContext
$creadsPrec :: Int -> ReadS DeleteContext
Prelude.Read, Int -> DeleteContext -> ShowS
[DeleteContext] -> ShowS
DeleteContext -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteContext] -> ShowS
$cshowList :: [DeleteContext] -> ShowS
show :: DeleteContext -> String
$cshow :: DeleteContext -> String
showsPrec :: Int -> DeleteContext -> ShowS
$cshowsPrec :: Int -> DeleteContext -> ShowS
Prelude.Show, forall x. Rep DeleteContext x -> DeleteContext
forall x. DeleteContext -> Rep DeleteContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteContext x -> DeleteContext
$cfrom :: forall x. DeleteContext -> Rep DeleteContext x
Prelude.Generic)

-- |
-- Create a value of 'DeleteContext' 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:
--
-- 'contextName', 'deleteContext_contextName' - The name of the context to delete.
newDeleteContext ::
  -- | 'contextName'
  Prelude.Text ->
  DeleteContext
newDeleteContext :: Text -> DeleteContext
newDeleteContext Text
pContextName_ =
  DeleteContext' {$sel:contextName:DeleteContext' :: Text
contextName = Text
pContextName_}

-- | The name of the context to delete.
deleteContext_contextName :: Lens.Lens' DeleteContext Prelude.Text
deleteContext_contextName :: Lens' DeleteContext Text
deleteContext_contextName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContext' {Text
contextName :: Text
$sel:contextName:DeleteContext' :: DeleteContext -> Text
contextName} -> Text
contextName) (\s :: DeleteContext
s@DeleteContext' {} Text
a -> DeleteContext
s {$sel:contextName:DeleteContext' :: Text
contextName = Text
a} :: DeleteContext)

instance Core.AWSRequest DeleteContext where
  type
    AWSResponse DeleteContext =
      DeleteContextResponse
  request :: (Service -> Service) -> DeleteContext -> Request DeleteContext
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 DeleteContext
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteContext)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteContextResponse
DeleteContextResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ContextArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

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

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

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

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

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

-- | /See:/ 'newDeleteContextResponse' smart constructor.
data DeleteContextResponse = DeleteContextResponse'
  { -- | The Amazon Resource Name (ARN) of the context.
    DeleteContextResponse -> Maybe Text
contextArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteContextResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteContextResponse -> DeleteContextResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteContextResponse -> DeleteContextResponse -> Bool
$c/= :: DeleteContextResponse -> DeleteContextResponse -> Bool
== :: DeleteContextResponse -> DeleteContextResponse -> Bool
$c== :: DeleteContextResponse -> DeleteContextResponse -> Bool
Prelude.Eq, ReadPrec [DeleteContextResponse]
ReadPrec DeleteContextResponse
Int -> ReadS DeleteContextResponse
ReadS [DeleteContextResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteContextResponse]
$creadListPrec :: ReadPrec [DeleteContextResponse]
readPrec :: ReadPrec DeleteContextResponse
$creadPrec :: ReadPrec DeleteContextResponse
readList :: ReadS [DeleteContextResponse]
$creadList :: ReadS [DeleteContextResponse]
readsPrec :: Int -> ReadS DeleteContextResponse
$creadsPrec :: Int -> ReadS DeleteContextResponse
Prelude.Read, Int -> DeleteContextResponse -> ShowS
[DeleteContextResponse] -> ShowS
DeleteContextResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteContextResponse] -> ShowS
$cshowList :: [DeleteContextResponse] -> ShowS
show :: DeleteContextResponse -> String
$cshow :: DeleteContextResponse -> String
showsPrec :: Int -> DeleteContextResponse -> ShowS
$cshowsPrec :: Int -> DeleteContextResponse -> ShowS
Prelude.Show, forall x. Rep DeleteContextResponse x -> DeleteContextResponse
forall x. DeleteContextResponse -> Rep DeleteContextResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteContextResponse x -> DeleteContextResponse
$cfrom :: forall x. DeleteContextResponse -> Rep DeleteContextResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteContextResponse' 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:
--
-- 'contextArn', 'deleteContextResponse_contextArn' - The Amazon Resource Name (ARN) of the context.
--
-- 'httpStatus', 'deleteContextResponse_httpStatus' - The response's http status code.
newDeleteContextResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteContextResponse
newDeleteContextResponse :: Int -> DeleteContextResponse
newDeleteContextResponse Int
pHttpStatus_ =
  DeleteContextResponse'
    { $sel:contextArn:DeleteContextResponse' :: Maybe Text
contextArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteContextResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the context.
deleteContextResponse_contextArn :: Lens.Lens' DeleteContextResponse (Prelude.Maybe Prelude.Text)
deleteContextResponse_contextArn :: Lens' DeleteContextResponse (Maybe Text)
deleteContextResponse_contextArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContextResponse' {Maybe Text
contextArn :: Maybe Text
$sel:contextArn:DeleteContextResponse' :: DeleteContextResponse -> Maybe Text
contextArn} -> Maybe Text
contextArn) (\s :: DeleteContextResponse
s@DeleteContextResponse' {} Maybe Text
a -> DeleteContextResponse
s {$sel:contextArn:DeleteContextResponse' :: Maybe Text
contextArn = Maybe Text
a} :: DeleteContextResponse)

-- | The response's http status code.
deleteContextResponse_httpStatus :: Lens.Lens' DeleteContextResponse Prelude.Int
deleteContextResponse_httpStatus :: Lens' DeleteContextResponse Int
deleteContextResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContextResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteContextResponse' :: DeleteContextResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteContextResponse
s@DeleteContextResponse' {} Int
a -> DeleteContextResponse
s {$sel:httpStatus:DeleteContextResponse' :: Int
httpStatus = Int
a} :: DeleteContextResponse)

instance Prelude.NFData DeleteContextResponse where
  rnf :: DeleteContextResponse -> ()
rnf DeleteContextResponse' {Int
Maybe Text
httpStatus :: Int
contextArn :: Maybe Text
$sel:httpStatus:DeleteContextResponse' :: DeleteContextResponse -> Int
$sel:contextArn:DeleteContextResponse' :: DeleteContextResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contextArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus