{-# 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.Batch.Types.EksEmptyDir
-- 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.Batch.Types.EksEmptyDir 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

-- | Specifies the configuration of a Kubernetes @emptyDir@ volume. An
-- @emptyDir@ volume is first created when a pod is assigned to a node. It
-- exists as long as that pod is running on that node. The @emptyDir@
-- volume is initially empty. All containers in the pod can read and write
-- the files in the @emptyDir@ volume. However, the @emptyDir@ volume can
-- be mounted at the same or different paths in each container. When a pod
-- is removed from a node for any reason, the data in the @emptyDir@ is
-- deleted permanently. For more information, see
-- <https://kubernetes.io/docs/concepts/storage/volumes/#emptydir emptyDir>
-- in the /Kubernetes documentation/.
--
-- /See:/ 'newEksEmptyDir' smart constructor.
data EksEmptyDir = EksEmptyDir'
  { -- | The medium to store the volume. The default value is an empty string,
    -- which uses the storage of the node.
    --
    -- [\"\"]
    --     __(Default)__ Use the disk storage of the node.
    --
    -- [\"Memory\"]
    --     Use the @tmpfs@ volume that\'s backed by the RAM of the node.
    --     Contents of the volume are lost when the node reboots, and any
    --     storage on the volume counts against the container\'s memory limit.
    EksEmptyDir -> Maybe Text
medium :: Prelude.Maybe Prelude.Text,
    -- | The maximum size of the volume. By default, there\'s no maximum size
    -- defined.
    EksEmptyDir -> Maybe Text
sizeLimit :: Prelude.Maybe Prelude.Text
  }
  deriving (EksEmptyDir -> EksEmptyDir -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EksEmptyDir -> EksEmptyDir -> Bool
$c/= :: EksEmptyDir -> EksEmptyDir -> Bool
== :: EksEmptyDir -> EksEmptyDir -> Bool
$c== :: EksEmptyDir -> EksEmptyDir -> Bool
Prelude.Eq, ReadPrec [EksEmptyDir]
ReadPrec EksEmptyDir
Int -> ReadS EksEmptyDir
ReadS [EksEmptyDir]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EksEmptyDir]
$creadListPrec :: ReadPrec [EksEmptyDir]
readPrec :: ReadPrec EksEmptyDir
$creadPrec :: ReadPrec EksEmptyDir
readList :: ReadS [EksEmptyDir]
$creadList :: ReadS [EksEmptyDir]
readsPrec :: Int -> ReadS EksEmptyDir
$creadsPrec :: Int -> ReadS EksEmptyDir
Prelude.Read, Int -> EksEmptyDir -> ShowS
[EksEmptyDir] -> ShowS
EksEmptyDir -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EksEmptyDir] -> ShowS
$cshowList :: [EksEmptyDir] -> ShowS
show :: EksEmptyDir -> String
$cshow :: EksEmptyDir -> String
showsPrec :: Int -> EksEmptyDir -> ShowS
$cshowsPrec :: Int -> EksEmptyDir -> ShowS
Prelude.Show, forall x. Rep EksEmptyDir x -> EksEmptyDir
forall x. EksEmptyDir -> Rep EksEmptyDir x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EksEmptyDir x -> EksEmptyDir
$cfrom :: forall x. EksEmptyDir -> Rep EksEmptyDir x
Prelude.Generic)

-- |
-- Create a value of 'EksEmptyDir' 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:
--
-- 'medium', 'eksEmptyDir_medium' - The medium to store the volume. The default value is an empty string,
-- which uses the storage of the node.
--
-- [\"\"]
--     __(Default)__ Use the disk storage of the node.
--
-- [\"Memory\"]
--     Use the @tmpfs@ volume that\'s backed by the RAM of the node.
--     Contents of the volume are lost when the node reboots, and any
--     storage on the volume counts against the container\'s memory limit.
--
-- 'sizeLimit', 'eksEmptyDir_sizeLimit' - The maximum size of the volume. By default, there\'s no maximum size
-- defined.
newEksEmptyDir ::
  EksEmptyDir
newEksEmptyDir :: EksEmptyDir
newEksEmptyDir =
  EksEmptyDir'
    { $sel:medium:EksEmptyDir' :: Maybe Text
medium = forall a. Maybe a
Prelude.Nothing,
      $sel:sizeLimit:EksEmptyDir' :: Maybe Text
sizeLimit = forall a. Maybe a
Prelude.Nothing
    }

-- | The medium to store the volume. The default value is an empty string,
-- which uses the storage of the node.
--
-- [\"\"]
--     __(Default)__ Use the disk storage of the node.
--
-- [\"Memory\"]
--     Use the @tmpfs@ volume that\'s backed by the RAM of the node.
--     Contents of the volume are lost when the node reboots, and any
--     storage on the volume counts against the container\'s memory limit.
eksEmptyDir_medium :: Lens.Lens' EksEmptyDir (Prelude.Maybe Prelude.Text)
eksEmptyDir_medium :: Lens' EksEmptyDir (Maybe Text)
eksEmptyDir_medium = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksEmptyDir' {Maybe Text
medium :: Maybe Text
$sel:medium:EksEmptyDir' :: EksEmptyDir -> Maybe Text
medium} -> Maybe Text
medium) (\s :: EksEmptyDir
s@EksEmptyDir' {} Maybe Text
a -> EksEmptyDir
s {$sel:medium:EksEmptyDir' :: Maybe Text
medium = Maybe Text
a} :: EksEmptyDir)

-- | The maximum size of the volume. By default, there\'s no maximum size
-- defined.
eksEmptyDir_sizeLimit :: Lens.Lens' EksEmptyDir (Prelude.Maybe Prelude.Text)
eksEmptyDir_sizeLimit :: Lens' EksEmptyDir (Maybe Text)
eksEmptyDir_sizeLimit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksEmptyDir' {Maybe Text
sizeLimit :: Maybe Text
$sel:sizeLimit:EksEmptyDir' :: EksEmptyDir -> Maybe Text
sizeLimit} -> Maybe Text
sizeLimit) (\s :: EksEmptyDir
s@EksEmptyDir' {} Maybe Text
a -> EksEmptyDir
s {$sel:sizeLimit:EksEmptyDir' :: Maybe Text
sizeLimit = Maybe Text
a} :: EksEmptyDir)

instance Data.FromJSON EksEmptyDir where
  parseJSON :: Value -> Parser EksEmptyDir
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EksEmptyDir"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> EksEmptyDir
EksEmptyDir'
            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
"medium")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sizeLimit")
      )

instance Prelude.Hashable EksEmptyDir where
  hashWithSalt :: Int -> EksEmptyDir -> Int
hashWithSalt Int
_salt EksEmptyDir' {Maybe Text
sizeLimit :: Maybe Text
medium :: Maybe Text
$sel:sizeLimit:EksEmptyDir' :: EksEmptyDir -> Maybe Text
$sel:medium:EksEmptyDir' :: EksEmptyDir -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
medium
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sizeLimit

instance Prelude.NFData EksEmptyDir where
  rnf :: EksEmptyDir -> ()
rnf EksEmptyDir' {Maybe Text
sizeLimit :: Maybe Text
medium :: Maybe Text
$sel:sizeLimit:EksEmptyDir' :: EksEmptyDir -> Maybe Text
$sel:medium:EksEmptyDir' :: EksEmptyDir -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
medium
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sizeLimit

instance Data.ToJSON EksEmptyDir where
  toJSON :: EksEmptyDir -> Value
toJSON EksEmptyDir' {Maybe Text
sizeLimit :: Maybe Text
medium :: Maybe Text
$sel:sizeLimit:EksEmptyDir' :: EksEmptyDir -> Maybe Text
$sel:medium:EksEmptyDir' :: EksEmptyDir -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"medium" 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
medium,
            (Key
"sizeLimit" 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
sizeLimit
          ]
      )