{-# 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.Batch.Types.LinuxParameters
-- 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.Batch.Types.LinuxParameters where

import Amazonka.Batch.Types.Device
import Amazonka.Batch.Types.Tmpfs
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Linux-specific modifications that are applied to the container, such as
-- details for device mappings.
--
-- /See:/ 'newLinuxParameters' smart constructor.
data LinuxParameters = LinuxParameters'
  { -- | The value for the size (in MiB) of the @\/dev\/shm@ volume. This
    -- parameter maps to the @--shm-size@ option to
    -- <https://docs.docker.com/engine/reference/run/ docker run>.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources and shouldn\'t be provided.
    LinuxParameters -> Maybe Int
sharedMemorySize :: Prelude.Maybe Prelude.Int,
    -- | If true, run an @init@ process inside the container that forwards
    -- signals and reaps processes. This parameter maps to the @--init@ option
    -- to <https://docs.docker.com/engine/reference/run/ docker run>. This
    -- parameter requires version 1.25 of the Docker Remote API or greater on
    -- your container instance. To check the Docker Remote API version on your
    -- container instance, log into your container instance and run the
    -- following command: @sudo docker version | grep \"Server API version\"@
    LinuxParameters -> Maybe Bool
initProcessEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The container path, mount options, and size (in MiB) of the tmpfs mount.
    -- This parameter maps to the @--tmpfs@ option to
    -- <https://docs.docker.com/engine/reference/run/ docker run>.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources and shouldn\'t be provided.
    LinuxParameters -> Maybe [Tmpfs]
tmpfs :: Prelude.Maybe [Tmpfs],
    -- | This allows you to tune a container\'s memory swappiness behavior. A
    -- @swappiness@ value of @0@ causes swapping not to happen unless
    -- absolutely necessary. A @swappiness@ value of @100@ causes pages to be
    -- swapped very aggressively. Accepted values are whole numbers between @0@
    -- and @100@. If the @swappiness@ parameter isn\'t specified, a default
    -- value of @60@ is used. If a value isn\'t specified for @maxSwap@, then
    -- this parameter is ignored. If @maxSwap@ is set to 0, the container
    -- doesn\'t use swap. This parameter maps to the @--memory-swappiness@
    -- option to <https://docs.docker.com/engine/reference/run/ docker run>.
    --
    -- Consider the following when you use a per-container swap configuration.
    --
    -- -   Swap space must be enabled and allocated on the container instance
    --     for the containers to use.
    --
    --     The Amazon ECS optimized AMIs don\'t have swap enabled by default.
    --     You must enable swap on the instance to use this feature. For more
    --     information, see
    --     <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-store-swap-volumes.html Instance Store Swap Volumes>
    --     in the /Amazon EC2 User Guide for Linux Instances/ or
    --     <http://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/ How do I allocate memory to work as swap space in an Amazon EC2 instance by using a swap file?>
    --
    -- -   The swap space parameters are only supported for job definitions
    --     using EC2 resources.
    --
    -- -   If the @maxSwap@ and @swappiness@ parameters are omitted from a job
    --     definition, each container will have a default @swappiness@ value of
    --     60, and the total swap usage will be limited to two times the memory
    --     reservation of the container.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources and shouldn\'t be provided.
    LinuxParameters -> Maybe Int
swappiness :: Prelude.Maybe Prelude.Int,
    -- | Any host devices to expose to the container. This parameter maps to
    -- @Devices@ in the
    -- <https://docs.docker.com/engine/api/v1.23/#create-a-container Create a container>
    -- section of the
    -- <https://docs.docker.com/engine/api/v1.23/ Docker Remote API> and the
    -- @--device@ option to
    -- <https://docs.docker.com/engine/reference/run/ docker run>.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources and shouldn\'t be provided.
    LinuxParameters -> Maybe [Device]
devices :: Prelude.Maybe [Device],
    -- | The total amount of swap memory (in MiB) a container can use. This
    -- parameter is translated to the @--memory-swap@ option to
    -- <https://docs.docker.com/engine/reference/run/ docker run> where the
    -- value is the sum of the container memory plus the @maxSwap@ value. For
    -- more information, see
    -- <https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details --memory-swap details>
    -- in the Docker documentation.
    --
    -- If a @maxSwap@ value of @0@ is specified, the container doesn\'t use
    -- swap. Accepted values are @0@ or any positive integer. If the @maxSwap@
    -- parameter is omitted, the container doesn\'t use the swap configuration
    -- for the container instance it is running on. A @maxSwap@ value must be
    -- set for the @swappiness@ parameter to be used.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources and shouldn\'t be provided.
    LinuxParameters -> Maybe Int
maxSwap :: Prelude.Maybe Prelude.Int
  }
  deriving (LinuxParameters -> LinuxParameters -> Bool
(LinuxParameters -> LinuxParameters -> Bool)
-> (LinuxParameters -> LinuxParameters -> Bool)
-> Eq LinuxParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LinuxParameters -> LinuxParameters -> Bool
$c/= :: LinuxParameters -> LinuxParameters -> Bool
== :: LinuxParameters -> LinuxParameters -> Bool
$c== :: LinuxParameters -> LinuxParameters -> Bool
Prelude.Eq, ReadPrec [LinuxParameters]
ReadPrec LinuxParameters
Int -> ReadS LinuxParameters
ReadS [LinuxParameters]
(Int -> ReadS LinuxParameters)
-> ReadS [LinuxParameters]
-> ReadPrec LinuxParameters
-> ReadPrec [LinuxParameters]
-> Read LinuxParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LinuxParameters]
$creadListPrec :: ReadPrec [LinuxParameters]
readPrec :: ReadPrec LinuxParameters
$creadPrec :: ReadPrec LinuxParameters
readList :: ReadS [LinuxParameters]
$creadList :: ReadS [LinuxParameters]
readsPrec :: Int -> ReadS LinuxParameters
$creadsPrec :: Int -> ReadS LinuxParameters
Prelude.Read, Int -> LinuxParameters -> ShowS
[LinuxParameters] -> ShowS
LinuxParameters -> String
(Int -> LinuxParameters -> ShowS)
-> (LinuxParameters -> String)
-> ([LinuxParameters] -> ShowS)
-> Show LinuxParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LinuxParameters] -> ShowS
$cshowList :: [LinuxParameters] -> ShowS
show :: LinuxParameters -> String
$cshow :: LinuxParameters -> String
showsPrec :: Int -> LinuxParameters -> ShowS
$cshowsPrec :: Int -> LinuxParameters -> ShowS
Prelude.Show, (forall x. LinuxParameters -> Rep LinuxParameters x)
-> (forall x. Rep LinuxParameters x -> LinuxParameters)
-> Generic LinuxParameters
forall x. Rep LinuxParameters x -> LinuxParameters
forall x. LinuxParameters -> Rep LinuxParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LinuxParameters x -> LinuxParameters
$cfrom :: forall x. LinuxParameters -> Rep LinuxParameters x
Prelude.Generic)

-- |
-- Create a value of 'LinuxParameters' 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:
--
-- 'sharedMemorySize', 'linuxParameters_sharedMemorySize' - The value for the size (in MiB) of the @\/dev\/shm@ volume. This
-- parameter maps to the @--shm-size@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
--
-- 'initProcessEnabled', 'linuxParameters_initProcessEnabled' - If true, run an @init@ process inside the container that forwards
-- signals and reaps processes. This parameter maps to the @--init@ option
-- to <https://docs.docker.com/engine/reference/run/ docker run>. This
-- parameter requires version 1.25 of the Docker Remote API or greater on
-- your container instance. To check the Docker Remote API version on your
-- container instance, log into your container instance and run the
-- following command: @sudo docker version | grep \"Server API version\"@
--
-- 'tmpfs', 'linuxParameters_tmpfs' - The container path, mount options, and size (in MiB) of the tmpfs mount.
-- This parameter maps to the @--tmpfs@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
--
-- 'swappiness', 'linuxParameters_swappiness' - This allows you to tune a container\'s memory swappiness behavior. A
-- @swappiness@ value of @0@ causes swapping not to happen unless
-- absolutely necessary. A @swappiness@ value of @100@ causes pages to be
-- swapped very aggressively. Accepted values are whole numbers between @0@
-- and @100@. If the @swappiness@ parameter isn\'t specified, a default
-- value of @60@ is used. If a value isn\'t specified for @maxSwap@, then
-- this parameter is ignored. If @maxSwap@ is set to 0, the container
-- doesn\'t use swap. This parameter maps to the @--memory-swappiness@
-- option to <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- Consider the following when you use a per-container swap configuration.
--
-- -   Swap space must be enabled and allocated on the container instance
--     for the containers to use.
--
--     The Amazon ECS optimized AMIs don\'t have swap enabled by default.
--     You must enable swap on the instance to use this feature. For more
--     information, see
--     <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-store-swap-volumes.html Instance Store Swap Volumes>
--     in the /Amazon EC2 User Guide for Linux Instances/ or
--     <http://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/ How do I allocate memory to work as swap space in an Amazon EC2 instance by using a swap file?>
--
-- -   The swap space parameters are only supported for job definitions
--     using EC2 resources.
--
-- -   If the @maxSwap@ and @swappiness@ parameters are omitted from a job
--     definition, each container will have a default @swappiness@ value of
--     60, and the total swap usage will be limited to two times the memory
--     reservation of the container.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
--
-- 'devices', 'linuxParameters_devices' - Any host devices to expose to the container. This parameter maps to
-- @Devices@ in the
-- <https://docs.docker.com/engine/api/v1.23/#create-a-container Create a container>
-- section of the
-- <https://docs.docker.com/engine/api/v1.23/ Docker Remote API> and the
-- @--device@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
--
-- 'maxSwap', 'linuxParameters_maxSwap' - The total amount of swap memory (in MiB) a container can use. This
-- parameter is translated to the @--memory-swap@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run> where the
-- value is the sum of the container memory plus the @maxSwap@ value. For
-- more information, see
-- <https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details --memory-swap details>
-- in the Docker documentation.
--
-- If a @maxSwap@ value of @0@ is specified, the container doesn\'t use
-- swap. Accepted values are @0@ or any positive integer. If the @maxSwap@
-- parameter is omitted, the container doesn\'t use the swap configuration
-- for the container instance it is running on. A @maxSwap@ value must be
-- set for the @swappiness@ parameter to be used.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
newLinuxParameters ::
  LinuxParameters
newLinuxParameters :: LinuxParameters
newLinuxParameters =
  LinuxParameters' :: Maybe Int
-> Maybe Bool
-> Maybe [Tmpfs]
-> Maybe Int
-> Maybe [Device]
-> Maybe Int
-> LinuxParameters
LinuxParameters'
    { $sel:sharedMemorySize:LinuxParameters' :: Maybe Int
sharedMemorySize =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:initProcessEnabled:LinuxParameters' :: Maybe Bool
initProcessEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:tmpfs:LinuxParameters' :: Maybe [Tmpfs]
tmpfs = Maybe [Tmpfs]
forall a. Maybe a
Prelude.Nothing,
      $sel:swappiness:LinuxParameters' :: Maybe Int
swappiness = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:devices:LinuxParameters' :: Maybe [Device]
devices = Maybe [Device]
forall a. Maybe a
Prelude.Nothing,
      $sel:maxSwap:LinuxParameters' :: Maybe Int
maxSwap = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The value for the size (in MiB) of the @\/dev\/shm@ volume. This
-- parameter maps to the @--shm-size@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
linuxParameters_sharedMemorySize :: Lens.Lens' LinuxParameters (Prelude.Maybe Prelude.Int)
linuxParameters_sharedMemorySize :: (Maybe Int -> f (Maybe Int))
-> LinuxParameters -> f LinuxParameters
linuxParameters_sharedMemorySize = (LinuxParameters -> Maybe Int)
-> (LinuxParameters -> Maybe Int -> LinuxParameters)
-> Lens LinuxParameters LinuxParameters (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinuxParameters' {Maybe Int
sharedMemorySize :: Maybe Int
$sel:sharedMemorySize:LinuxParameters' :: LinuxParameters -> Maybe Int
sharedMemorySize} -> Maybe Int
sharedMemorySize) (\s :: LinuxParameters
s@LinuxParameters' {} Maybe Int
a -> LinuxParameters
s {$sel:sharedMemorySize:LinuxParameters' :: Maybe Int
sharedMemorySize = Maybe Int
a} :: LinuxParameters)

-- | If true, run an @init@ process inside the container that forwards
-- signals and reaps processes. This parameter maps to the @--init@ option
-- to <https://docs.docker.com/engine/reference/run/ docker run>. This
-- parameter requires version 1.25 of the Docker Remote API or greater on
-- your container instance. To check the Docker Remote API version on your
-- container instance, log into your container instance and run the
-- following command: @sudo docker version | grep \"Server API version\"@
linuxParameters_initProcessEnabled :: Lens.Lens' LinuxParameters (Prelude.Maybe Prelude.Bool)
linuxParameters_initProcessEnabled :: (Maybe Bool -> f (Maybe Bool))
-> LinuxParameters -> f LinuxParameters
linuxParameters_initProcessEnabled = (LinuxParameters -> Maybe Bool)
-> (LinuxParameters -> Maybe Bool -> LinuxParameters)
-> Lens LinuxParameters LinuxParameters (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinuxParameters' {Maybe Bool
initProcessEnabled :: Maybe Bool
$sel:initProcessEnabled:LinuxParameters' :: LinuxParameters -> Maybe Bool
initProcessEnabled} -> Maybe Bool
initProcessEnabled) (\s :: LinuxParameters
s@LinuxParameters' {} Maybe Bool
a -> LinuxParameters
s {$sel:initProcessEnabled:LinuxParameters' :: Maybe Bool
initProcessEnabled = Maybe Bool
a} :: LinuxParameters)

-- | The container path, mount options, and size (in MiB) of the tmpfs mount.
-- This parameter maps to the @--tmpfs@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
linuxParameters_tmpfs :: Lens.Lens' LinuxParameters (Prelude.Maybe [Tmpfs])
linuxParameters_tmpfs :: (Maybe [Tmpfs] -> f (Maybe [Tmpfs]))
-> LinuxParameters -> f LinuxParameters
linuxParameters_tmpfs = (LinuxParameters -> Maybe [Tmpfs])
-> (LinuxParameters -> Maybe [Tmpfs] -> LinuxParameters)
-> Lens
     LinuxParameters LinuxParameters (Maybe [Tmpfs]) (Maybe [Tmpfs])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinuxParameters' {Maybe [Tmpfs]
tmpfs :: Maybe [Tmpfs]
$sel:tmpfs:LinuxParameters' :: LinuxParameters -> Maybe [Tmpfs]
tmpfs} -> Maybe [Tmpfs]
tmpfs) (\s :: LinuxParameters
s@LinuxParameters' {} Maybe [Tmpfs]
a -> LinuxParameters
s {$sel:tmpfs:LinuxParameters' :: Maybe [Tmpfs]
tmpfs = Maybe [Tmpfs]
a} :: LinuxParameters) ((Maybe [Tmpfs] -> f (Maybe [Tmpfs]))
 -> LinuxParameters -> f LinuxParameters)
-> ((Maybe [Tmpfs] -> f (Maybe [Tmpfs]))
    -> Maybe [Tmpfs] -> f (Maybe [Tmpfs]))
-> (Maybe [Tmpfs] -> f (Maybe [Tmpfs]))
-> LinuxParameters
-> f LinuxParameters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tmpfs] [Tmpfs] [Tmpfs] [Tmpfs]
-> Iso
     (Maybe [Tmpfs]) (Maybe [Tmpfs]) (Maybe [Tmpfs]) (Maybe [Tmpfs])
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 [Tmpfs] [Tmpfs] [Tmpfs] [Tmpfs]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | This allows you to tune a container\'s memory swappiness behavior. A
-- @swappiness@ value of @0@ causes swapping not to happen unless
-- absolutely necessary. A @swappiness@ value of @100@ causes pages to be
-- swapped very aggressively. Accepted values are whole numbers between @0@
-- and @100@. If the @swappiness@ parameter isn\'t specified, a default
-- value of @60@ is used. If a value isn\'t specified for @maxSwap@, then
-- this parameter is ignored. If @maxSwap@ is set to 0, the container
-- doesn\'t use swap. This parameter maps to the @--memory-swappiness@
-- option to <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- Consider the following when you use a per-container swap configuration.
--
-- -   Swap space must be enabled and allocated on the container instance
--     for the containers to use.
--
--     The Amazon ECS optimized AMIs don\'t have swap enabled by default.
--     You must enable swap on the instance to use this feature. For more
--     information, see
--     <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-store-swap-volumes.html Instance Store Swap Volumes>
--     in the /Amazon EC2 User Guide for Linux Instances/ or
--     <http://aws.amazon.com/premiumsupport/knowledge-center/ec2-memory-swap-file/ How do I allocate memory to work as swap space in an Amazon EC2 instance by using a swap file?>
--
-- -   The swap space parameters are only supported for job definitions
--     using EC2 resources.
--
-- -   If the @maxSwap@ and @swappiness@ parameters are omitted from a job
--     definition, each container will have a default @swappiness@ value of
--     60, and the total swap usage will be limited to two times the memory
--     reservation of the container.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
linuxParameters_swappiness :: Lens.Lens' LinuxParameters (Prelude.Maybe Prelude.Int)
linuxParameters_swappiness :: (Maybe Int -> f (Maybe Int))
-> LinuxParameters -> f LinuxParameters
linuxParameters_swappiness = (LinuxParameters -> Maybe Int)
-> (LinuxParameters -> Maybe Int -> LinuxParameters)
-> Lens LinuxParameters LinuxParameters (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinuxParameters' {Maybe Int
swappiness :: Maybe Int
$sel:swappiness:LinuxParameters' :: LinuxParameters -> Maybe Int
swappiness} -> Maybe Int
swappiness) (\s :: LinuxParameters
s@LinuxParameters' {} Maybe Int
a -> LinuxParameters
s {$sel:swappiness:LinuxParameters' :: Maybe Int
swappiness = Maybe Int
a} :: LinuxParameters)

-- | Any host devices to expose to the container. This parameter maps to
-- @Devices@ in the
-- <https://docs.docker.com/engine/api/v1.23/#create-a-container Create a container>
-- section of the
-- <https://docs.docker.com/engine/api/v1.23/ Docker Remote API> and the
-- @--device@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run>.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
linuxParameters_devices :: Lens.Lens' LinuxParameters (Prelude.Maybe [Device])
linuxParameters_devices :: (Maybe [Device] -> f (Maybe [Device]))
-> LinuxParameters -> f LinuxParameters
linuxParameters_devices = (LinuxParameters -> Maybe [Device])
-> (LinuxParameters -> Maybe [Device] -> LinuxParameters)
-> Lens
     LinuxParameters LinuxParameters (Maybe [Device]) (Maybe [Device])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinuxParameters' {Maybe [Device]
devices :: Maybe [Device]
$sel:devices:LinuxParameters' :: LinuxParameters -> Maybe [Device]
devices} -> Maybe [Device]
devices) (\s :: LinuxParameters
s@LinuxParameters' {} Maybe [Device]
a -> LinuxParameters
s {$sel:devices:LinuxParameters' :: Maybe [Device]
devices = Maybe [Device]
a} :: LinuxParameters) ((Maybe [Device] -> f (Maybe [Device]))
 -> LinuxParameters -> f LinuxParameters)
-> ((Maybe [Device] -> f (Maybe [Device]))
    -> Maybe [Device] -> f (Maybe [Device]))
-> (Maybe [Device] -> f (Maybe [Device]))
-> LinuxParameters
-> f LinuxParameters
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Device] [Device] [Device] [Device]
-> Iso
     (Maybe [Device]) (Maybe [Device]) (Maybe [Device]) (Maybe [Device])
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 [Device] [Device] [Device] [Device]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The total amount of swap memory (in MiB) a container can use. This
-- parameter is translated to the @--memory-swap@ option to
-- <https://docs.docker.com/engine/reference/run/ docker run> where the
-- value is the sum of the container memory plus the @maxSwap@ value. For
-- more information, see
-- <https://docs.docker.com/config/containers/resource_constraints/#--memory-swap-details --memory-swap details>
-- in the Docker documentation.
--
-- If a @maxSwap@ value of @0@ is specified, the container doesn\'t use
-- swap. Accepted values are @0@ or any positive integer. If the @maxSwap@
-- parameter is omitted, the container doesn\'t use the swap configuration
-- for the container instance it is running on. A @maxSwap@ value must be
-- set for the @swappiness@ parameter to be used.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources and shouldn\'t be provided.
linuxParameters_maxSwap :: Lens.Lens' LinuxParameters (Prelude.Maybe Prelude.Int)
linuxParameters_maxSwap :: (Maybe Int -> f (Maybe Int))
-> LinuxParameters -> f LinuxParameters
linuxParameters_maxSwap = (LinuxParameters -> Maybe Int)
-> (LinuxParameters -> Maybe Int -> LinuxParameters)
-> Lens LinuxParameters LinuxParameters (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinuxParameters' {Maybe Int
maxSwap :: Maybe Int
$sel:maxSwap:LinuxParameters' :: LinuxParameters -> Maybe Int
maxSwap} -> Maybe Int
maxSwap) (\s :: LinuxParameters
s@LinuxParameters' {} Maybe Int
a -> LinuxParameters
s {$sel:maxSwap:LinuxParameters' :: Maybe Int
maxSwap = Maybe Int
a} :: LinuxParameters)

instance Core.FromJSON LinuxParameters where
  parseJSON :: Value -> Parser LinuxParameters
parseJSON =
    String
-> (Object -> Parser LinuxParameters)
-> Value
-> Parser LinuxParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LinuxParameters"
      ( \Object
x ->
          Maybe Int
-> Maybe Bool
-> Maybe [Tmpfs]
-> Maybe Int
-> Maybe [Device]
-> Maybe Int
-> LinuxParameters
LinuxParameters'
            (Maybe Int
 -> Maybe Bool
 -> Maybe [Tmpfs]
 -> Maybe Int
 -> Maybe [Device]
 -> Maybe Int
 -> LinuxParameters)
-> Parser (Maybe Int)
-> Parser
     (Maybe Bool
      -> Maybe [Tmpfs]
      -> Maybe Int
      -> Maybe [Device]
      -> Maybe Int
      -> LinuxParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sharedMemorySize")
            Parser
  (Maybe Bool
   -> Maybe [Tmpfs]
   -> Maybe Int
   -> Maybe [Device]
   -> Maybe Int
   -> LinuxParameters)
-> Parser (Maybe Bool)
-> Parser
     (Maybe [Tmpfs]
      -> Maybe Int -> Maybe [Device] -> Maybe Int -> LinuxParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"initProcessEnabled")
            Parser
  (Maybe [Tmpfs]
   -> Maybe Int -> Maybe [Device] -> Maybe Int -> LinuxParameters)
-> Parser (Maybe [Tmpfs])
-> Parser
     (Maybe Int -> Maybe [Device] -> Maybe Int -> LinuxParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Tmpfs]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tmpfs" Parser (Maybe (Maybe [Tmpfs]))
-> Maybe [Tmpfs] -> Parser (Maybe [Tmpfs])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Tmpfs]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Int -> Maybe [Device] -> Maybe Int -> LinuxParameters)
-> Parser (Maybe Int)
-> Parser (Maybe [Device] -> Maybe Int -> LinuxParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"swappiness")
            Parser (Maybe [Device] -> Maybe Int -> LinuxParameters)
-> Parser (Maybe [Device]) -> Parser (Maybe Int -> LinuxParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Device]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"devices" Parser (Maybe (Maybe [Device]))
-> Maybe [Device] -> Parser (Maybe [Device])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Device]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Int -> LinuxParameters)
-> Parser (Maybe Int) -> Parser LinuxParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maxSwap")
      )

instance Prelude.Hashable LinuxParameters

instance Prelude.NFData LinuxParameters

instance Core.ToJSON LinuxParameters where
  toJSON :: LinuxParameters -> Value
toJSON LinuxParameters' {Maybe Bool
Maybe Int
Maybe [Device]
Maybe [Tmpfs]
maxSwap :: Maybe Int
devices :: Maybe [Device]
swappiness :: Maybe Int
tmpfs :: Maybe [Tmpfs]
initProcessEnabled :: Maybe Bool
sharedMemorySize :: Maybe Int
$sel:maxSwap:LinuxParameters' :: LinuxParameters -> Maybe Int
$sel:devices:LinuxParameters' :: LinuxParameters -> Maybe [Device]
$sel:swappiness:LinuxParameters' :: LinuxParameters -> Maybe Int
$sel:tmpfs:LinuxParameters' :: LinuxParameters -> Maybe [Tmpfs]
$sel:initProcessEnabled:LinuxParameters' :: LinuxParameters -> Maybe Bool
$sel:sharedMemorySize:LinuxParameters' :: LinuxParameters -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"sharedMemorySize" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
sharedMemorySize,
            (Text
"initProcessEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
initProcessEnabled,
            (Text
"tmpfs" Text -> [Tmpfs] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tmpfs] -> Pair) -> Maybe [Tmpfs] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tmpfs]
tmpfs,
            (Text
"swappiness" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
swappiness,
            (Text
"devices" Text -> [Device] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Device] -> Pair) -> Maybe [Device] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Device]
devices,
            (Text
"maxSwap" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
maxSwap
          ]
      )