{-# 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-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)
--
-- 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.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:/ 'newDeleteContext' smart constructor.
data DeleteContext = DeleteContext'
  { -- | The name of the context to delete.
    DeleteContext -> Text
contextName :: Prelude.Text
  }
  deriving (DeleteContext -> DeleteContext -> Bool
(DeleteContext -> DeleteContext -> Bool)
-> (DeleteContext -> DeleteContext -> Bool) -> Eq DeleteContext
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]
(Int -> ReadS DeleteContext)
-> ReadS [DeleteContext]
-> ReadPrec DeleteContext
-> ReadPrec [DeleteContext]
-> Read 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
(Int -> DeleteContext -> ShowS)
-> (DeleteContext -> String)
-> ([DeleteContext] -> ShowS)
-> Show DeleteContext
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. DeleteContext -> Rep DeleteContext x)
-> (forall x. Rep DeleteContext x -> DeleteContext)
-> Generic DeleteContext
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' :: Text -> DeleteContext
DeleteContext' {$sel:contextName:DeleteContext' :: Text
contextName = Text
pContextName_}

-- | The name of the context to delete.
deleteContext_contextName :: Lens.Lens' DeleteContext Prelude.Text
deleteContext_contextName :: (Text -> f Text) -> DeleteContext -> f DeleteContext
deleteContext_contextName = (DeleteContext -> Text)
-> (DeleteContext -> Text -> DeleteContext)
-> Lens DeleteContext DeleteContext Text Text
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 :: DeleteContext -> Request DeleteContext
request = Service -> DeleteContext -> Request DeleteContext
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteContext
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteContext)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteContext))
-> Logger
-> Service
-> Proxy DeleteContext
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteContext)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DeleteContextResponse
DeleteContextResponse'
            (Maybe Text -> Int -> DeleteContextResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteContextResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ContextArn")
            Either String (Int -> DeleteContextResponse)
-> Either String Int -> Either String DeleteContextResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteContext

instance Prelude.NFData DeleteContext

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

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

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

instance Core.ToQuery DeleteContext where
  toQuery :: DeleteContext -> QueryString
toQuery = QueryString -> DeleteContext -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteContextResponse -> DeleteContextResponse -> Bool)
-> (DeleteContextResponse -> DeleteContextResponse -> Bool)
-> Eq DeleteContextResponse
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]
(Int -> ReadS DeleteContextResponse)
-> ReadS [DeleteContextResponse]
-> ReadPrec DeleteContextResponse
-> ReadPrec [DeleteContextResponse]
-> Read 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
(Int -> DeleteContextResponse -> ShowS)
-> (DeleteContextResponse -> String)
-> ([DeleteContextResponse] -> ShowS)
-> Show DeleteContextResponse
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. DeleteContextResponse -> Rep DeleteContextResponse x)
-> (forall x. Rep DeleteContextResponse x -> DeleteContextResponse)
-> Generic DeleteContextResponse
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' :: Maybe Text -> Int -> DeleteContextResponse
DeleteContextResponse'
    { $sel:contextArn:DeleteContextResponse' :: Maybe Text
contextArn =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteContextResponse -> f DeleteContextResponse
deleteContextResponse_contextArn = (DeleteContextResponse -> Maybe Text)
-> (DeleteContextResponse -> Maybe Text -> DeleteContextResponse)
-> Lens
     DeleteContextResponse
     DeleteContextResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int) -> DeleteContextResponse -> f DeleteContextResponse
deleteContextResponse_httpStatus = (DeleteContextResponse -> Int)
-> (DeleteContextResponse -> Int -> DeleteContextResponse)
-> Lens DeleteContextResponse DeleteContextResponse Int Int
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