{-# 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.DeleteTrial
-- 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 the specified trial. All trial components that make up the trial
-- must be deleted first. Use the DescribeTrialComponent API to get the
-- list of trial components.
module Amazonka.SageMaker.DeleteTrial
  ( -- * Creating a Request
    DeleteTrial (..),
    newDeleteTrial,

    -- * Request Lenses
    deleteTrial_trialName,

    -- * Destructuring the Response
    DeleteTrialResponse (..),
    newDeleteTrialResponse,

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

-- |
-- Create a value of 'DeleteTrial' 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:
--
-- 'trialName', 'deleteTrial_trialName' - The name of the trial to delete.
newDeleteTrial ::
  -- | 'trialName'
  Prelude.Text ->
  DeleteTrial
newDeleteTrial :: Text -> DeleteTrial
newDeleteTrial Text
pTrialName_ =
  DeleteTrial' :: Text -> DeleteTrial
DeleteTrial' {$sel:trialName:DeleteTrial' :: Text
trialName = Text
pTrialName_}

-- | The name of the trial to delete.
deleteTrial_trialName :: Lens.Lens' DeleteTrial Prelude.Text
deleteTrial_trialName :: (Text -> f Text) -> DeleteTrial -> f DeleteTrial
deleteTrial_trialName = (DeleteTrial -> Text)
-> (DeleteTrial -> Text -> DeleteTrial)
-> Lens DeleteTrial DeleteTrial Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTrial' {Text
trialName :: Text
$sel:trialName:DeleteTrial' :: DeleteTrial -> Text
trialName} -> Text
trialName) (\s :: DeleteTrial
s@DeleteTrial' {} Text
a -> DeleteTrial
s {$sel:trialName:DeleteTrial' :: Text
trialName = Text
a} :: DeleteTrial)

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

instance Prelude.NFData DeleteTrial

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

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

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

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

-- |
-- Create a value of 'DeleteTrialResponse' 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:
--
-- 'trialArn', 'deleteTrialResponse_trialArn' - The Amazon Resource Name (ARN) of the trial that is being deleted.
--
-- 'httpStatus', 'deleteTrialResponse_httpStatus' - The response's http status code.
newDeleteTrialResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteTrialResponse
newDeleteTrialResponse :: Int -> DeleteTrialResponse
newDeleteTrialResponse Int
pHttpStatus_ =
  DeleteTrialResponse' :: Maybe Text -> Int -> DeleteTrialResponse
DeleteTrialResponse'
    { $sel:trialArn:DeleteTrialResponse' :: Maybe Text
trialArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteTrialResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData DeleteTrialResponse