{-# 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.DeleteAction
-- 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 action.
module Amazonka.SageMaker.DeleteAction
  ( -- * Creating a Request
    DeleteAction (..),
    newDeleteAction,

    -- * Request Lenses
    deleteAction_actionName,

    -- * Destructuring the Response
    DeleteActionResponse (..),
    newDeleteActionResponse,

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

-- |
-- Create a value of 'DeleteAction' 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:
--
-- 'actionName', 'deleteAction_actionName' - The name of the action to delete.
newDeleteAction ::
  -- | 'actionName'
  Prelude.Text ->
  DeleteAction
newDeleteAction :: Text -> DeleteAction
newDeleteAction Text
pActionName_ =
  DeleteAction' {$sel:actionName:DeleteAction' :: Text
actionName = Text
pActionName_}

-- | The name of the action to delete.
deleteAction_actionName :: Lens.Lens' DeleteAction Prelude.Text
deleteAction_actionName :: Lens' DeleteAction Text
deleteAction_actionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAction' {Text
actionName :: Text
$sel:actionName:DeleteAction' :: DeleteAction -> Text
actionName} -> Text
actionName) (\s :: DeleteAction
s@DeleteAction' {} Text
a -> DeleteAction
s {$sel:actionName:DeleteAction' :: Text
actionName = Text
a} :: DeleteAction)

instance Core.AWSRequest DeleteAction where
  type AWSResponse DeleteAction = DeleteActionResponse
  request :: (Service -> Service) -> DeleteAction -> Request DeleteAction
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 DeleteAction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAction)))
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 -> DeleteActionResponse
DeleteActionResponse'
            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
"ActionArn")
            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 DeleteAction where
  hashWithSalt :: Int -> DeleteAction -> Int
hashWithSalt Int
_salt DeleteAction' {Text
actionName :: Text
$sel:actionName:DeleteAction' :: DeleteAction -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
actionName

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

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

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

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

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

-- |
-- Create a value of 'DeleteActionResponse' 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:
--
-- 'actionArn', 'deleteActionResponse_actionArn' - The Amazon Resource Name (ARN) of the action.
--
-- 'httpStatus', 'deleteActionResponse_httpStatus' - The response's http status code.
newDeleteActionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteActionResponse
newDeleteActionResponse :: Int -> DeleteActionResponse
newDeleteActionResponse Int
pHttpStatus_ =
  DeleteActionResponse'
    { $sel:actionArn:DeleteActionResponse' :: Maybe Text
actionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteActionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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