{-# 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.GreengrassV2.Types.LambdaContainerParams
-- 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.GreengrassV2.Types.LambdaContainerParams where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.LambdaDeviceMount
import Amazonka.GreengrassV2.Types.LambdaVolumeMount
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a container in which Lambda functions run on
-- Greengrass core devices.
--
-- /See:/ 'newLambdaContainerParams' smart constructor.
data LambdaContainerParams = LambdaContainerParams'
  { -- | Whether or not the container can read information from the device\'s
    -- @\/sys@ folder.
    --
    -- Default: @false@
    LambdaContainerParams -> Maybe Bool
mountROSysfs :: Prelude.Maybe Prelude.Bool,
    -- | The memory size of the container, expressed in kilobytes.
    --
    -- Default: @16384@ (16 MB)
    LambdaContainerParams -> Maybe Int
memorySizeInKB :: Prelude.Maybe Prelude.Int,
    -- | The list of system devices that the container can access.
    LambdaContainerParams -> Maybe [LambdaDeviceMount]
devices :: Prelude.Maybe [LambdaDeviceMount],
    -- | The list of volumes that the container can access.
    LambdaContainerParams -> Maybe [LambdaVolumeMount]
volumes :: Prelude.Maybe [LambdaVolumeMount]
  }
  deriving (LambdaContainerParams -> LambdaContainerParams -> Bool
(LambdaContainerParams -> LambdaContainerParams -> Bool)
-> (LambdaContainerParams -> LambdaContainerParams -> Bool)
-> Eq LambdaContainerParams
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaContainerParams -> LambdaContainerParams -> Bool
$c/= :: LambdaContainerParams -> LambdaContainerParams -> Bool
== :: LambdaContainerParams -> LambdaContainerParams -> Bool
$c== :: LambdaContainerParams -> LambdaContainerParams -> Bool
Prelude.Eq, ReadPrec [LambdaContainerParams]
ReadPrec LambdaContainerParams
Int -> ReadS LambdaContainerParams
ReadS [LambdaContainerParams]
(Int -> ReadS LambdaContainerParams)
-> ReadS [LambdaContainerParams]
-> ReadPrec LambdaContainerParams
-> ReadPrec [LambdaContainerParams]
-> Read LambdaContainerParams
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaContainerParams]
$creadListPrec :: ReadPrec [LambdaContainerParams]
readPrec :: ReadPrec LambdaContainerParams
$creadPrec :: ReadPrec LambdaContainerParams
readList :: ReadS [LambdaContainerParams]
$creadList :: ReadS [LambdaContainerParams]
readsPrec :: Int -> ReadS LambdaContainerParams
$creadsPrec :: Int -> ReadS LambdaContainerParams
Prelude.Read, Int -> LambdaContainerParams -> ShowS
[LambdaContainerParams] -> ShowS
LambdaContainerParams -> String
(Int -> LambdaContainerParams -> ShowS)
-> (LambdaContainerParams -> String)
-> ([LambdaContainerParams] -> ShowS)
-> Show LambdaContainerParams
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaContainerParams] -> ShowS
$cshowList :: [LambdaContainerParams] -> ShowS
show :: LambdaContainerParams -> String
$cshow :: LambdaContainerParams -> String
showsPrec :: Int -> LambdaContainerParams -> ShowS
$cshowsPrec :: Int -> LambdaContainerParams -> ShowS
Prelude.Show, (forall x. LambdaContainerParams -> Rep LambdaContainerParams x)
-> (forall x. Rep LambdaContainerParams x -> LambdaContainerParams)
-> Generic LambdaContainerParams
forall x. Rep LambdaContainerParams x -> LambdaContainerParams
forall x. LambdaContainerParams -> Rep LambdaContainerParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaContainerParams x -> LambdaContainerParams
$cfrom :: forall x. LambdaContainerParams -> Rep LambdaContainerParams x
Prelude.Generic)

-- |
-- Create a value of 'LambdaContainerParams' 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:
--
-- 'mountROSysfs', 'lambdaContainerParams_mountROSysfs' - Whether or not the container can read information from the device\'s
-- @\/sys@ folder.
--
-- Default: @false@
--
-- 'memorySizeInKB', 'lambdaContainerParams_memorySizeInKB' - The memory size of the container, expressed in kilobytes.
--
-- Default: @16384@ (16 MB)
--
-- 'devices', 'lambdaContainerParams_devices' - The list of system devices that the container can access.
--
-- 'volumes', 'lambdaContainerParams_volumes' - The list of volumes that the container can access.
newLambdaContainerParams ::
  LambdaContainerParams
newLambdaContainerParams :: LambdaContainerParams
newLambdaContainerParams =
  LambdaContainerParams' :: Maybe Bool
-> Maybe Int
-> Maybe [LambdaDeviceMount]
-> Maybe [LambdaVolumeMount]
-> LambdaContainerParams
LambdaContainerParams'
    { $sel:mountROSysfs:LambdaContainerParams' :: Maybe Bool
mountROSysfs =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:memorySizeInKB:LambdaContainerParams' :: Maybe Int
memorySizeInKB = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:devices:LambdaContainerParams' :: Maybe [LambdaDeviceMount]
devices = Maybe [LambdaDeviceMount]
forall a. Maybe a
Prelude.Nothing,
      $sel:volumes:LambdaContainerParams' :: Maybe [LambdaVolumeMount]
volumes = Maybe [LambdaVolumeMount]
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether or not the container can read information from the device\'s
-- @\/sys@ folder.
--
-- Default: @false@
lambdaContainerParams_mountROSysfs :: Lens.Lens' LambdaContainerParams (Prelude.Maybe Prelude.Bool)
lambdaContainerParams_mountROSysfs :: (Maybe Bool -> f (Maybe Bool))
-> LambdaContainerParams -> f LambdaContainerParams
lambdaContainerParams_mountROSysfs = (LambdaContainerParams -> Maybe Bool)
-> (LambdaContainerParams -> Maybe Bool -> LambdaContainerParams)
-> Lens
     LambdaContainerParams
     LambdaContainerParams
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaContainerParams' {Maybe Bool
mountROSysfs :: Maybe Bool
$sel:mountROSysfs:LambdaContainerParams' :: LambdaContainerParams -> Maybe Bool
mountROSysfs} -> Maybe Bool
mountROSysfs) (\s :: LambdaContainerParams
s@LambdaContainerParams' {} Maybe Bool
a -> LambdaContainerParams
s {$sel:mountROSysfs:LambdaContainerParams' :: Maybe Bool
mountROSysfs = Maybe Bool
a} :: LambdaContainerParams)

-- | The memory size of the container, expressed in kilobytes.
--
-- Default: @16384@ (16 MB)
lambdaContainerParams_memorySizeInKB :: Lens.Lens' LambdaContainerParams (Prelude.Maybe Prelude.Int)
lambdaContainerParams_memorySizeInKB :: (Maybe Int -> f (Maybe Int))
-> LambdaContainerParams -> f LambdaContainerParams
lambdaContainerParams_memorySizeInKB = (LambdaContainerParams -> Maybe Int)
-> (LambdaContainerParams -> Maybe Int -> LambdaContainerParams)
-> Lens
     LambdaContainerParams LambdaContainerParams (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaContainerParams' {Maybe Int
memorySizeInKB :: Maybe Int
$sel:memorySizeInKB:LambdaContainerParams' :: LambdaContainerParams -> Maybe Int
memorySizeInKB} -> Maybe Int
memorySizeInKB) (\s :: LambdaContainerParams
s@LambdaContainerParams' {} Maybe Int
a -> LambdaContainerParams
s {$sel:memorySizeInKB:LambdaContainerParams' :: Maybe Int
memorySizeInKB = Maybe Int
a} :: LambdaContainerParams)

-- | The list of system devices that the container can access.
lambdaContainerParams_devices :: Lens.Lens' LambdaContainerParams (Prelude.Maybe [LambdaDeviceMount])
lambdaContainerParams_devices :: (Maybe [LambdaDeviceMount] -> f (Maybe [LambdaDeviceMount]))
-> LambdaContainerParams -> f LambdaContainerParams
lambdaContainerParams_devices = (LambdaContainerParams -> Maybe [LambdaDeviceMount])
-> (LambdaContainerParams
    -> Maybe [LambdaDeviceMount] -> LambdaContainerParams)
-> Lens
     LambdaContainerParams
     LambdaContainerParams
     (Maybe [LambdaDeviceMount])
     (Maybe [LambdaDeviceMount])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaContainerParams' {Maybe [LambdaDeviceMount]
devices :: Maybe [LambdaDeviceMount]
$sel:devices:LambdaContainerParams' :: LambdaContainerParams -> Maybe [LambdaDeviceMount]
devices} -> Maybe [LambdaDeviceMount]
devices) (\s :: LambdaContainerParams
s@LambdaContainerParams' {} Maybe [LambdaDeviceMount]
a -> LambdaContainerParams
s {$sel:devices:LambdaContainerParams' :: Maybe [LambdaDeviceMount]
devices = Maybe [LambdaDeviceMount]
a} :: LambdaContainerParams) ((Maybe [LambdaDeviceMount] -> f (Maybe [LambdaDeviceMount]))
 -> LambdaContainerParams -> f LambdaContainerParams)
-> ((Maybe [LambdaDeviceMount] -> f (Maybe [LambdaDeviceMount]))
    -> Maybe [LambdaDeviceMount] -> f (Maybe [LambdaDeviceMount]))
-> (Maybe [LambdaDeviceMount] -> f (Maybe [LambdaDeviceMount]))
-> LambdaContainerParams
-> f LambdaContainerParams
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LambdaDeviceMount]
  [LambdaDeviceMount]
  [LambdaDeviceMount]
  [LambdaDeviceMount]
-> Iso
     (Maybe [LambdaDeviceMount])
     (Maybe [LambdaDeviceMount])
     (Maybe [LambdaDeviceMount])
     (Maybe [LambdaDeviceMount])
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
  [LambdaDeviceMount]
  [LambdaDeviceMount]
  [LambdaDeviceMount]
  [LambdaDeviceMount]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The list of volumes that the container can access.
lambdaContainerParams_volumes :: Lens.Lens' LambdaContainerParams (Prelude.Maybe [LambdaVolumeMount])
lambdaContainerParams_volumes :: (Maybe [LambdaVolumeMount] -> f (Maybe [LambdaVolumeMount]))
-> LambdaContainerParams -> f LambdaContainerParams
lambdaContainerParams_volumes = (LambdaContainerParams -> Maybe [LambdaVolumeMount])
-> (LambdaContainerParams
    -> Maybe [LambdaVolumeMount] -> LambdaContainerParams)
-> Lens
     LambdaContainerParams
     LambdaContainerParams
     (Maybe [LambdaVolumeMount])
     (Maybe [LambdaVolumeMount])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaContainerParams' {Maybe [LambdaVolumeMount]
volumes :: Maybe [LambdaVolumeMount]
$sel:volumes:LambdaContainerParams' :: LambdaContainerParams -> Maybe [LambdaVolumeMount]
volumes} -> Maybe [LambdaVolumeMount]
volumes) (\s :: LambdaContainerParams
s@LambdaContainerParams' {} Maybe [LambdaVolumeMount]
a -> LambdaContainerParams
s {$sel:volumes:LambdaContainerParams' :: Maybe [LambdaVolumeMount]
volumes = Maybe [LambdaVolumeMount]
a} :: LambdaContainerParams) ((Maybe [LambdaVolumeMount] -> f (Maybe [LambdaVolumeMount]))
 -> LambdaContainerParams -> f LambdaContainerParams)
-> ((Maybe [LambdaVolumeMount] -> f (Maybe [LambdaVolumeMount]))
    -> Maybe [LambdaVolumeMount] -> f (Maybe [LambdaVolumeMount]))
-> (Maybe [LambdaVolumeMount] -> f (Maybe [LambdaVolumeMount]))
-> LambdaContainerParams
-> f LambdaContainerParams
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LambdaVolumeMount]
  [LambdaVolumeMount]
  [LambdaVolumeMount]
  [LambdaVolumeMount]
-> Iso
     (Maybe [LambdaVolumeMount])
     (Maybe [LambdaVolumeMount])
     (Maybe [LambdaVolumeMount])
     (Maybe [LambdaVolumeMount])
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
  [LambdaVolumeMount]
  [LambdaVolumeMount]
  [LambdaVolumeMount]
  [LambdaVolumeMount]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable LambdaContainerParams

instance Prelude.NFData LambdaContainerParams

instance Core.ToJSON LambdaContainerParams where
  toJSON :: LambdaContainerParams -> Value
toJSON LambdaContainerParams' {Maybe Bool
Maybe Int
Maybe [LambdaDeviceMount]
Maybe [LambdaVolumeMount]
volumes :: Maybe [LambdaVolumeMount]
devices :: Maybe [LambdaDeviceMount]
memorySizeInKB :: Maybe Int
mountROSysfs :: Maybe Bool
$sel:volumes:LambdaContainerParams' :: LambdaContainerParams -> Maybe [LambdaVolumeMount]
$sel:devices:LambdaContainerParams' :: LambdaContainerParams -> Maybe [LambdaDeviceMount]
$sel:memorySizeInKB:LambdaContainerParams' :: LambdaContainerParams -> Maybe Int
$sel:mountROSysfs:LambdaContainerParams' :: LambdaContainerParams -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"mountROSysfs" 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
mountROSysfs,
            (Text
"memorySizeInKB" 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
memorySizeInKB,
            (Text
"devices" Text -> [LambdaDeviceMount] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([LambdaDeviceMount] -> Pair)
-> Maybe [LambdaDeviceMount] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [LambdaDeviceMount]
devices,
            (Text
"volumes" Text -> [LambdaVolumeMount] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([LambdaVolumeMount] -> Pair)
-> Maybe [LambdaVolumeMount] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [LambdaVolumeMount]
volumes
          ]
      )