{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Types.Tmpfs where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:mountOptions:Tmpfs' :: Maybe [Text]
mountOptions = 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 :: Lens' Tmpfs (Maybe [Text])
tmpfs_mountOptions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' Tmpfs Text
tmpfs_containerPath = 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 :: Lens' Tmpfs Int
tmpfs_size = 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 Data.FromJSON Tmpfs where
  parseJSON :: Value -> Parser Tmpfs
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Tmpfs"
      ( \Object
x ->
          Maybe [Text] -> Text -> Int -> Tmpfs
Tmpfs'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"mountOptions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"containerPath")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"size")
      )

instance Prelude.Hashable Tmpfs where
  hashWithSalt :: Int -> Tmpfs -> Int
hashWithSalt Int
_salt 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]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
mountOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
containerPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
size

instance Prelude.NFData Tmpfs where
  rnf :: Tmpfs -> ()
rnf 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]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
mountOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
containerPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
size

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"mountOptions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
mountOptions,
            forall a. a -> Maybe a
Prelude.Just (Key
"containerPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
containerPath),
            forall a. a -> Maybe a
Prelude.Just (Key
"size" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
size)
          ]
      )