{-# 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.CreateImage
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a custom SageMaker image. A SageMaker image is a set of image
-- versions. Each image version represents a container image stored in
-- Amazon Elastic Container Registry (ECR). For more information, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/studio-byoi.html Bring your own SageMaker image>.
module Amazonka.SageMaker.CreateImage
  ( -- * Creating a Request
    CreateImage (..),
    newCreateImage,

    -- * Request Lenses
    createImage_description,
    createImage_displayName,
    createImage_tags,
    createImage_imageName,
    createImage_roleArn,

    -- * Destructuring the Response
    CreateImageResponse (..),
    newCreateImageResponse,

    -- * Response Lenses
    createImageResponse_imageArn,
    createImageResponse_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:/ 'newCreateImage' smart constructor.
data CreateImage = CreateImage'
  { -- | The description of the image.
    CreateImage -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The display name of the image. If not provided, @ImageName@ is
    -- displayed.
    CreateImage -> Maybe Text
displayName :: Prelude.Maybe Prelude.Text,
    -- | A list of tags to apply to the image.
    CreateImage -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the image. Must be unique to your account.
    CreateImage -> Text
imageName :: Prelude.Text,
    -- | The ARN of an IAM role that enables Amazon SageMaker to perform tasks on
    -- your behalf.
    CreateImage -> Text
roleArn :: Prelude.Text
  }
  deriving (CreateImage -> CreateImage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateImage -> CreateImage -> Bool
$c/= :: CreateImage -> CreateImage -> Bool
== :: CreateImage -> CreateImage -> Bool
$c== :: CreateImage -> CreateImage -> Bool
Prelude.Eq, ReadPrec [CreateImage]
ReadPrec CreateImage
Int -> ReadS CreateImage
ReadS [CreateImage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateImage]
$creadListPrec :: ReadPrec [CreateImage]
readPrec :: ReadPrec CreateImage
$creadPrec :: ReadPrec CreateImage
readList :: ReadS [CreateImage]
$creadList :: ReadS [CreateImage]
readsPrec :: Int -> ReadS CreateImage
$creadsPrec :: Int -> ReadS CreateImage
Prelude.Read, Int -> CreateImage -> ShowS
[CreateImage] -> ShowS
CreateImage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateImage] -> ShowS
$cshowList :: [CreateImage] -> ShowS
show :: CreateImage -> String
$cshow :: CreateImage -> String
showsPrec :: Int -> CreateImage -> ShowS
$cshowsPrec :: Int -> CreateImage -> ShowS
Prelude.Show, forall x. Rep CreateImage x -> CreateImage
forall x. CreateImage -> Rep CreateImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateImage x -> CreateImage
$cfrom :: forall x. CreateImage -> Rep CreateImage x
Prelude.Generic)

-- |
-- Create a value of 'CreateImage' 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', 'createImage_description' - The description of the image.
--
-- 'displayName', 'createImage_displayName' - The display name of the image. If not provided, @ImageName@ is
-- displayed.
--
-- 'tags', 'createImage_tags' - A list of tags to apply to the image.
--
-- 'imageName', 'createImage_imageName' - The name of the image. Must be unique to your account.
--
-- 'roleArn', 'createImage_roleArn' - The ARN of an IAM role that enables Amazon SageMaker to perform tasks on
-- your behalf.
newCreateImage ::
  -- | 'imageName'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  CreateImage
newCreateImage :: Text -> Text -> CreateImage
newCreateImage Text
pImageName_ Text
pRoleArn_ =
  CreateImage'
    { $sel:description:CreateImage' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:displayName:CreateImage' :: Maybe Text
displayName = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateImage' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:imageName:CreateImage' :: Text
imageName = Text
pImageName_,
      $sel:roleArn:CreateImage' :: Text
roleArn = Text
pRoleArn_
    }

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

-- | The display name of the image. If not provided, @ImageName@ is
-- displayed.
createImage_displayName :: Lens.Lens' CreateImage (Prelude.Maybe Prelude.Text)
createImage_displayName :: Lens' CreateImage (Maybe Text)
createImage_displayName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImage' {Maybe Text
displayName :: Maybe Text
$sel:displayName:CreateImage' :: CreateImage -> Maybe Text
displayName} -> Maybe Text
displayName) (\s :: CreateImage
s@CreateImage' {} Maybe Text
a -> CreateImage
s {$sel:displayName:CreateImage' :: Maybe Text
displayName = Maybe Text
a} :: CreateImage)

-- | A list of tags to apply to the image.
createImage_tags :: Lens.Lens' CreateImage (Prelude.Maybe [Tag])
createImage_tags :: Lens' CreateImage (Maybe [Tag])
createImage_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImage' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateImage' :: CreateImage -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateImage
s@CreateImage' {} Maybe [Tag]
a -> CreateImage
s {$sel:tags:CreateImage' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateImage) 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 name of the image. Must be unique to your account.
createImage_imageName :: Lens.Lens' CreateImage Prelude.Text
createImage_imageName :: Lens' CreateImage Text
createImage_imageName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImage' {Text
imageName :: Text
$sel:imageName:CreateImage' :: CreateImage -> Text
imageName} -> Text
imageName) (\s :: CreateImage
s@CreateImage' {} Text
a -> CreateImage
s {$sel:imageName:CreateImage' :: Text
imageName = Text
a} :: CreateImage)

-- | The ARN of an IAM role that enables Amazon SageMaker to perform tasks on
-- your behalf.
createImage_roleArn :: Lens.Lens' CreateImage Prelude.Text
createImage_roleArn :: Lens' CreateImage Text
createImage_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateImage' {Text
roleArn :: Text
$sel:roleArn:CreateImage' :: CreateImage -> Text
roleArn} -> Text
roleArn) (\s :: CreateImage
s@CreateImage' {} Text
a -> CreateImage
s {$sel:roleArn:CreateImage' :: Text
roleArn = Text
a} :: CreateImage)

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

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

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

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

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

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

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

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

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

instance Prelude.NFData CreateImageResponse where
  rnf :: CreateImageResponse -> ()
rnf CreateImageResponse' {Int
Maybe Text
httpStatus :: Int
imageArn :: Maybe Text
$sel:httpStatus:CreateImageResponse' :: CreateImageResponse -> Int
$sel:imageArn:CreateImageResponse' :: CreateImageResponse -> 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