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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The container path, mount options, and size of the tmpfs mount.
--
-- /See:/ 'newTmpfs' smart constructor.
data Tmpfs = Tmpfs'
  { -- | The list of tmpfs volume mount options.
    --
    -- Valid values:
    -- @\"defaults\" | \"ro\" | \"rw\" | \"suid\" | \"nosuid\" | \"dev\" | \"nodev\" | \"exec\" | \"noexec\" | \"sync\" | \"async\" | \"dirsync\" | \"remount\" | \"mand\" | \"nomand\" | \"atime\" | \"noatime\" | \"diratime\" | \"nodiratime\" | \"bind\" | \"rbind\" | \"unbindable\" | \"runbindable\" | \"private\" | \"rprivate\" | \"shared\" | \"rshared\" | \"slave\" | \"rslave\" | \"relatime\" | \"norelatime\" | \"strictatime\" | \"nostrictatime\" | \"mode\" | \"uid\" | \"gid\" | \"nr_inodes\" | \"nr_blocks\" | \"mpol\"@
    Tmpfs -> Maybe [Text]
mountOptions :: Prelude.Maybe [Prelude.Text],
    -- | The absolute file path where the tmpfs volume is to be mounted.
    Tmpfs -> Text
containerPath :: Prelude.Text,
    -- | The maximum size (in MiB) of the tmpfs volume.
    Tmpfs -> Int
size :: Prelude.Int
  }
  deriving (Tmpfs -> Tmpfs -> Bool
(Tmpfs -> Tmpfs -> Bool) -> (Tmpfs -> Tmpfs -> Bool) -> Eq Tmpfs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Tmpfs -> Tmpfs -> Bool
$c/= :: Tmpfs -> Tmpfs -> Bool
== :: Tmpfs -> Tmpfs -> Bool
$c== :: Tmpfs -> Tmpfs -> Bool
Prelude.Eq, ReadPrec [Tmpfs]
ReadPrec Tmpfs
Int -> ReadS Tmpfs
ReadS [Tmpfs]
(Int -> ReadS Tmpfs)
-> ReadS [Tmpfs]
-> ReadPrec Tmpfs
-> ReadPrec [Tmpfs]
-> Read Tmpfs
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Tmpfs]
$creadListPrec :: ReadPrec [Tmpfs]
readPrec :: ReadPrec Tmpfs
$creadPrec :: ReadPrec Tmpfs
readList :: ReadS [Tmpfs]
$creadList :: ReadS [Tmpfs]
readsPrec :: Int -> ReadS Tmpfs
$creadsPrec :: Int -> ReadS Tmpfs
Prelude.Read, Int -> Tmpfs -> ShowS
[Tmpfs] -> ShowS
Tmpfs -> String
(Int -> Tmpfs -> ShowS)
-> (Tmpfs -> String) -> ([Tmpfs] -> ShowS) -> Show Tmpfs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Tmpfs] -> ShowS
$cshowList :: [Tmpfs] -> ShowS
show :: Tmpfs -> String
$cshow :: Tmpfs -> String
showsPrec :: Int -> Tmpfs -> ShowS
$cshowsPrec :: Int -> Tmpfs -> ShowS
Prelude.Show, (forall x. Tmpfs -> Rep Tmpfs x)
-> (forall x. Rep Tmpfs x -> Tmpfs) -> Generic Tmpfs
forall x. Rep Tmpfs x -> Tmpfs
forall x. Tmpfs -> Rep Tmpfs x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Tmpfs x -> Tmpfs
$cfrom :: forall x. Tmpfs -> Rep Tmpfs x
Prelude.Generic)

-- |
-- Create a value of 'Tmpfs' 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:
--
-- 'mountOptions', 'tmpfs_mountOptions' - The list of tmpfs volume mount options.
--
-- Valid values:
-- @\"defaults\" | \"ro\" | \"rw\" | \"suid\" | \"nosuid\" | \"dev\" | \"nodev\" | \"exec\" | \"noexec\" | \"sync\" | \"async\" | \"dirsync\" | \"remount\" | \"mand\" | \"nomand\" | \"atime\" | \"noatime\" | \"diratime\" | \"nodiratime\" | \"bind\" | \"rbind\" | \"unbindable\" | \"runbindable\" | \"private\" | \"rprivate\" | \"shared\" | \"rshared\" | \"slave\" | \"rslave\" | \"relatime\" | \"norelatime\" | \"strictatime\" | \"nostrictatime\" | \"mode\" | \"uid\" | \"gid\" | \"nr_inodes\" | \"nr_blocks\" | \"mpol\"@
--
-- 'containerPath', 'tmpfs_containerPath' - The absolute file path where the tmpfs volume is to be mounted.
--
-- 'size', 'tmpfs_size' - The maximum size (in MiB) of the tmpfs volume.
newTmpfs ::
  -- | 'containerPath'
  Prelude.Text ->
  -- | 'size'
  Prelude.Int ->
  Tmpfs
newTmpfs :: Text -> Int -> Tmpfs
newTmpfs Text
pContainerPath_ Int
pSize_ =
  Tmpfs' :: Maybe [Text] -> Text -> Int -> Tmpfs
Tmpfs'
    { $sel:mountOptions:Tmpfs' :: Maybe [Text]
mountOptions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:containerPath:Tmpfs' :: Text
containerPath = Text
pContainerPath_,
      $sel:size:Tmpfs' :: Int
size = Int
pSize_
    }

-- | The list of tmpfs volume mount options.
--
-- Valid values:
-- @\"defaults\" | \"ro\" | \"rw\" | \"suid\" | \"nosuid\" | \"dev\" | \"nodev\" | \"exec\" | \"noexec\" | \"sync\" | \"async\" | \"dirsync\" | \"remount\" | \"mand\" | \"nomand\" | \"atime\" | \"noatime\" | \"diratime\" | \"nodiratime\" | \"bind\" | \"rbind\" | \"unbindable\" | \"runbindable\" | \"private\" | \"rprivate\" | \"shared\" | \"rshared\" | \"slave\" | \"rslave\" | \"relatime\" | \"norelatime\" | \"strictatime\" | \"nostrictatime\" | \"mode\" | \"uid\" | \"gid\" | \"nr_inodes\" | \"nr_blocks\" | \"mpol\"@
tmpfs_mountOptions :: Lens.Lens' Tmpfs (Prelude.Maybe [Prelude.Text])
tmpfs_mountOptions :: (Maybe [Text] -> f (Maybe [Text])) -> Tmpfs -> f Tmpfs
tmpfs_mountOptions = (Tmpfs -> Maybe [Text])
-> (Tmpfs -> Maybe [Text] -> Tmpfs)
-> Lens Tmpfs Tmpfs (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tmpfs' {Maybe [Text]
mountOptions :: Maybe [Text]
$sel:mountOptions:Tmpfs' :: Tmpfs -> Maybe [Text]
mountOptions} -> Maybe [Text]
mountOptions) (\s :: Tmpfs
s@Tmpfs' {} Maybe [Text]
a -> Tmpfs
s {$sel:mountOptions:Tmpfs' :: Maybe [Text]
mountOptions = Maybe [Text]
a} :: Tmpfs) ((Maybe [Text] -> f (Maybe [Text])) -> Tmpfs -> f Tmpfs)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Tmpfs
-> f Tmpfs
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The absolute file path where the tmpfs volume is to be mounted.
tmpfs_containerPath :: Lens.Lens' Tmpfs Prelude.Text
tmpfs_containerPath :: (Text -> f Text) -> Tmpfs -> f Tmpfs
tmpfs_containerPath = (Tmpfs -> Text)
-> (Tmpfs -> Text -> Tmpfs) -> Lens Tmpfs Tmpfs Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tmpfs' {Text
containerPath :: Text
$sel:containerPath:Tmpfs' :: Tmpfs -> Text
containerPath} -> Text
containerPath) (\s :: Tmpfs
s@Tmpfs' {} Text
a -> Tmpfs
s {$sel:containerPath:Tmpfs' :: Text
containerPath = Text
a} :: Tmpfs)

-- | The maximum size (in MiB) of the tmpfs volume.
tmpfs_size :: Lens.Lens' Tmpfs Prelude.Int
tmpfs_size :: (Int -> f Int) -> Tmpfs -> f Tmpfs
tmpfs_size = (Tmpfs -> Int)
-> (Tmpfs -> Int -> Tmpfs) -> Lens Tmpfs Tmpfs Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Tmpfs' {Int
size :: Int
$sel:size:Tmpfs' :: Tmpfs -> Int
size} -> Int
size) (\s :: Tmpfs
s@Tmpfs' {} Int
a -> Tmpfs
s {$sel:size:Tmpfs' :: Int
size = Int
a} :: Tmpfs)

instance Core.FromJSON Tmpfs where
  parseJSON :: Value -> Parser Tmpfs
parseJSON =
    String -> (Object -> Parser Tmpfs) -> Value -> Parser Tmpfs
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Tmpfs"
      ( \Object
x ->
          Maybe [Text] -> Text -> Int -> Tmpfs
Tmpfs'
            (Maybe [Text] -> Text -> Int -> Tmpfs)
-> Parser (Maybe [Text]) -> Parser (Text -> Int -> Tmpfs)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"mountOptions" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Text -> Int -> Tmpfs)
-> Parser Text -> Parser (Int -> Tmpfs)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"containerPath")
            Parser (Int -> Tmpfs) -> Parser Int -> Parser Tmpfs
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"size")
      )

instance Prelude.Hashable Tmpfs

instance Prelude.NFData Tmpfs

instance Core.ToJSON Tmpfs where
  toJSON :: Tmpfs -> Value
toJSON Tmpfs' {Int
Maybe [Text]
Text
size :: Int
containerPath :: Text
mountOptions :: Maybe [Text]
$sel:size:Tmpfs' :: Tmpfs -> Int
$sel:containerPath:Tmpfs' :: Tmpfs -> Text
$sel:mountOptions:Tmpfs' :: Tmpfs -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"mountOptions" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
mountOptions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"containerPath" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerPath),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"size" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
size)
          ]
      )