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

import qualified Amazonka.Core as Core
import Amazonka.ECS.Types.Device
import Amazonka.ECS.Types.KernelCapabilities
import Amazonka.ECS.Types.Tmpfs
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Linux-specific options that are applied to the container, such as Linux
-- KernelCapabilities.
--
-- /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/#security-configuration docker run>.
    --
    -- If you are using tasks that use the Fargate launch type, the
    -- @sharedMemorySize@ parameter is not supported.
    LinuxParameters -> Maybe Int
sharedMemorySize :: Prelude.Maybe Prelude.Int,
    -- | 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/#security-configuration 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 in to your container instance and run the
    -- following command:
    -- @sudo docker version --format \'{{.Server.APIVersion}}\'@
    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/#security-configuration docker run>.
    --
    -- If you are using tasks that use the Fargate launch type, the @tmpfs@
    -- parameter is not supported.
    LinuxParameters -> Maybe [Tmpfs]
tmpfs :: Prelude.Maybe [Tmpfs],
    -- | This allows you to tune a container\'s memory swappiness behavior. A
    -- @swappiness@ value of @0@ will cause swapping to not happen unless
    -- absolutely necessary. A @swappiness@ value of @100@ will cause pages to
    -- be swapped very aggressively. Accepted values are whole numbers between
    -- @0@ and @100@. If the @swappiness@ parameter is not specified, a default
    -- value of @60@ is used. If a value is not specified for @maxSwap@ then
    -- this parameter is ignored. This parameter maps to the
    -- @--memory-swappiness@ option to
    -- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>.
    --
    -- If you are using tasks that use the Fargate launch type, the
    -- @swappiness@ parameter is not supported.
    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.35/#operation/ContainerCreate Create a container>
    -- section of the
    -- <https://docs.docker.com/engine/api/v1.35/ Docker Remote API> and the
    -- @--device@ option to
    -- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>.
    --
    -- If you are using tasks that use the Fargate launch type, the @devices@
    -- parameter is not supported.
    LinuxParameters -> Maybe [Device]
devices :: Prelude.Maybe [Device],
    -- | The Linux capabilities for the container that are added to or dropped
    -- from the default configuration provided by Docker.
    --
    -- For tasks that use the Fargate launch type, @capabilities@ is supported
    -- for all platform versions but the @add@ parameter is only supported if
    -- using platform version 1.4.0 or later.
    LinuxParameters -> Maybe KernelCapabilities
capabilities :: Prelude.Maybe KernelCapabilities,
    -- | The total amount of swap memory (in MiB) a container can use. This
    -- parameter will be translated to the @--memory-swap@ option to
    -- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>
    -- where the value would be the sum of the container memory plus the
    -- @maxSwap@ value.
    --
    -- If a @maxSwap@ value of @0@ is specified, the container will not use
    -- swap. Accepted values are @0@ or any positive integer. If the @maxSwap@
    -- parameter is omitted, the container will 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.
    --
    -- If you are using tasks that use the Fargate launch type, the @maxSwap@
    -- parameter is not supported.
    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/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the
-- @sharedMemorySize@ parameter is not supported.
--
-- 'initProcessEnabled', 'linuxParameters_initProcessEnabled' - 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/#security-configuration 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 in to your container instance and run the
-- following command:
-- @sudo docker version --format \'{{.Server.APIVersion}}\'@
--
-- '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/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the @tmpfs@
-- parameter is not supported.
--
-- 'swappiness', 'linuxParameters_swappiness' - This allows you to tune a container\'s memory swappiness behavior. A
-- @swappiness@ value of @0@ will cause swapping to not happen unless
-- absolutely necessary. A @swappiness@ value of @100@ will cause pages to
-- be swapped very aggressively. Accepted values are whole numbers between
-- @0@ and @100@. If the @swappiness@ parameter is not specified, a default
-- value of @60@ is used. If a value is not specified for @maxSwap@ then
-- this parameter is ignored. This parameter maps to the
-- @--memory-swappiness@ option to
-- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the
-- @swappiness@ parameter is not supported.
--
-- '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.35/#operation/ContainerCreate Create a container>
-- section of the
-- <https://docs.docker.com/engine/api/v1.35/ Docker Remote API> and the
-- @--device@ option to
-- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the @devices@
-- parameter is not supported.
--
-- 'capabilities', 'linuxParameters_capabilities' - The Linux capabilities for the container that are added to or dropped
-- from the default configuration provided by Docker.
--
-- For tasks that use the Fargate launch type, @capabilities@ is supported
-- for all platform versions but the @add@ parameter is only supported if
-- using platform version 1.4.0 or later.
--
-- 'maxSwap', 'linuxParameters_maxSwap' - The total amount of swap memory (in MiB) a container can use. This
-- parameter will be translated to the @--memory-swap@ option to
-- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>
-- where the value would be the sum of the container memory plus the
-- @maxSwap@ value.
--
-- If a @maxSwap@ value of @0@ is specified, the container will not use
-- swap. Accepted values are @0@ or any positive integer. If the @maxSwap@
-- parameter is omitted, the container will 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.
--
-- If you are using tasks that use the Fargate launch type, the @maxSwap@
-- parameter is not supported.
newLinuxParameters ::
  LinuxParameters
newLinuxParameters :: LinuxParameters
newLinuxParameters =
  LinuxParameters' :: Maybe Int
-> Maybe Bool
-> Maybe [Tmpfs]
-> Maybe Int
-> Maybe [Device]
-> Maybe KernelCapabilities
-> 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:capabilities:LinuxParameters' :: Maybe KernelCapabilities
capabilities = Maybe KernelCapabilities
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/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the
-- @sharedMemorySize@ parameter is not supported.
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)

-- | 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/#security-configuration 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 in to your container instance and run the
-- following command:
-- @sudo docker version --format \'{{.Server.APIVersion}}\'@
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/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the @tmpfs@
-- parameter is not supported.
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@ will cause swapping to not happen unless
-- absolutely necessary. A @swappiness@ value of @100@ will cause pages to
-- be swapped very aggressively. Accepted values are whole numbers between
-- @0@ and @100@. If the @swappiness@ parameter is not specified, a default
-- value of @60@ is used. If a value is not specified for @maxSwap@ then
-- this parameter is ignored. This parameter maps to the
-- @--memory-swappiness@ option to
-- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the
-- @swappiness@ parameter is not supported.
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.35/#operation/ContainerCreate Create a container>
-- section of the
-- <https://docs.docker.com/engine/api/v1.35/ Docker Remote API> and the
-- @--device@ option to
-- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>.
--
-- If you are using tasks that use the Fargate launch type, the @devices@
-- parameter is not supported.
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 Linux capabilities for the container that are added to or dropped
-- from the default configuration provided by Docker.
--
-- For tasks that use the Fargate launch type, @capabilities@ is supported
-- for all platform versions but the @add@ parameter is only supported if
-- using platform version 1.4.0 or later.
linuxParameters_capabilities :: Lens.Lens' LinuxParameters (Prelude.Maybe KernelCapabilities)
linuxParameters_capabilities :: (Maybe KernelCapabilities -> f (Maybe KernelCapabilities))
-> LinuxParameters -> f LinuxParameters
linuxParameters_capabilities = (LinuxParameters -> Maybe KernelCapabilities)
-> (LinuxParameters -> Maybe KernelCapabilities -> LinuxParameters)
-> Lens
     LinuxParameters
     LinuxParameters
     (Maybe KernelCapabilities)
     (Maybe KernelCapabilities)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LinuxParameters' {Maybe KernelCapabilities
capabilities :: Maybe KernelCapabilities
$sel:capabilities:LinuxParameters' :: LinuxParameters -> Maybe KernelCapabilities
capabilities} -> Maybe KernelCapabilities
capabilities) (\s :: LinuxParameters
s@LinuxParameters' {} Maybe KernelCapabilities
a -> LinuxParameters
s {$sel:capabilities:LinuxParameters' :: Maybe KernelCapabilities
capabilities = Maybe KernelCapabilities
a} :: LinuxParameters)

-- | The total amount of swap memory (in MiB) a container can use. This
-- parameter will be translated to the @--memory-swap@ option to
-- <https://docs.docker.com/engine/reference/run/#security-configuration docker run>
-- where the value would be the sum of the container memory plus the
-- @maxSwap@ value.
--
-- If a @maxSwap@ value of @0@ is specified, the container will not use
-- swap. Accepted values are @0@ or any positive integer. If the @maxSwap@
-- parameter is omitted, the container will 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.
--
-- If you are using tasks that use the Fargate launch type, the @maxSwap@
-- parameter is not supported.
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 KernelCapabilities
-> Maybe Int
-> LinuxParameters
LinuxParameters'
            (Maybe Int
 -> Maybe Bool
 -> Maybe [Tmpfs]
 -> Maybe Int
 -> Maybe [Device]
 -> Maybe KernelCapabilities
 -> Maybe Int
 -> LinuxParameters)
-> Parser (Maybe Int)
-> Parser
     (Maybe Bool
      -> Maybe [Tmpfs]
      -> Maybe Int
      -> Maybe [Device]
      -> Maybe KernelCapabilities
      -> 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 KernelCapabilities
   -> Maybe Int
   -> LinuxParameters)
-> Parser (Maybe Bool)
-> Parser
     (Maybe [Tmpfs]
      -> Maybe Int
      -> Maybe [Device]
      -> Maybe KernelCapabilities
      -> 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 KernelCapabilities
   -> Maybe Int
   -> LinuxParameters)
-> Parser (Maybe [Tmpfs])
-> Parser
     (Maybe Int
      -> Maybe [Device]
      -> Maybe KernelCapabilities
      -> 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 KernelCapabilities
   -> Maybe Int
   -> LinuxParameters)
-> Parser (Maybe Int)
-> Parser
     (Maybe [Device]
      -> Maybe KernelCapabilities -> 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 KernelCapabilities -> Maybe Int -> LinuxParameters)
-> Parser (Maybe [Device])
-> Parser
     (Maybe KernelCapabilities -> 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 KernelCapabilities -> Maybe Int -> LinuxParameters)
-> Parser (Maybe KernelCapabilities)
-> Parser (Maybe Int -> LinuxParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe KernelCapabilities)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"capabilities")
            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]
Maybe KernelCapabilities
maxSwap :: Maybe Int
capabilities :: Maybe KernelCapabilities
devices :: Maybe [Device]
swappiness :: Maybe Int
tmpfs :: Maybe [Tmpfs]
initProcessEnabled :: Maybe Bool
sharedMemorySize :: Maybe Int
$sel:maxSwap:LinuxParameters' :: LinuxParameters -> Maybe Int
$sel:capabilities:LinuxParameters' :: LinuxParameters -> Maybe KernelCapabilities
$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
"capabilities" Text -> KernelCapabilities -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (KernelCapabilities -> Pair)
-> Maybe KernelCapabilities -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe KernelCapabilities
capabilities,
            (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
          ]
      )