{-# 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.DeleteExperiment
-- 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 SageMaker experiment. All trials associated with the
-- experiment must be deleted first. Use the ListTrials API to get a list
-- of the trials associated with the experiment.
module Amazonka.SageMaker.DeleteExperiment
  ( -- * Creating a Request
    DeleteExperiment (..),
    newDeleteExperiment,

    -- * Request Lenses
    deleteExperiment_experimentName,

    -- * Destructuring the Response
    DeleteExperimentResponse (..),
    newDeleteExperimentResponse,

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

-- |
-- Create a value of 'DeleteExperiment' 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:
--
-- 'experimentName', 'deleteExperiment_experimentName' - The name of the experiment to delete.
newDeleteExperiment ::
  -- | 'experimentName'
  Prelude.Text ->
  DeleteExperiment
newDeleteExperiment :: Text -> DeleteExperiment
newDeleteExperiment Text
pExperimentName_ =
  DeleteExperiment' :: Text -> DeleteExperiment
DeleteExperiment'
    { $sel:experimentName:DeleteExperiment' :: Text
experimentName =
        Text
pExperimentName_
    }

-- | The name of the experiment to delete.
deleteExperiment_experimentName :: Lens.Lens' DeleteExperiment Prelude.Text
deleteExperiment_experimentName :: (Text -> f Text) -> DeleteExperiment -> f DeleteExperiment
deleteExperiment_experimentName = (DeleteExperiment -> Text)
-> (DeleteExperiment -> Text -> DeleteExperiment)
-> Lens DeleteExperiment DeleteExperiment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteExperiment' {Text
experimentName :: Text
$sel:experimentName:DeleteExperiment' :: DeleteExperiment -> Text
experimentName} -> Text
experimentName) (\s :: DeleteExperiment
s@DeleteExperiment' {} Text
a -> DeleteExperiment
s {$sel:experimentName:DeleteExperiment' :: Text
experimentName = Text
a} :: DeleteExperiment)

instance Core.AWSRequest DeleteExperiment where
  type
    AWSResponse DeleteExperiment =
      DeleteExperimentResponse
  request :: DeleteExperiment -> Request DeleteExperiment
request = Service -> DeleteExperiment -> Request DeleteExperiment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteExperiment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteExperiment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteExperiment))
-> Logger
-> Service
-> Proxy DeleteExperiment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteExperiment)))
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 -> DeleteExperimentResponse
DeleteExperimentResponse'
            (Maybe Text -> Int -> DeleteExperimentResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteExperimentResponse)
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
"ExperimentArn")
            Either String (Int -> DeleteExperimentResponse)
-> Either String Int -> Either String DeleteExperimentResponse
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 DeleteExperiment

instance Prelude.NFData DeleteExperiment

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

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

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

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

-- |
-- Create a value of 'DeleteExperimentResponse' 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:
--
-- 'experimentArn', 'deleteExperimentResponse_experimentArn' - The Amazon Resource Name (ARN) of the experiment that is being deleted.
--
-- 'httpStatus', 'deleteExperimentResponse_httpStatus' - The response's http status code.
newDeleteExperimentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteExperimentResponse
newDeleteExperimentResponse :: Int -> DeleteExperimentResponse
newDeleteExperimentResponse Int
pHttpStatus_ =
  DeleteExperimentResponse' :: Maybe Text -> Int -> DeleteExperimentResponse
DeleteExperimentResponse'
    { $sel:experimentArn:DeleteExperimentResponse' :: Maybe Text
experimentArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteExperimentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the experiment that is being deleted.
deleteExperimentResponse_experimentArn :: Lens.Lens' DeleteExperimentResponse (Prelude.Maybe Prelude.Text)
deleteExperimentResponse_experimentArn :: (Maybe Text -> f (Maybe Text))
-> DeleteExperimentResponse -> f DeleteExperimentResponse
deleteExperimentResponse_experimentArn = (DeleteExperimentResponse -> Maybe Text)
-> (DeleteExperimentResponse
    -> Maybe Text -> DeleteExperimentResponse)
-> Lens
     DeleteExperimentResponse
     DeleteExperimentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteExperimentResponse' {Maybe Text
experimentArn :: Maybe Text
$sel:experimentArn:DeleteExperimentResponse' :: DeleteExperimentResponse -> Maybe Text
experimentArn} -> Maybe Text
experimentArn) (\s :: DeleteExperimentResponse
s@DeleteExperimentResponse' {} Maybe Text
a -> DeleteExperimentResponse
s {$sel:experimentArn:DeleteExperimentResponse' :: Maybe Text
experimentArn = Maybe Text
a} :: DeleteExperimentResponse)

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

instance Prelude.NFData DeleteExperimentResponse