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

-- | The name of the action to delete.
deleteAction_actionName :: Lens.Lens' DeleteAction Prelude.Text
deleteAction_actionName :: (Text -> f Text) -> DeleteAction -> f DeleteAction
deleteAction_actionName = (DeleteAction -> Text)
-> (DeleteAction -> Text -> DeleteAction)
-> Lens DeleteAction DeleteAction Text Text
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 :: DeleteAction -> Request DeleteAction
request = Service -> DeleteAction -> Request DeleteAction
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAction)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteAction))
-> Logger
-> Service
-> Proxy DeleteAction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAction)))
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 -> DeleteActionResponse
DeleteActionResponse'
            (Maybe Text -> Int -> DeleteActionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteActionResponse)
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
"ActionArn")
            Either String (Int -> DeleteActionResponse)
-> Either String Int -> Either String DeleteActionResponse
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 DeleteAction

instance Prelude.NFData DeleteAction

instance Core.ToHeaders DeleteAction where
  toHeaders :: DeleteAction -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAction -> 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.DeleteAction" :: 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 DeleteAction where
  toJSON :: DeleteAction -> Value
toJSON DeleteAction' {Text
actionName :: Text
$sel:actionName:DeleteAction' :: DeleteAction -> 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
"ActionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
actionName)]
      )

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

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