{-# 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.CreateAppImageConfig
-- 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 configuration for running a SageMaker image as a KernelGateway
-- app. The configuration specifies the Amazon Elastic File System (EFS)
-- storage volume on the image, and a list of the kernels in the image.
module Amazonka.SageMaker.CreateAppImageConfig
  ( -- * Creating a Request
    CreateAppImageConfig (..),
    newCreateAppImageConfig,

    -- * Request Lenses
    createAppImageConfig_kernelGatewayImageConfig,
    createAppImageConfig_tags,
    createAppImageConfig_appImageConfigName,

    -- * Destructuring the Response
    CreateAppImageConfigResponse (..),
    newCreateAppImageConfigResponse,

    -- * Response Lenses
    createAppImageConfigResponse_appImageConfigArn,
    createAppImageConfigResponse_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:/ 'newCreateAppImageConfig' smart constructor.
data CreateAppImageConfig = CreateAppImageConfig'
  { -- | The KernelGatewayImageConfig. You can only specify one image kernel in
    -- the AppImageConfig API. This kernel will be shown to users before the
    -- image starts. Once the image runs, all kernels are visible in
    -- JupyterLab.
    CreateAppImageConfig -> Maybe KernelGatewayImageConfig
kernelGatewayImageConfig :: Prelude.Maybe KernelGatewayImageConfig,
    -- | A list of tags to apply to the AppImageConfig.
    CreateAppImageConfig -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name of the AppImageConfig. Must be unique to your account.
    CreateAppImageConfig -> Text
appImageConfigName :: Prelude.Text
  }
  deriving (CreateAppImageConfig -> CreateAppImageConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAppImageConfig -> CreateAppImageConfig -> Bool
$c/= :: CreateAppImageConfig -> CreateAppImageConfig -> Bool
== :: CreateAppImageConfig -> CreateAppImageConfig -> Bool
$c== :: CreateAppImageConfig -> CreateAppImageConfig -> Bool
Prelude.Eq, ReadPrec [CreateAppImageConfig]
ReadPrec CreateAppImageConfig
Int -> ReadS CreateAppImageConfig
ReadS [CreateAppImageConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAppImageConfig]
$creadListPrec :: ReadPrec [CreateAppImageConfig]
readPrec :: ReadPrec CreateAppImageConfig
$creadPrec :: ReadPrec CreateAppImageConfig
readList :: ReadS [CreateAppImageConfig]
$creadList :: ReadS [CreateAppImageConfig]
readsPrec :: Int -> ReadS CreateAppImageConfig
$creadsPrec :: Int -> ReadS CreateAppImageConfig
Prelude.Read, Int -> CreateAppImageConfig -> ShowS
[CreateAppImageConfig] -> ShowS
CreateAppImageConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAppImageConfig] -> ShowS
$cshowList :: [CreateAppImageConfig] -> ShowS
show :: CreateAppImageConfig -> String
$cshow :: CreateAppImageConfig -> String
showsPrec :: Int -> CreateAppImageConfig -> ShowS
$cshowsPrec :: Int -> CreateAppImageConfig -> ShowS
Prelude.Show, forall x. Rep CreateAppImageConfig x -> CreateAppImageConfig
forall x. CreateAppImageConfig -> Rep CreateAppImageConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAppImageConfig x -> CreateAppImageConfig
$cfrom :: forall x. CreateAppImageConfig -> Rep CreateAppImageConfig x
Prelude.Generic)

-- |
-- Create a value of 'CreateAppImageConfig' 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:
--
-- 'kernelGatewayImageConfig', 'createAppImageConfig_kernelGatewayImageConfig' - The KernelGatewayImageConfig. You can only specify one image kernel in
-- the AppImageConfig API. This kernel will be shown to users before the
-- image starts. Once the image runs, all kernels are visible in
-- JupyterLab.
--
-- 'tags', 'createAppImageConfig_tags' - A list of tags to apply to the AppImageConfig.
--
-- 'appImageConfigName', 'createAppImageConfig_appImageConfigName' - The name of the AppImageConfig. Must be unique to your account.
newCreateAppImageConfig ::
  -- | 'appImageConfigName'
  Prelude.Text ->
  CreateAppImageConfig
newCreateAppImageConfig :: Text -> CreateAppImageConfig
newCreateAppImageConfig Text
pAppImageConfigName_ =
  CreateAppImageConfig'
    { $sel:kernelGatewayImageConfig:CreateAppImageConfig' :: Maybe KernelGatewayImageConfig
kernelGatewayImageConfig =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateAppImageConfig' :: Maybe [Tag]
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:appImageConfigName:CreateAppImageConfig' :: Text
appImageConfigName = Text
pAppImageConfigName_
    }

-- | The KernelGatewayImageConfig. You can only specify one image kernel in
-- the AppImageConfig API. This kernel will be shown to users before the
-- image starts. Once the image runs, all kernels are visible in
-- JupyterLab.
createAppImageConfig_kernelGatewayImageConfig :: Lens.Lens' CreateAppImageConfig (Prelude.Maybe KernelGatewayImageConfig)
createAppImageConfig_kernelGatewayImageConfig :: Lens' CreateAppImageConfig (Maybe KernelGatewayImageConfig)
createAppImageConfig_kernelGatewayImageConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAppImageConfig' {Maybe KernelGatewayImageConfig
kernelGatewayImageConfig :: Maybe KernelGatewayImageConfig
$sel:kernelGatewayImageConfig:CreateAppImageConfig' :: CreateAppImageConfig -> Maybe KernelGatewayImageConfig
kernelGatewayImageConfig} -> Maybe KernelGatewayImageConfig
kernelGatewayImageConfig) (\s :: CreateAppImageConfig
s@CreateAppImageConfig' {} Maybe KernelGatewayImageConfig
a -> CreateAppImageConfig
s {$sel:kernelGatewayImageConfig:CreateAppImageConfig' :: Maybe KernelGatewayImageConfig
kernelGatewayImageConfig = Maybe KernelGatewayImageConfig
a} :: CreateAppImageConfig)

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

instance Core.AWSRequest CreateAppImageConfig where
  type
    AWSResponse CreateAppImageConfig =
      CreateAppImageConfigResponse
  request :: (Service -> Service)
-> CreateAppImageConfig -> Request CreateAppImageConfig
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 CreateAppImageConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateAppImageConfig)))
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 -> CreateAppImageConfigResponse
CreateAppImageConfigResponse'
            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
"AppImageConfigArn")
            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 CreateAppImageConfig where
  hashWithSalt :: Int -> CreateAppImageConfig -> Int
hashWithSalt Int
_salt CreateAppImageConfig' {Maybe [Tag]
Maybe KernelGatewayImageConfig
Text
appImageConfigName :: Text
tags :: Maybe [Tag]
kernelGatewayImageConfig :: Maybe KernelGatewayImageConfig
$sel:appImageConfigName:CreateAppImageConfig' :: CreateAppImageConfig -> Text
$sel:tags:CreateAppImageConfig' :: CreateAppImageConfig -> Maybe [Tag]
$sel:kernelGatewayImageConfig:CreateAppImageConfig' :: CreateAppImageConfig -> Maybe KernelGatewayImageConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe KernelGatewayImageConfig
kernelGatewayImageConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
appImageConfigName

instance Prelude.NFData CreateAppImageConfig where
  rnf :: CreateAppImageConfig -> ()
rnf CreateAppImageConfig' {Maybe [Tag]
Maybe KernelGatewayImageConfig
Text
appImageConfigName :: Text
tags :: Maybe [Tag]
kernelGatewayImageConfig :: Maybe KernelGatewayImageConfig
$sel:appImageConfigName:CreateAppImageConfig' :: CreateAppImageConfig -> Text
$sel:tags:CreateAppImageConfig' :: CreateAppImageConfig -> Maybe [Tag]
$sel:kernelGatewayImageConfig:CreateAppImageConfig' :: CreateAppImageConfig -> Maybe KernelGatewayImageConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe KernelGatewayImageConfig
kernelGatewayImageConfig
      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
appImageConfigName

instance Data.ToHeaders CreateAppImageConfig where
  toHeaders :: CreateAppImageConfig -> 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.CreateAppImageConfig" ::
                          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 CreateAppImageConfig where
  toJSON :: CreateAppImageConfig -> Value
toJSON CreateAppImageConfig' {Maybe [Tag]
Maybe KernelGatewayImageConfig
Text
appImageConfigName :: Text
tags :: Maybe [Tag]
kernelGatewayImageConfig :: Maybe KernelGatewayImageConfig
$sel:appImageConfigName:CreateAppImageConfig' :: CreateAppImageConfig -> Text
$sel:tags:CreateAppImageConfig' :: CreateAppImageConfig -> Maybe [Tag]
$sel:kernelGatewayImageConfig:CreateAppImageConfig' :: CreateAppImageConfig -> Maybe KernelGatewayImageConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"KernelGatewayImageConfig" 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 KernelGatewayImageConfig
kernelGatewayImageConfig,
            (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
"AppImageConfigName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
appImageConfigName)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateAppImageConfigResponse' 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:
--
-- 'appImageConfigArn', 'createAppImageConfigResponse_appImageConfigArn' - The Amazon Resource Name (ARN) of the AppImageConfig.
--
-- 'httpStatus', 'createAppImageConfigResponse_httpStatus' - The response's http status code.
newCreateAppImageConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateAppImageConfigResponse
newCreateAppImageConfigResponse :: Int -> CreateAppImageConfigResponse
newCreateAppImageConfigResponse Int
pHttpStatus_ =
  CreateAppImageConfigResponse'
    { $sel:appImageConfigArn:CreateAppImageConfigResponse' :: Maybe Text
appImageConfigArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateAppImageConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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