{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.AppSpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(AppSpecification -> AppSpecification -> Bool)
-> (AppSpecification -> AppSpecification -> Bool)
-> Eq AppSpecification
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]
(Int -> ReadS AppSpecification)
-> ReadS [AppSpecification]
-> ReadPrec AppSpecification
-> ReadPrec [AppSpecification]
-> Read 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
(Int -> AppSpecification -> ShowS)
-> (AppSpecification -> String)
-> ([AppSpecification] -> ShowS)
-> Show AppSpecification
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. AppSpecification -> Rep AppSpecification x)
-> (forall x. Rep AppSpecification x -> AppSpecification)
-> Generic AppSpecification
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' :: Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text) -> Text -> AppSpecification
AppSpecification'
    { $sel:containerArguments:AppSpecification' :: Maybe (NonEmpty Text)
containerArguments =
        Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:containerEntrypoint:AppSpecification' :: Maybe (NonEmpty Text)
containerEntrypoint = Maybe (NonEmpty Text)
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 :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AppSpecification -> f AppSpecification
appSpecification_containerArguments = (AppSpecification -> Maybe (NonEmpty Text))
-> (AppSpecification -> Maybe (NonEmpty Text) -> AppSpecification)
-> Lens
     AppSpecification
     AppSpecification
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> AppSpecification -> f AppSpecification)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AppSpecification
-> f AppSpecification
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
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 :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AppSpecification -> f AppSpecification
appSpecification_containerEntrypoint = (AppSpecification -> Maybe (NonEmpty Text))
-> (AppSpecification -> Maybe (NonEmpty Text) -> AppSpecification)
-> Lens
     AppSpecification
     AppSpecification
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> AppSpecification -> f AppSpecification)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> AppSpecification
-> f AppSpecification
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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 AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
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 :: (Text -> f Text) -> AppSpecification -> f AppSpecification
appSpecification_imageUri = (AppSpecification -> Text)
-> (AppSpecification -> Text -> AppSpecification)
-> Lens AppSpecification AppSpecification Text Text
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 Core.FromJSON AppSpecification where
  parseJSON :: Value -> Parser AppSpecification
parseJSON =
    String
-> (Object -> Parser AppSpecification)
-> Value
-> Parser AppSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AppSpecification"
      ( \Object
x ->
          Maybe (NonEmpty Text)
-> Maybe (NonEmpty Text) -> Text -> AppSpecification
AppSpecification'
            (Maybe (NonEmpty Text)
 -> Maybe (NonEmpty Text) -> Text -> AppSpecification)
-> Parser (Maybe (NonEmpty Text))
-> Parser (Maybe (NonEmpty Text) -> Text -> AppSpecification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ContainerArguments")
            Parser (Maybe (NonEmpty Text) -> Text -> AppSpecification)
-> Parser (Maybe (NonEmpty Text))
-> Parser (Text -> AppSpecification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ContainerEntrypoint")
            Parser (Text -> AppSpecification)
-> Parser Text -> Parser AppSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ImageUri")
      )

instance Prelude.Hashable AppSpecification

instance Prelude.NFData AppSpecification

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ContainerArguments" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
containerArguments,
            (Text
"ContainerEntrypoint" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
containerEntrypoint,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ImageUri" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
imageUri)
          ]
      )