{-# 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.Pipes.Types.BatchContainerOverrides
-- 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.Pipes.Types.BatchContainerOverrides where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pipes.Types.BatchEnvironmentVariable
import Amazonka.Pipes.Types.BatchResourceRequirement
import qualified Amazonka.Prelude as Prelude

-- | The overrides that are sent to a container.
--
-- /See:/ 'newBatchContainerOverrides' smart constructor.
data BatchContainerOverrides = BatchContainerOverrides'
  { -- | The command to send to the container that overrides the default command
    -- from the Docker image or the task definition.
    BatchContainerOverrides -> Maybe [Text]
command :: Prelude.Maybe [Prelude.Text],
    -- | The environment variables to send to the container. You can add new
    -- environment variables, which are added to the container at launch, or
    -- you can override the existing environment variables from the Docker
    -- image or the task definition.
    --
    -- Environment variables cannot start with \"@Batch@\". This naming
    -- convention is reserved for variables that Batch sets.
    BatchContainerOverrides -> Maybe [BatchEnvironmentVariable]
environment :: Prelude.Maybe [BatchEnvironmentVariable],
    -- | The instance type to use for a multi-node parallel job.
    --
    -- This parameter isn\'t applicable to single-node container jobs or jobs
    -- that run on Fargate resources, and shouldn\'t be provided.
    BatchContainerOverrides -> Maybe Text
instanceType :: Prelude.Maybe Prelude.Text,
    -- | The type and amount of resources to assign to a container. This
    -- overrides the settings in the job definition. The supported resources
    -- include @GPU@, @MEMORY@, and @VCPU@.
    BatchContainerOverrides -> Maybe [BatchResourceRequirement]
resourceRequirements :: Prelude.Maybe [BatchResourceRequirement]
  }
  deriving (BatchContainerOverrides -> BatchContainerOverrides -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchContainerOverrides -> BatchContainerOverrides -> Bool
$c/= :: BatchContainerOverrides -> BatchContainerOverrides -> Bool
== :: BatchContainerOverrides -> BatchContainerOverrides -> Bool
$c== :: BatchContainerOverrides -> BatchContainerOverrides -> Bool
Prelude.Eq, ReadPrec [BatchContainerOverrides]
ReadPrec BatchContainerOverrides
Int -> ReadS BatchContainerOverrides
ReadS [BatchContainerOverrides]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchContainerOverrides]
$creadListPrec :: ReadPrec [BatchContainerOverrides]
readPrec :: ReadPrec BatchContainerOverrides
$creadPrec :: ReadPrec BatchContainerOverrides
readList :: ReadS [BatchContainerOverrides]
$creadList :: ReadS [BatchContainerOverrides]
readsPrec :: Int -> ReadS BatchContainerOverrides
$creadsPrec :: Int -> ReadS BatchContainerOverrides
Prelude.Read, Int -> BatchContainerOverrides -> ShowS
[BatchContainerOverrides] -> ShowS
BatchContainerOverrides -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchContainerOverrides] -> ShowS
$cshowList :: [BatchContainerOverrides] -> ShowS
show :: BatchContainerOverrides -> String
$cshow :: BatchContainerOverrides -> String
showsPrec :: Int -> BatchContainerOverrides -> ShowS
$cshowsPrec :: Int -> BatchContainerOverrides -> ShowS
Prelude.Show, forall x. Rep BatchContainerOverrides x -> BatchContainerOverrides
forall x. BatchContainerOverrides -> Rep BatchContainerOverrides x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchContainerOverrides x -> BatchContainerOverrides
$cfrom :: forall x. BatchContainerOverrides -> Rep BatchContainerOverrides x
Prelude.Generic)

-- |
-- Create a value of 'BatchContainerOverrides' 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:
--
-- 'command', 'batchContainerOverrides_command' - The command to send to the container that overrides the default command
-- from the Docker image or the task definition.
--
-- 'environment', 'batchContainerOverrides_environment' - The environment variables to send to the container. You can add new
-- environment variables, which are added to the container at launch, or
-- you can override the existing environment variables from the Docker
-- image or the task definition.
--
-- Environment variables cannot start with \"@Batch@\". This naming
-- convention is reserved for variables that Batch sets.
--
-- 'instanceType', 'batchContainerOverrides_instanceType' - The instance type to use for a multi-node parallel job.
--
-- This parameter isn\'t applicable to single-node container jobs or jobs
-- that run on Fargate resources, and shouldn\'t be provided.
--
-- 'resourceRequirements', 'batchContainerOverrides_resourceRequirements' - The type and amount of resources to assign to a container. This
-- overrides the settings in the job definition. The supported resources
-- include @GPU@, @MEMORY@, and @VCPU@.
newBatchContainerOverrides ::
  BatchContainerOverrides
newBatchContainerOverrides :: BatchContainerOverrides
newBatchContainerOverrides =
  BatchContainerOverrides'
    { $sel:command:BatchContainerOverrides' :: Maybe [Text]
command = forall a. Maybe a
Prelude.Nothing,
      $sel:environment:BatchContainerOverrides' :: Maybe [BatchEnvironmentVariable]
environment = forall a. Maybe a
Prelude.Nothing,
      $sel:instanceType:BatchContainerOverrides' :: Maybe Text
instanceType = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceRequirements:BatchContainerOverrides' :: Maybe [BatchResourceRequirement]
resourceRequirements = forall a. Maybe a
Prelude.Nothing
    }

-- | The command to send to the container that overrides the default command
-- from the Docker image or the task definition.
batchContainerOverrides_command :: Lens.Lens' BatchContainerOverrides (Prelude.Maybe [Prelude.Text])
batchContainerOverrides_command :: Lens' BatchContainerOverrides (Maybe [Text])
batchContainerOverrides_command = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchContainerOverrides' {Maybe [Text]
command :: Maybe [Text]
$sel:command:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [Text]
command} -> Maybe [Text]
command) (\s :: BatchContainerOverrides
s@BatchContainerOverrides' {} Maybe [Text]
a -> BatchContainerOverrides
s {$sel:command:BatchContainerOverrides' :: Maybe [Text]
command = Maybe [Text]
a} :: BatchContainerOverrides) 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 environment variables to send to the container. You can add new
-- environment variables, which are added to the container at launch, or
-- you can override the existing environment variables from the Docker
-- image or the task definition.
--
-- Environment variables cannot start with \"@Batch@\". This naming
-- convention is reserved for variables that Batch sets.
batchContainerOverrides_environment :: Lens.Lens' BatchContainerOverrides (Prelude.Maybe [BatchEnvironmentVariable])
batchContainerOverrides_environment :: Lens' BatchContainerOverrides (Maybe [BatchEnvironmentVariable])
batchContainerOverrides_environment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchContainerOverrides' {Maybe [BatchEnvironmentVariable]
environment :: Maybe [BatchEnvironmentVariable]
$sel:environment:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchEnvironmentVariable]
environment} -> Maybe [BatchEnvironmentVariable]
environment) (\s :: BatchContainerOverrides
s@BatchContainerOverrides' {} Maybe [BatchEnvironmentVariable]
a -> BatchContainerOverrides
s {$sel:environment:BatchContainerOverrides' :: Maybe [BatchEnvironmentVariable]
environment = Maybe [BatchEnvironmentVariable]
a} :: BatchContainerOverrides) 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 instance type to use for a multi-node parallel job.
--
-- This parameter isn\'t applicable to single-node container jobs or jobs
-- that run on Fargate resources, and shouldn\'t be provided.
batchContainerOverrides_instanceType :: Lens.Lens' BatchContainerOverrides (Prelude.Maybe Prelude.Text)
batchContainerOverrides_instanceType :: Lens' BatchContainerOverrides (Maybe Text)
batchContainerOverrides_instanceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchContainerOverrides' {Maybe Text
instanceType :: Maybe Text
$sel:instanceType:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe Text
instanceType} -> Maybe Text
instanceType) (\s :: BatchContainerOverrides
s@BatchContainerOverrides' {} Maybe Text
a -> BatchContainerOverrides
s {$sel:instanceType:BatchContainerOverrides' :: Maybe Text
instanceType = Maybe Text
a} :: BatchContainerOverrides)

-- | The type and amount of resources to assign to a container. This
-- overrides the settings in the job definition. The supported resources
-- include @GPU@, @MEMORY@, and @VCPU@.
batchContainerOverrides_resourceRequirements :: Lens.Lens' BatchContainerOverrides (Prelude.Maybe [BatchResourceRequirement])
batchContainerOverrides_resourceRequirements :: Lens' BatchContainerOverrides (Maybe [BatchResourceRequirement])
batchContainerOverrides_resourceRequirements = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchContainerOverrides' {Maybe [BatchResourceRequirement]
resourceRequirements :: Maybe [BatchResourceRequirement]
$sel:resourceRequirements:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchResourceRequirement]
resourceRequirements} -> Maybe [BatchResourceRequirement]
resourceRequirements) (\s :: BatchContainerOverrides
s@BatchContainerOverrides' {} Maybe [BatchResourceRequirement]
a -> BatchContainerOverrides
s {$sel:resourceRequirements:BatchContainerOverrides' :: Maybe [BatchResourceRequirement]
resourceRequirements = Maybe [BatchResourceRequirement]
a} :: BatchContainerOverrides) 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

instance Data.FromJSON BatchContainerOverrides where
  parseJSON :: Value -> Parser BatchContainerOverrides
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BatchContainerOverrides"
      ( \Object
x ->
          Maybe [Text]
-> Maybe [BatchEnvironmentVariable]
-> Maybe Text
-> Maybe [BatchResourceRequirement]
-> BatchContainerOverrides
BatchContainerOverrides'
            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
"Command" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Environment" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"InstanceType")
            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
"ResourceRequirements"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable BatchContainerOverrides where
  hashWithSalt :: Int -> BatchContainerOverrides -> Int
hashWithSalt Int
_salt BatchContainerOverrides' {Maybe [Text]
Maybe [BatchEnvironmentVariable]
Maybe [BatchResourceRequirement]
Maybe Text
resourceRequirements :: Maybe [BatchResourceRequirement]
instanceType :: Maybe Text
environment :: Maybe [BatchEnvironmentVariable]
command :: Maybe [Text]
$sel:resourceRequirements:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchResourceRequirement]
$sel:instanceType:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe Text
$sel:environment:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchEnvironmentVariable]
$sel:command:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
command
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [BatchEnvironmentVariable]
environment
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [BatchResourceRequirement]
resourceRequirements

instance Prelude.NFData BatchContainerOverrides where
  rnf :: BatchContainerOverrides -> ()
rnf BatchContainerOverrides' {Maybe [Text]
Maybe [BatchEnvironmentVariable]
Maybe [BatchResourceRequirement]
Maybe Text
resourceRequirements :: Maybe [BatchResourceRequirement]
instanceType :: Maybe Text
environment :: Maybe [BatchEnvironmentVariable]
command :: Maybe [Text]
$sel:resourceRequirements:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchResourceRequirement]
$sel:instanceType:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe Text
$sel:environment:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchEnvironmentVariable]
$sel:command:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
command
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchEnvironmentVariable]
environment
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [BatchResourceRequirement]
resourceRequirements

instance Data.ToJSON BatchContainerOverrides where
  toJSON :: BatchContainerOverrides -> Value
toJSON BatchContainerOverrides' {Maybe [Text]
Maybe [BatchEnvironmentVariable]
Maybe [BatchResourceRequirement]
Maybe Text
resourceRequirements :: Maybe [BatchResourceRequirement]
instanceType :: Maybe Text
environment :: Maybe [BatchEnvironmentVariable]
command :: Maybe [Text]
$sel:resourceRequirements:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchResourceRequirement]
$sel:instanceType:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe Text
$sel:environment:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [BatchEnvironmentVariable]
$sel:command:BatchContainerOverrides' :: BatchContainerOverrides -> Maybe [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Command" 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]
command,
            (Key
"Environment" 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 [BatchEnvironmentVariable]
environment,
            (Key
"InstanceType" 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
instanceType,
            (Key
"ResourceRequirements" 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 [BatchResourceRequirement]
resourceRequirements
          ]
      )