{-# 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.UpdateImage
-- 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 properties of a SageMaker image. To change the image\'s
-- tags, use the AddTags and DeleteTags APIs.
module Amazonka.SageMaker.UpdateImage
  ( -- * Creating a Request
    UpdateImage (..),
    newUpdateImage,

    -- * Request Lenses
    updateImage_deleteProperties,
    updateImage_description,
    updateImage_displayName,
    updateImage_roleArn,
    updateImage_imageName,

    -- * Destructuring the Response
    UpdateImageResponse (..),
    newUpdateImageResponse,

    -- * Response Lenses
    updateImageResponse_imageArn,
    updateImageResponse_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:/ 'newUpdateImage' smart constructor.
data UpdateImage = UpdateImage'
  { -- | A list of properties to delete. Only the @Description@ and @DisplayName@
    -- properties can be deleted.
    UpdateImage -> Maybe [Text]
deleteProperties :: Prelude.Maybe [Prelude.Text],
    -- | The new description for the image.
    UpdateImage -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The new display name for the image.
    UpdateImage -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | The new ARN for the IAM role that enables Amazon SageMaker to perform
    -- tasks on your behalf.
    UpdateImage -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the image to update.
    UpdateImage -> Text
imageName :: Prelude.Text
  }
  deriving (UpdateImage -> UpdateImage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateImage -> UpdateImage -> Bool
$c/= :: UpdateImage -> UpdateImage -> Bool
== :: UpdateImage -> UpdateImage -> Bool
$c== :: UpdateImage -> UpdateImage -> Bool
Prelude.Eq, ReadPrec [UpdateImage]
ReadPrec UpdateImage
Int -> ReadS UpdateImage
ReadS [UpdateImage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateImage]
$creadListPrec :: ReadPrec [UpdateImage]
readPrec :: ReadPrec UpdateImage
$creadPrec :: ReadPrec UpdateImage
readList :: ReadS [UpdateImage]
$creadList :: ReadS [UpdateImage]
readsPrec :: Int -> ReadS UpdateImage
$creadsPrec :: Int -> ReadS UpdateImage
Prelude.Read, Int -> UpdateImage -> ShowS
[UpdateImage] -> ShowS
UpdateImage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateImage] -> ShowS
$cshowList :: [UpdateImage] -> ShowS
show :: UpdateImage -> String
$cshow :: UpdateImage -> String
showsPrec :: Int -> UpdateImage -> ShowS
$cshowsPrec :: Int -> UpdateImage -> ShowS
Prelude.Show, forall x. Rep UpdateImage x -> UpdateImage
forall x. UpdateImage -> Rep UpdateImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateImage x -> UpdateImage
$cfrom :: forall x. UpdateImage -> Rep UpdateImage x
Prelude.Generic)

-- |
-- Create a value of 'UpdateImage' 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:
--
-- 'deleteProperties', 'updateImage_deleteProperties' - A list of properties to delete. Only the @Description@ and @DisplayName@
-- properties can be deleted.
--
-- 'description', 'updateImage_description' - The new description for the image.
--
-- 'displayName', 'updateImage_displayName' - The new display name for the image.
--
-- 'roleArn', 'updateImage_roleArn' - The new ARN for the IAM role that enables Amazon SageMaker to perform
-- tasks on your behalf.
--
-- 'imageName', 'updateImage_imageName' - The name of the image to update.
newUpdateImage ::
  -- | 'imageName'
  Prelude.Text ->
  UpdateImage
newUpdateImage :: Text -> UpdateImage
newUpdateImage Text
pImageName_ =
  UpdateImage'
    { $sel:deleteProperties:UpdateImage' :: Maybe [Text]
deleteProperties = forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateImage' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:UpdateImage' :: Maybe Text
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:UpdateImage' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:imageName:UpdateImage' :: Text
imageName = Text
pImageName_
    }

-- | A list of properties to delete. Only the @Description@ and @DisplayName@
-- properties can be deleted.
updateImage_deleteProperties :: Lens.Lens' UpdateImage (Prelude.Maybe [Prelude.Text])
updateImage_deleteProperties :: Lens' UpdateImage (Maybe [Text])
updateImage_deleteProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImage' {Maybe [Text]
deleteProperties :: Maybe [Text]
$sel:deleteProperties:UpdateImage' :: UpdateImage -> Maybe [Text]
deleteProperties} -> Maybe [Text]
deleteProperties) (\s :: UpdateImage
s@UpdateImage' {} Maybe [Text]
a -> UpdateImage
s {$sel:deleteProperties:UpdateImage' :: Maybe [Text]
deleteProperties = Maybe [Text]
a} :: UpdateImage) 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 description for the image.
updateImage_description :: Lens.Lens' UpdateImage (Prelude.Maybe Prelude.Text)
updateImage_description :: Lens' UpdateImage (Maybe Text)
updateImage_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImage' {Maybe Text
description :: Maybe Text
$sel:description:UpdateImage' :: UpdateImage -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateImage
s@UpdateImage' {} Maybe Text
a -> UpdateImage
s {$sel:description:UpdateImage' :: Maybe Text
description = Maybe Text
a} :: UpdateImage)

-- | The new display name for the image.
updateImage_displayName :: Lens.Lens' UpdateImage (Prelude.Maybe Prelude.Text)
updateImage_displayName :: Lens' UpdateImage (Maybe Text)
updateImage_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImage' {Maybe Text
displayName :: Maybe Text
$sel:displayName:UpdateImage' :: UpdateImage -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: UpdateImage
s@UpdateImage' {} Maybe Text
a -> UpdateImage
s {$sel:displayName:UpdateImage' :: Maybe Text
displayName = Maybe Text
a} :: UpdateImage)

-- | The new ARN for the IAM role that enables Amazon SageMaker to perform
-- tasks on your behalf.
updateImage_roleArn :: Lens.Lens' UpdateImage (Prelude.Maybe Prelude.Text)
updateImage_roleArn :: Lens' UpdateImage (Maybe Text)
updateImage_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImage' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:UpdateImage' :: UpdateImage -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: UpdateImage
s@UpdateImage' {} Maybe Text
a -> UpdateImage
s {$sel:roleArn:UpdateImage' :: Maybe Text
roleArn = Maybe Text
a} :: UpdateImage)

-- | The name of the image to update.
updateImage_imageName :: Lens.Lens' UpdateImage Prelude.Text
updateImage_imageName :: Lens' UpdateImage Text
updateImage_imageName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImage' {Text
imageName :: Text
$sel:imageName:UpdateImage' :: UpdateImage -> Text
imageName} -> Text
imageName) (\s :: UpdateImage
s@UpdateImage' {} Text
a -> UpdateImage
s {$sel:imageName:UpdateImage' :: Text
imageName = Text
a} :: UpdateImage)

instance Core.AWSRequest UpdateImage where
  type AWSResponse UpdateImage = UpdateImageResponse
  request :: (Service -> Service) -> UpdateImage -> Request UpdateImage
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 UpdateImage
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateImage)))
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 -> UpdateImageResponse
UpdateImageResponse'
            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
"ImageArn")
            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 UpdateImage where
  hashWithSalt :: Int -> UpdateImage -> Int
hashWithSalt Int
_salt UpdateImage' {Maybe [Text]
Maybe Text
Text
imageName :: Text
roleArn :: Maybe Text
displayName :: Maybe Text
description :: Maybe Text
deleteProperties :: Maybe [Text]
$sel:imageName:UpdateImage' :: UpdateImage -> Text
$sel:roleArn:UpdateImage' :: UpdateImage -> Maybe Text
$sel:displayName:UpdateImage' :: UpdateImage -> Maybe Text
$sel:description:UpdateImage' :: UpdateImage -> Maybe Text
$sel:deleteProperties:UpdateImage' :: UpdateImage -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
deleteProperties
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
displayName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
imageName

instance Prelude.NFData UpdateImage where
  rnf :: UpdateImage -> ()
rnf UpdateImage' {Maybe [Text]
Maybe Text
Text
imageName :: Text
roleArn :: Maybe Text
displayName :: Maybe Text
description :: Maybe Text
deleteProperties :: Maybe [Text]
$sel:imageName:UpdateImage' :: UpdateImage -> Text
$sel:roleArn:UpdateImage' :: UpdateImage -> Maybe Text
$sel:displayName:UpdateImage' :: UpdateImage -> Maybe Text
$sel:description:UpdateImage' :: UpdateImage -> Maybe Text
$sel:deleteProperties:UpdateImage' :: UpdateImage -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
deleteProperties
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Text
displayName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
imageName

instance Data.ToHeaders UpdateImage where
  toHeaders :: UpdateImage -> 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.UpdateImage" :: 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 UpdateImage where
  toJSON :: UpdateImage -> Value
toJSON UpdateImage' {Maybe [Text]
Maybe Text
Text
imageName :: Text
roleArn :: Maybe Text
displayName :: Maybe Text
description :: Maybe Text
deleteProperties :: Maybe [Text]
$sel:imageName:UpdateImage' :: UpdateImage -> Text
$sel:roleArn:UpdateImage' :: UpdateImage -> Maybe Text
$sel:displayName:UpdateImage' :: UpdateImage -> Maybe Text
$sel:description:UpdateImage' :: UpdateImage -> Maybe Text
$sel:deleteProperties:UpdateImage' :: UpdateImage -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DeleteProperties" 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]
deleteProperties,
            (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
"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,
            (Key
"RoleArn" 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
roleArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"ImageName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
imageName)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateImageResponse' 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:
--
-- 'imageArn', 'updateImageResponse_imageArn' - The ARN of the image.
--
-- 'httpStatus', 'updateImageResponse_httpStatus' - The response's http status code.
newUpdateImageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateImageResponse
newUpdateImageResponse :: Int -> UpdateImageResponse
newUpdateImageResponse Int
pHttpStatus_ =
  UpdateImageResponse'
    { $sel:imageArn:UpdateImageResponse' :: Maybe Text
imageArn = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateImageResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ARN of the image.
updateImageResponse_imageArn :: Lens.Lens' UpdateImageResponse (Prelude.Maybe Prelude.Text)
updateImageResponse_imageArn :: Lens' UpdateImageResponse (Maybe Text)
updateImageResponse_imageArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateImageResponse' {Maybe Text
imageArn :: Maybe Text
$sel:imageArn:UpdateImageResponse' :: UpdateImageResponse -> Maybe Text
imageArn} -> Maybe Text
imageArn) (\s :: UpdateImageResponse
s@UpdateImageResponse' {} Maybe Text
a -> UpdateImageResponse
s {$sel:imageArn:UpdateImageResponse' :: Maybe Text
imageArn = Maybe Text
a} :: UpdateImageResponse)

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

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