{-# 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.UpdateExperiment
-- 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)
--
-- Adds, updates, or removes the description of an experiment. Updates the
-- display name of an experiment.
module Amazonka.SageMaker.UpdateExperiment
  ( -- * Creating a Request
    UpdateExperiment (..),
    newUpdateExperiment,

    -- * Request Lenses
    updateExperiment_displayName,
    updateExperiment_description,
    updateExperiment_experimentName,

    -- * Destructuring the Response
    UpdateExperimentResponse (..),
    newUpdateExperimentResponse,

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

-- |
-- Create a value of 'UpdateExperiment' 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', 'updateExperiment_displayName' - The name of the experiment as displayed. The name doesn\'t need to be
-- unique. If @DisplayName@ isn\'t specified, @ExperimentName@ is
-- displayed.
--
-- 'description', 'updateExperiment_description' - The description of the experiment.
--
-- 'experimentName', 'updateExperiment_experimentName' - The name of the experiment to update.
newUpdateExperiment ::
  -- | 'experimentName'
  Prelude.Text ->
  UpdateExperiment
newUpdateExperiment :: Text -> UpdateExperiment
newUpdateExperiment Text
pExperimentName_ =
  UpdateExperiment' :: Maybe Text -> Maybe Text -> Text -> UpdateExperiment
UpdateExperiment'
    { $sel:displayName:UpdateExperiment' :: Maybe Text
displayName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateExperiment' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:experimentName:UpdateExperiment' :: Text
experimentName = Text
pExperimentName_
    }

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

-- | The description of the experiment.
updateExperiment_description :: Lens.Lens' UpdateExperiment (Prelude.Maybe Prelude.Text)
updateExperiment_description :: (Maybe Text -> f (Maybe Text))
-> UpdateExperiment -> f UpdateExperiment
updateExperiment_description = (UpdateExperiment -> Maybe Text)
-> (UpdateExperiment -> Maybe Text -> UpdateExperiment)
-> Lens UpdateExperiment UpdateExperiment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateExperiment' {Maybe Text
description :: Maybe Text
$sel:description:UpdateExperiment' :: UpdateExperiment -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateExperiment
s@UpdateExperiment' {} Maybe Text
a -> UpdateExperiment
s {$sel:description:UpdateExperiment' :: Maybe Text
description = Maybe Text
a} :: UpdateExperiment)

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

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

instance Prelude.NFData UpdateExperiment

instance Core.ToHeaders UpdateExperiment where
  toHeaders :: UpdateExperiment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateExperiment -> 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.UpdateExperiment" :: 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 UpdateExperiment where
  toJSON :: UpdateExperiment -> Value
toJSON UpdateExperiment' {Maybe Text
Text
experimentName :: Text
description :: Maybe Text
displayName :: Maybe Text
$sel:experimentName:UpdateExperiment' :: UpdateExperiment -> Text
$sel:description:UpdateExperiment' :: UpdateExperiment -> Maybe Text
$sel:displayName:UpdateExperiment' :: UpdateExperiment -> 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,
            (Text
"Description" 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
description,
            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 UpdateExperiment where
  toPath :: UpdateExperiment -> ByteString
toPath = ByteString -> UpdateExperiment -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'UpdateExperimentResponse' 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', 'updateExperimentResponse_experimentArn' - The Amazon Resource Name (ARN) of the experiment.
--
-- 'httpStatus', 'updateExperimentResponse_httpStatus' - The response's http status code.
newUpdateExperimentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateExperimentResponse
newUpdateExperimentResponse :: Int -> UpdateExperimentResponse
newUpdateExperimentResponse Int
pHttpStatus_ =
  UpdateExperimentResponse' :: Maybe Text -> Int -> UpdateExperimentResponse
UpdateExperimentResponse'
    { $sel:experimentArn:UpdateExperimentResponse' :: Maybe Text
experimentArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateExperimentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData UpdateExperimentResponse