{-# 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-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)
--
-- 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.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:/ '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
(UpdateTrial -> UpdateTrial -> Bool)
-> (UpdateTrial -> UpdateTrial -> Bool) -> Eq UpdateTrial
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]
(Int -> ReadS UpdateTrial)
-> ReadS [UpdateTrial]
-> ReadPrec UpdateTrial
-> ReadPrec [UpdateTrial]
-> Read 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
(Int -> UpdateTrial -> ShowS)
-> (UpdateTrial -> String)
-> ([UpdateTrial] -> ShowS)
-> Show UpdateTrial
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. UpdateTrial -> Rep UpdateTrial x)
-> (forall x. Rep UpdateTrial x -> UpdateTrial)
-> Generic UpdateTrial
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' :: Maybe Text -> Text -> UpdateTrial
UpdateTrial'
    { $sel:displayName:UpdateTrial' :: Maybe Text
displayName = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> UpdateTrial -> f UpdateTrial
updateTrial_displayName = (UpdateTrial -> Maybe Text)
-> (UpdateTrial -> Maybe Text -> UpdateTrial)
-> Lens UpdateTrial UpdateTrial (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> UpdateTrial -> f UpdateTrial
updateTrial_trialName = (UpdateTrial -> Text)
-> (UpdateTrial -> Text -> UpdateTrial)
-> Lens UpdateTrial UpdateTrial Text Text
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 :: UpdateTrial -> Request UpdateTrial
request = Service -> UpdateTrial -> Request UpdateTrial
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateTrial
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTrial)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateTrial))
-> Logger
-> Service
-> Proxy UpdateTrial
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateTrial)))
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 -> UpdateTrialResponse
UpdateTrialResponse'
            (Maybe Text -> Int -> UpdateTrialResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateTrialResponse)
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 -> UpdateTrialResponse)
-> Either String Int -> Either String UpdateTrialResponse
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 UpdateTrial

instance Prelude.NFData UpdateTrial

instance Core.ToHeaders UpdateTrial where
  toHeaders :: UpdateTrial -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateTrial -> 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.UpdateTrial" :: 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DisplayName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
displayName,
            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 UpdateTrial where
  toPath :: UpdateTrial -> ByteString
toPath = ByteString -> UpdateTrial -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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