{-# 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.UpdateTrial
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the display name of a trial.
module Amazonka.SageMaker.UpdateTrial
  ( -- * Creating a Request
    UpdateTrial (..),
    newUpdateTrial,

    -- * Request Lenses
    updateTrial_displayName,
    updateTrial_trialName,

    -- * Destructuring the Response
    UpdateTrialResponse (..),
    newUpdateTrialResponse,

    -- * Response Lenses
    updateTrialResponse_trialArn,
    updateTrialResponse_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:/ 'newUpdateTrial' smart constructor.
data UpdateTrial = UpdateTrial'
  { -- | The name of the trial as displayed. The name doesn\'t need to be unique.
    -- If @DisplayName@ isn\'t specified, @TrialName@ is displayed.
    UpdateTrial -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The name of the trial to update.
    UpdateTrial -> Text
trialName :: Prelude.Text
  }
  deriving (UpdateTrial -> UpdateTrial -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTrial -> UpdateTrial -> Bool
$c/= :: UpdateTrial -> UpdateTrial -> Bool
== :: UpdateTrial -> UpdateTrial -> Bool
$c== :: UpdateTrial -> UpdateTrial -> Bool
Prelude.Eq, ReadPrec [UpdateTrial]
ReadPrec UpdateTrial
Int -> ReadS UpdateTrial
ReadS [UpdateTrial]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTrial]
$creadListPrec :: ReadPrec [UpdateTrial]
readPrec :: ReadPrec UpdateTrial
$creadPrec :: ReadPrec UpdateTrial
readList :: ReadS [UpdateTrial]
$creadList :: ReadS [UpdateTrial]
readsPrec :: Int -> ReadS UpdateTrial
$creadsPrec :: Int -> ReadS UpdateTrial
Prelude.Read, Int -> UpdateTrial -> ShowS
[UpdateTrial] -> ShowS
UpdateTrial -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTrial] -> ShowS
$cshowList :: [UpdateTrial] -> ShowS
show :: UpdateTrial -> String
$cshow :: UpdateTrial -> String
showsPrec :: Int -> UpdateTrial -> ShowS
$cshowsPrec :: Int -> UpdateTrial -> ShowS
Prelude.Show, forall x. Rep UpdateTrial x -> UpdateTrial
forall x. UpdateTrial -> Rep UpdateTrial x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTrial x -> UpdateTrial
$cfrom :: forall x. UpdateTrial -> Rep UpdateTrial x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTrial' 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:
--
-- 'displayName', 'updateTrial_displayName' - The name of the trial as displayed. The name doesn\'t need to be unique.
-- If @DisplayName@ isn\'t specified, @TrialName@ is displayed.
--
-- 'trialName', 'updateTrial_trialName' - The name of the trial to update.
newUpdateTrial ::
  -- | 'trialName'
  Prelude.Text ->
  UpdateTrial
newUpdateTrial :: Text -> UpdateTrial
newUpdateTrial Text
pTrialName_ =
  UpdateTrial'
    { $sel:displayName:UpdateTrial' :: Maybe Text
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:trialName:UpdateTrial' :: Text
trialName = Text
pTrialName_
    }

-- | The name of the trial as displayed. The name doesn\'t need to be unique.
-- If @DisplayName@ isn\'t specified, @TrialName@ is displayed.
updateTrial_displayName :: Lens.Lens' UpdateTrial (Prelude.Maybe Prelude.Text)
updateTrial_displayName :: Lens' UpdateTrial (Maybe Text)
updateTrial_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTrial' {Maybe Text
displayName :: Maybe Text
$sel:displayName:UpdateTrial' :: UpdateTrial -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: UpdateTrial
s@UpdateTrial' {} Maybe Text
a -> UpdateTrial
s {$sel:displayName:UpdateTrial' :: Maybe Text
displayName = Maybe Text
a} :: UpdateTrial)

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

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

instance Prelude.NFData UpdateTrial where
  rnf :: UpdateTrial -> ()
rnf UpdateTrial' {Maybe Text
Text
trialName :: Text
displayName :: Maybe Text
$sel:trialName:UpdateTrial' :: UpdateTrial -> Text
$sel:displayName:UpdateTrial' :: UpdateTrial -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
trialName

instance Data.ToHeaders UpdateTrial where
  toHeaders :: UpdateTrial -> 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.UpdateTrial" :: 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 UpdateTrial where
  toJSON :: UpdateTrial -> Value
toJSON UpdateTrial' {Maybe Text
Text
trialName :: Text
displayName :: Maybe Text
$sel:trialName:UpdateTrial' :: UpdateTrial -> Text
$sel:displayName:UpdateTrial' :: UpdateTrial -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DisplayName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
displayName,
            forall a. a -> Maybe a
Prelude.Just (Key
"TrialName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
trialName)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateTrialResponse' 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', 'updateTrialResponse_trialArn' - The Amazon Resource Name (ARN) of the trial.
--
-- 'httpStatus', 'updateTrialResponse_httpStatus' - The response's http status code.
newUpdateTrialResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateTrialResponse
newUpdateTrialResponse :: Int -> UpdateTrialResponse
newUpdateTrialResponse Int
pHttpStatus_ =
  UpdateTrialResponse'
    { $sel:trialArn:UpdateTrialResponse' :: Maybe Text
trialArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateTrialResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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