{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.AppSpecification
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.AppSpecification 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

-- | Configuration to run a processing job in a specified container image.
--
-- /See:/ 'newAppSpecification' smart constructor.
data AppSpecification = AppSpecification'
  { -- | The arguments for a container used to run a processing job.
    AppSpecification -> Maybe (NonEmpty Text)
containerArguments :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The entrypoint for a container used to run a processing job.
    AppSpecification -> Maybe (NonEmpty Text)
containerEntrypoint :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The container image to be run by the processing job.
    AppSpecification -> Text
imageUri :: Prelude.Text
  }
  deriving (AppSpecification -> AppSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AppSpecification -> AppSpecification -> Bool
$c/= :: AppSpecification -> AppSpecification -> Bool
== :: AppSpecification -> AppSpecification -> Bool
$c== :: AppSpecification -> AppSpecification -> Bool
Prelude.Eq, ReadPrec [AppSpecification]
ReadPrec AppSpecification
Int -> ReadS AppSpecification
ReadS [AppSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AppSpecification]
$creadListPrec :: ReadPrec [AppSpecification]
readPrec :: ReadPrec AppSpecification
$creadPrec :: ReadPrec AppSpecification
readList :: ReadS [AppSpecification]
$creadList :: ReadS [AppSpecification]
readsPrec :: Int -> ReadS AppSpecification
$creadsPrec :: Int -> ReadS AppSpecification
Prelude.Read, Int -> AppSpecification -> ShowS
[AppSpecification] -> ShowS
AppSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AppSpecification] -> ShowS
$cshowList :: [AppSpecification] -> ShowS
show :: AppSpecification -> String
$cshow :: AppSpecification -> String
showsPrec :: Int -> AppSpecification -> ShowS
$cshowsPrec :: Int -> AppSpecification -> ShowS
Prelude.Show, forall x. Rep AppSpecification x -> AppSpecification
forall x. AppSpecification -> Rep AppSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AppSpecification x -> AppSpecification
$cfrom :: forall x. AppSpecification -> Rep AppSpecification x
Prelude.Generic)

-- |
-- Create a value of 'AppSpecification' 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:
--
-- 'containerArguments', 'appSpecification_containerArguments' - The arguments for a container used to run a processing job.
--
-- 'containerEntrypoint', 'appSpecification_containerEntrypoint' - The entrypoint for a container used to run a processing job.
--
-- 'imageUri', 'appSpecification_imageUri' - The container image to be run by the processing job.
newAppSpecification ::
  -- | 'imageUri'
  Prelude.Text ->
  AppSpecification
newAppSpecification :: Text -> AppSpecification
newAppSpecification Text
pImageUri_ =
  AppSpecification'
    { $sel:containerArguments:AppSpecification' :: Maybe (NonEmpty Text)
containerArguments =
        forall a. Maybe a
Prelude.Nothing,
      $sel:containerEntrypoint:AppSpecification' :: Maybe (NonEmpty Text)
containerEntrypoint = forall a. Maybe a
Prelude.Nothing,
      $sel:imageUri:AppSpecification' :: Text
imageUri = Text
pImageUri_
    }

-- | The arguments for a container used to run a processing job.
appSpecification_containerArguments :: Lens.Lens' AppSpecification (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
appSpecification_containerArguments :: Lens' AppSpecification (Maybe (NonEmpty Text))
appSpecification_containerArguments = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppSpecification' {Maybe (NonEmpty Text)
containerArguments :: Maybe (NonEmpty Text)
$sel:containerArguments:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
containerArguments} -> Maybe (NonEmpty Text)
containerArguments) (\s :: AppSpecification
s@AppSpecification' {} Maybe (NonEmpty Text)
a -> AppSpecification
s {$sel:containerArguments:AppSpecification' :: Maybe (NonEmpty Text)
containerArguments = Maybe (NonEmpty Text)
a} :: AppSpecification) 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 entrypoint for a container used to run a processing job.
appSpecification_containerEntrypoint :: Lens.Lens' AppSpecification (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
appSpecification_containerEntrypoint :: Lens' AppSpecification (Maybe (NonEmpty Text))
appSpecification_containerEntrypoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppSpecification' {Maybe (NonEmpty Text)
containerEntrypoint :: Maybe (NonEmpty Text)
$sel:containerEntrypoint:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
containerEntrypoint} -> Maybe (NonEmpty Text)
containerEntrypoint) (\s :: AppSpecification
s@AppSpecification' {} Maybe (NonEmpty Text)
a -> AppSpecification
s {$sel:containerEntrypoint:AppSpecification' :: Maybe (NonEmpty Text)
containerEntrypoint = Maybe (NonEmpty Text)
a} :: AppSpecification) 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 container image to be run by the processing job.
appSpecification_imageUri :: Lens.Lens' AppSpecification Prelude.Text
appSpecification_imageUri :: Lens' AppSpecification Text
appSpecification_imageUri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppSpecification' {Text
imageUri :: Text
$sel:imageUri:AppSpecification' :: AppSpecification -> Text
imageUri} -> Text
imageUri) (\s :: AppSpecification
s@AppSpecification' {} Text
a -> AppSpecification
s {$sel:imageUri:AppSpecification' :: Text
imageUri = Text
a} :: AppSpecification)

instance Data.FromJSON AppSpecification where
  parseJSON :: Value -> Parser AppSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AppSpecification"
      ( \Object
x ->
          Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text) -> Text -> AppSpecification
AppSpecification'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ContainerArguments")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ContainerEntrypoint")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ImageUri")
      )

instance Prelude.Hashable AppSpecification where
  hashWithSalt :: Int -> AppSpecification -> Int
hashWithSalt Int
_salt AppSpecification' {Maybe (NonEmpty Text)
Text
imageUri :: Text
containerEntrypoint :: Maybe (NonEmpty Text)
containerArguments :: Maybe (NonEmpty Text)
$sel:imageUri:AppSpecification' :: AppSpecification -> Text
$sel:containerEntrypoint:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
$sel:containerArguments:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
containerArguments
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
containerEntrypoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
imageUri

instance Prelude.NFData AppSpecification where
  rnf :: AppSpecification -> ()
rnf AppSpecification' {Maybe (NonEmpty Text)
Text
imageUri :: Text
containerEntrypoint :: Maybe (NonEmpty Text)
containerArguments :: Maybe (NonEmpty Text)
$sel:imageUri:AppSpecification' :: AppSpecification -> Text
$sel:containerEntrypoint:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
$sel:containerArguments:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
containerArguments
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
containerEntrypoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
imageUri

instance Data.ToJSON AppSpecification where
  toJSON :: AppSpecification -> Value
toJSON AppSpecification' {Maybe (NonEmpty Text)
Text
imageUri :: Text
containerEntrypoint :: Maybe (NonEmpty Text)
containerArguments :: Maybe (NonEmpty Text)
$sel:imageUri:AppSpecification' :: AppSpecification -> Text
$sel:containerEntrypoint:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
$sel:containerArguments:AppSpecification' :: AppSpecification -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ContainerArguments" 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 (NonEmpty Text)
containerArguments,
            (Key
"ContainerEntrypoint" 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 (NonEmpty Text)
containerEntrypoint,
            forall a. a -> Maybe a
Prelude.Just (Key
"ImageUri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
imageUri)
          ]
      )