{-# 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.LambdaVolumeMount
-- 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.LambdaVolumeMount where

import qualified Amazonka.Core as Core
import Amazonka.GreengrassV2.Types.LambdaFilesystemPermission
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a volume that Linux processes in a container
-- can access. When you define a volume, the IoT Greengrass Core software
-- mounts the source files to the destination inside the container.
--
-- /See:/ 'newLambdaVolumeMount' smart constructor.
data LambdaVolumeMount = LambdaVolumeMount'
  { -- | Whether or not to add the IoT Greengrass user group as an owner of the
    -- volume.
    --
    -- Default: @false@
    LambdaVolumeMount -> Maybe Bool
addGroupOwner :: Prelude.Maybe Prelude.Bool,
    -- | The permission to access the volume: read\/only (@ro@) or read\/write
    -- (@rw@).
    --
    -- Default: @ro@
    LambdaVolumeMount -> Maybe LambdaFilesystemPermission
permission :: Prelude.Maybe LambdaFilesystemPermission,
    -- | The path to the physical volume in the file system.
    LambdaVolumeMount -> Text
sourcePath :: Prelude.Text,
    -- | The path to the logical volume in the file system.
    LambdaVolumeMount -> Text
destinationPath :: Prelude.Text
  }
  deriving (LambdaVolumeMount -> LambdaVolumeMount -> Bool
(LambdaVolumeMount -> LambdaVolumeMount -> Bool)
-> (LambdaVolumeMount -> LambdaVolumeMount -> Bool)
-> Eq LambdaVolumeMount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LambdaVolumeMount -> LambdaVolumeMount -> Bool
$c/= :: LambdaVolumeMount -> LambdaVolumeMount -> Bool
== :: LambdaVolumeMount -> LambdaVolumeMount -> Bool
$c== :: LambdaVolumeMount -> LambdaVolumeMount -> Bool
Prelude.Eq, ReadPrec [LambdaVolumeMount]
ReadPrec LambdaVolumeMount
Int -> ReadS LambdaVolumeMount
ReadS [LambdaVolumeMount]
(Int -> ReadS LambdaVolumeMount)
-> ReadS [LambdaVolumeMount]
-> ReadPrec LambdaVolumeMount
-> ReadPrec [LambdaVolumeMount]
-> Read LambdaVolumeMount
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LambdaVolumeMount]
$creadListPrec :: ReadPrec [LambdaVolumeMount]
readPrec :: ReadPrec LambdaVolumeMount
$creadPrec :: ReadPrec LambdaVolumeMount
readList :: ReadS [LambdaVolumeMount]
$creadList :: ReadS [LambdaVolumeMount]
readsPrec :: Int -> ReadS LambdaVolumeMount
$creadsPrec :: Int -> ReadS LambdaVolumeMount
Prelude.Read, Int -> LambdaVolumeMount -> ShowS
[LambdaVolumeMount] -> ShowS
LambdaVolumeMount -> String
(Int -> LambdaVolumeMount -> ShowS)
-> (LambdaVolumeMount -> String)
-> ([LambdaVolumeMount] -> ShowS)
-> Show LambdaVolumeMount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LambdaVolumeMount] -> ShowS
$cshowList :: [LambdaVolumeMount] -> ShowS
show :: LambdaVolumeMount -> String
$cshow :: LambdaVolumeMount -> String
showsPrec :: Int -> LambdaVolumeMount -> ShowS
$cshowsPrec :: Int -> LambdaVolumeMount -> ShowS
Prelude.Show, (forall x. LambdaVolumeMount -> Rep LambdaVolumeMount x)
-> (forall x. Rep LambdaVolumeMount x -> LambdaVolumeMount)
-> Generic LambdaVolumeMount
forall x. Rep LambdaVolumeMount x -> LambdaVolumeMount
forall x. LambdaVolumeMount -> Rep LambdaVolumeMount x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LambdaVolumeMount x -> LambdaVolumeMount
$cfrom :: forall x. LambdaVolumeMount -> Rep LambdaVolumeMount x
Prelude.Generic)

-- |
-- Create a value of 'LambdaVolumeMount' 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:
--
-- 'addGroupOwner', 'lambdaVolumeMount_addGroupOwner' - Whether or not to add the IoT Greengrass user group as an owner of the
-- volume.
--
-- Default: @false@
--
-- 'permission', 'lambdaVolumeMount_permission' - The permission to access the volume: read\/only (@ro@) or read\/write
-- (@rw@).
--
-- Default: @ro@
--
-- 'sourcePath', 'lambdaVolumeMount_sourcePath' - The path to the physical volume in the file system.
--
-- 'destinationPath', 'lambdaVolumeMount_destinationPath' - The path to the logical volume in the file system.
newLambdaVolumeMount ::
  -- | 'sourcePath'
  Prelude.Text ->
  -- | 'destinationPath'
  Prelude.Text ->
  LambdaVolumeMount
newLambdaVolumeMount :: Text -> Text -> LambdaVolumeMount
newLambdaVolumeMount Text
pSourcePath_ Text
pDestinationPath_ =
  LambdaVolumeMount' :: Maybe Bool
-> Maybe LambdaFilesystemPermission
-> Text
-> Text
-> LambdaVolumeMount
LambdaVolumeMount'
    { $sel:addGroupOwner:LambdaVolumeMount' :: Maybe Bool
addGroupOwner = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:permission:LambdaVolumeMount' :: Maybe LambdaFilesystemPermission
permission = Maybe LambdaFilesystemPermission
forall a. Maybe a
Prelude.Nothing,
      $sel:sourcePath:LambdaVolumeMount' :: Text
sourcePath = Text
pSourcePath_,
      $sel:destinationPath:LambdaVolumeMount' :: Text
destinationPath = Text
pDestinationPath_
    }

-- | Whether or not to add the IoT Greengrass user group as an owner of the
-- volume.
--
-- Default: @false@
lambdaVolumeMount_addGroupOwner :: Lens.Lens' LambdaVolumeMount (Prelude.Maybe Prelude.Bool)
lambdaVolumeMount_addGroupOwner :: (Maybe Bool -> f (Maybe Bool))
-> LambdaVolumeMount -> f LambdaVolumeMount
lambdaVolumeMount_addGroupOwner = (LambdaVolumeMount -> Maybe Bool)
-> (LambdaVolumeMount -> Maybe Bool -> LambdaVolumeMount)
-> Lens
     LambdaVolumeMount LambdaVolumeMount (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaVolumeMount' {Maybe Bool
addGroupOwner :: Maybe Bool
$sel:addGroupOwner:LambdaVolumeMount' :: LambdaVolumeMount -> Maybe Bool
addGroupOwner} -> Maybe Bool
addGroupOwner) (\s :: LambdaVolumeMount
s@LambdaVolumeMount' {} Maybe Bool
a -> LambdaVolumeMount
s {$sel:addGroupOwner:LambdaVolumeMount' :: Maybe Bool
addGroupOwner = Maybe Bool
a} :: LambdaVolumeMount)

-- | The permission to access the volume: read\/only (@ro@) or read\/write
-- (@rw@).
--
-- Default: @ro@
lambdaVolumeMount_permission :: Lens.Lens' LambdaVolumeMount (Prelude.Maybe LambdaFilesystemPermission)
lambdaVolumeMount_permission :: (Maybe LambdaFilesystemPermission
 -> f (Maybe LambdaFilesystemPermission))
-> LambdaVolumeMount -> f LambdaVolumeMount
lambdaVolumeMount_permission = (LambdaVolumeMount -> Maybe LambdaFilesystemPermission)
-> (LambdaVolumeMount
    -> Maybe LambdaFilesystemPermission -> LambdaVolumeMount)
-> Lens
     LambdaVolumeMount
     LambdaVolumeMount
     (Maybe LambdaFilesystemPermission)
     (Maybe LambdaFilesystemPermission)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaVolumeMount' {Maybe LambdaFilesystemPermission
permission :: Maybe LambdaFilesystemPermission
$sel:permission:LambdaVolumeMount' :: LambdaVolumeMount -> Maybe LambdaFilesystemPermission
permission} -> Maybe LambdaFilesystemPermission
permission) (\s :: LambdaVolumeMount
s@LambdaVolumeMount' {} Maybe LambdaFilesystemPermission
a -> LambdaVolumeMount
s {$sel:permission:LambdaVolumeMount' :: Maybe LambdaFilesystemPermission
permission = Maybe LambdaFilesystemPermission
a} :: LambdaVolumeMount)

-- | The path to the physical volume in the file system.
lambdaVolumeMount_sourcePath :: Lens.Lens' LambdaVolumeMount Prelude.Text
lambdaVolumeMount_sourcePath :: (Text -> f Text) -> LambdaVolumeMount -> f LambdaVolumeMount
lambdaVolumeMount_sourcePath = (LambdaVolumeMount -> Text)
-> (LambdaVolumeMount -> Text -> LambdaVolumeMount)
-> Lens LambdaVolumeMount LambdaVolumeMount Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaVolumeMount' {Text
sourcePath :: Text
$sel:sourcePath:LambdaVolumeMount' :: LambdaVolumeMount -> Text
sourcePath} -> Text
sourcePath) (\s :: LambdaVolumeMount
s@LambdaVolumeMount' {} Text
a -> LambdaVolumeMount
s {$sel:sourcePath:LambdaVolumeMount' :: Text
sourcePath = Text
a} :: LambdaVolumeMount)

-- | The path to the logical volume in the file system.
lambdaVolumeMount_destinationPath :: Lens.Lens' LambdaVolumeMount Prelude.Text
lambdaVolumeMount_destinationPath :: (Text -> f Text) -> LambdaVolumeMount -> f LambdaVolumeMount
lambdaVolumeMount_destinationPath = (LambdaVolumeMount -> Text)
-> (LambdaVolumeMount -> Text -> LambdaVolumeMount)
-> Lens LambdaVolumeMount LambdaVolumeMount Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LambdaVolumeMount' {Text
destinationPath :: Text
$sel:destinationPath:LambdaVolumeMount' :: LambdaVolumeMount -> Text
destinationPath} -> Text
destinationPath) (\s :: LambdaVolumeMount
s@LambdaVolumeMount' {} Text
a -> LambdaVolumeMount
s {$sel:destinationPath:LambdaVolumeMount' :: Text
destinationPath = Text
a} :: LambdaVolumeMount)

instance Prelude.Hashable LambdaVolumeMount

instance Prelude.NFData LambdaVolumeMount

instance Core.ToJSON LambdaVolumeMount where
  toJSON :: LambdaVolumeMount -> Value
toJSON LambdaVolumeMount' {Maybe Bool
Maybe LambdaFilesystemPermission
Text
destinationPath :: Text
sourcePath :: Text
permission :: Maybe LambdaFilesystemPermission
addGroupOwner :: Maybe Bool
$sel:destinationPath:LambdaVolumeMount' :: LambdaVolumeMount -> Text
$sel:sourcePath:LambdaVolumeMount' :: LambdaVolumeMount -> Text
$sel:permission:LambdaVolumeMount' :: LambdaVolumeMount -> Maybe LambdaFilesystemPermission
$sel:addGroupOwner:LambdaVolumeMount' :: LambdaVolumeMount -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"addGroupOwner" 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
addGroupOwner,
            (Text
"permission" Text -> LambdaFilesystemPermission -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LambdaFilesystemPermission -> Pair)
-> Maybe LambdaFilesystemPermission -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaFilesystemPermission
permission,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"sourcePath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourcePath),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"destinationPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationPath)
          ]
      )