{-# 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.UpdateAction
-- 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 an action.
module Amazonka.SageMaker.UpdateAction
  ( -- * Creating a Request
    UpdateAction (..),
    newUpdateAction,

    -- * Request Lenses
    updateAction_description,
    updateAction_properties,
    updateAction_propertiesToRemove,
    updateAction_status,
    updateAction_actionName,

    -- * Destructuring the Response
    UpdateActionResponse (..),
    newUpdateActionResponse,

    -- * Response Lenses
    updateActionResponse_actionArn,
    updateActionResponse_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:/ 'newUpdateAction' smart constructor.
data UpdateAction = UpdateAction'
  { -- | The new description for the action.
    UpdateAction -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The new list of properties. Overwrites the current property list.
    UpdateAction -> Maybe (HashMap Text Text)
properties :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A list of properties to remove.
    UpdateAction -> Maybe [Text]
propertiesToRemove :: Prelude.Maybe [Prelude.Text],
    -- | The new status for the action.
    UpdateAction -> Maybe ActionStatus
status :: Prelude.Maybe ActionStatus,
    -- | The name of the action to update.
    UpdateAction -> Text
actionName :: Prelude.Text
  }
  deriving (UpdateAction -> UpdateAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAction -> UpdateAction -> Bool
$c/= :: UpdateAction -> UpdateAction -> Bool
== :: UpdateAction -> UpdateAction -> Bool
$c== :: UpdateAction -> UpdateAction -> Bool
Prelude.Eq, ReadPrec [UpdateAction]
ReadPrec UpdateAction
Int -> ReadS UpdateAction
ReadS [UpdateAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAction]
$creadListPrec :: ReadPrec [UpdateAction]
readPrec :: ReadPrec UpdateAction
$creadPrec :: ReadPrec UpdateAction
readList :: ReadS [UpdateAction]
$creadList :: ReadS [UpdateAction]
readsPrec :: Int -> ReadS UpdateAction
$creadsPrec :: Int -> ReadS UpdateAction
Prelude.Read, Int -> UpdateAction -> ShowS
[UpdateAction] -> ShowS
UpdateAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAction] -> ShowS
$cshowList :: [UpdateAction] -> ShowS
show :: UpdateAction -> String
$cshow :: UpdateAction -> String
showsPrec :: Int -> UpdateAction -> ShowS
$cshowsPrec :: Int -> UpdateAction -> ShowS
Prelude.Show, forall x. Rep UpdateAction x -> UpdateAction
forall x. UpdateAction -> Rep UpdateAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAction x -> UpdateAction
$cfrom :: forall x. UpdateAction -> Rep UpdateAction x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAction' 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:
--
-- 'description', 'updateAction_description' - The new description for the action.
--
-- 'properties', 'updateAction_properties' - The new list of properties. Overwrites the current property list.
--
-- 'propertiesToRemove', 'updateAction_propertiesToRemove' - A list of properties to remove.
--
-- 'status', 'updateAction_status' - The new status for the action.
--
-- 'actionName', 'updateAction_actionName' - The name of the action to update.
newUpdateAction ::
  -- | 'actionName'
  Prelude.Text ->
  UpdateAction
newUpdateAction :: Text -> UpdateAction
newUpdateAction Text
pActionName_ =
  UpdateAction'
    { $sel:description:UpdateAction' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:properties:UpdateAction' :: Maybe (HashMap Text Text)
properties = forall a. Maybe a
Prelude.Nothing,
      $sel:propertiesToRemove:UpdateAction' :: Maybe [Text]
propertiesToRemove = forall a. Maybe a
Prelude.Nothing,
      $sel:status:UpdateAction' :: Maybe ActionStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:actionName:UpdateAction' :: Text
actionName = Text
pActionName_
    }

-- | The new description for the action.
updateAction_description :: Lens.Lens' UpdateAction (Prelude.Maybe Prelude.Text)
updateAction_description :: Lens' UpdateAction (Maybe Text)
updateAction_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAction' {Maybe Text
description :: Maybe Text
$sel:description:UpdateAction' :: UpdateAction -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateAction
s@UpdateAction' {} Maybe Text
a -> UpdateAction
s {$sel:description:UpdateAction' :: Maybe Text
description = Maybe Text
a} :: UpdateAction)

-- | The new list of properties. Overwrites the current property list.
updateAction_properties :: Lens.Lens' UpdateAction (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
updateAction_properties :: Lens' UpdateAction (Maybe (HashMap Text Text))
updateAction_properties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAction' {Maybe (HashMap Text Text)
properties :: Maybe (HashMap Text Text)
$sel:properties:UpdateAction' :: UpdateAction -> Maybe (HashMap Text Text)
properties} -> Maybe (HashMap Text Text)
properties) (\s :: UpdateAction
s@UpdateAction' {} Maybe (HashMap Text Text)
a -> UpdateAction
s {$sel:properties:UpdateAction' :: Maybe (HashMap Text Text)
properties = Maybe (HashMap Text Text)
a} :: UpdateAction) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of properties to remove.
updateAction_propertiesToRemove :: Lens.Lens' UpdateAction (Prelude.Maybe [Prelude.Text])
updateAction_propertiesToRemove :: Lens' UpdateAction (Maybe [Text])
updateAction_propertiesToRemove = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAction' {Maybe [Text]
propertiesToRemove :: Maybe [Text]
$sel:propertiesToRemove:UpdateAction' :: UpdateAction -> Maybe [Text]
propertiesToRemove} -> Maybe [Text]
propertiesToRemove) (\s :: UpdateAction
s@UpdateAction' {} Maybe [Text]
a -> UpdateAction
s {$sel:propertiesToRemove:UpdateAction' :: Maybe [Text]
propertiesToRemove = Maybe [Text]
a} :: UpdateAction) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The new status for the action.
updateAction_status :: Lens.Lens' UpdateAction (Prelude.Maybe ActionStatus)
updateAction_status :: Lens' UpdateAction (Maybe ActionStatus)
updateAction_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAction' {Maybe ActionStatus
status :: Maybe ActionStatus
$sel:status:UpdateAction' :: UpdateAction -> Maybe ActionStatus
status} -> Maybe ActionStatus
status) (\s :: UpdateAction
s@UpdateAction' {} Maybe ActionStatus
a -> UpdateAction
s {$sel:status:UpdateAction' :: Maybe ActionStatus
status = Maybe ActionStatus
a} :: UpdateAction)

-- | The name of the action to update.
updateAction_actionName :: Lens.Lens' UpdateAction Prelude.Text
updateAction_actionName :: Lens' UpdateAction Text
updateAction_actionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAction' {Text
actionName :: Text
$sel:actionName:UpdateAction' :: UpdateAction -> Text
actionName} -> Text
actionName) (\s :: UpdateAction
s@UpdateAction' {} Text
a -> UpdateAction
s {$sel:actionName:UpdateAction' :: Text
actionName = Text
a} :: UpdateAction)

instance Core.AWSRequest UpdateAction where
  type AWSResponse UpdateAction = UpdateActionResponse
  request :: (Service -> Service) -> UpdateAction -> Request UpdateAction
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 UpdateAction
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAction)))
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 -> UpdateActionResponse
UpdateActionResponse'
            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
"ActionArn")
            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 UpdateAction where
  hashWithSalt :: Int -> UpdateAction -> Int
hashWithSalt Int
_salt UpdateAction' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ActionStatus
Text
actionName :: Text
status :: Maybe ActionStatus
propertiesToRemove :: Maybe [Text]
properties :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:actionName:UpdateAction' :: UpdateAction -> Text
$sel:status:UpdateAction' :: UpdateAction -> Maybe ActionStatus
$sel:propertiesToRemove:UpdateAction' :: UpdateAction -> Maybe [Text]
$sel:properties:UpdateAction' :: UpdateAction -> Maybe (HashMap Text Text)
$sel:description:UpdateAction' :: UpdateAction -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
properties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
propertiesToRemove
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ActionStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
actionName

instance Prelude.NFData UpdateAction where
  rnf :: UpdateAction -> ()
rnf UpdateAction' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ActionStatus
Text
actionName :: Text
status :: Maybe ActionStatus
propertiesToRemove :: Maybe [Text]
properties :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:actionName:UpdateAction' :: UpdateAction -> Text
$sel:status:UpdateAction' :: UpdateAction -> Maybe ActionStatus
$sel:propertiesToRemove:UpdateAction' :: UpdateAction -> Maybe [Text]
$sel:properties:UpdateAction' :: UpdateAction -> Maybe (HashMap Text Text)
$sel:description:UpdateAction' :: UpdateAction -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
properties
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
propertiesToRemove
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ActionStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
actionName

instance Data.ToHeaders UpdateAction where
  toHeaders :: UpdateAction -> 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.UpdateAction" :: 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 UpdateAction where
  toJSON :: UpdateAction -> Value
toJSON UpdateAction' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ActionStatus
Text
actionName :: Text
status :: Maybe ActionStatus
propertiesToRemove :: Maybe [Text]
properties :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:actionName:UpdateAction' :: UpdateAction -> Text
$sel:status:UpdateAction' :: UpdateAction -> Maybe ActionStatus
$sel:propertiesToRemove:UpdateAction' :: UpdateAction -> Maybe [Text]
$sel:properties:UpdateAction' :: UpdateAction -> Maybe (HashMap Text Text)
$sel:description:UpdateAction' :: UpdateAction -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Description" 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
description,
            (Key
"Properties" 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 (HashMap Text Text)
properties,
            (Key
"PropertiesToRemove" 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]
propertiesToRemove,
            (Key
"Status" 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 ActionStatus
status,
            forall a. a -> Maybe a
Prelude.Just (Key
"ActionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
actionName)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateActionResponse' 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:
--
-- 'actionArn', 'updateActionResponse_actionArn' - The Amazon Resource Name (ARN) of the action.
--
-- 'httpStatus', 'updateActionResponse_httpStatus' - The response's http status code.
newUpdateActionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateActionResponse
newUpdateActionResponse :: Int -> UpdateActionResponse
newUpdateActionResponse Int
pHttpStatus_ =
  UpdateActionResponse'
    { $sel:actionArn:UpdateActionResponse' :: Maybe Text
actionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateActionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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