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

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

-- | The amount of ephemeral storage to allocate for the task. This parameter
-- is used to expand the total amount of ephemeral storage available,
-- beyond the default amount, for tasks hosted on Fargate. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/userguide/using_data_volumes.html Fargate task storage>
-- in the /Amazon ECS User Guide for Fargate/.
--
-- This parameter is only supported for tasks hosted on Fargate using
-- platform version @1.4.0@ or later.
--
-- /See:/ 'newEphemeralStorage' smart constructor.
data EphemeralStorage = EphemeralStorage'
  { -- | The total amount, in GiB, of ephemeral storage to set for the task. The
    -- minimum supported value is @21@ GiB and the maximum supported value is
    -- @200@ GiB.
    EphemeralStorage -> Int
sizeInGiB :: Prelude.Int
  }
  deriving (EphemeralStorage -> EphemeralStorage -> Bool
(EphemeralStorage -> EphemeralStorage -> Bool)
-> (EphemeralStorage -> EphemeralStorage -> Bool)
-> Eq EphemeralStorage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EphemeralStorage -> EphemeralStorage -> Bool
$c/= :: EphemeralStorage -> EphemeralStorage -> Bool
== :: EphemeralStorage -> EphemeralStorage -> Bool
$c== :: EphemeralStorage -> EphemeralStorage -> Bool
Prelude.Eq, ReadPrec [EphemeralStorage]
ReadPrec EphemeralStorage
Int -> ReadS EphemeralStorage
ReadS [EphemeralStorage]
(Int -> ReadS EphemeralStorage)
-> ReadS [EphemeralStorage]
-> ReadPrec EphemeralStorage
-> ReadPrec [EphemeralStorage]
-> Read EphemeralStorage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EphemeralStorage]
$creadListPrec :: ReadPrec [EphemeralStorage]
readPrec :: ReadPrec EphemeralStorage
$creadPrec :: ReadPrec EphemeralStorage
readList :: ReadS [EphemeralStorage]
$creadList :: ReadS [EphemeralStorage]
readsPrec :: Int -> ReadS EphemeralStorage
$creadsPrec :: Int -> ReadS EphemeralStorage
Prelude.Read, Int -> EphemeralStorage -> ShowS
[EphemeralStorage] -> ShowS
EphemeralStorage -> String
(Int -> EphemeralStorage -> ShowS)
-> (EphemeralStorage -> String)
-> ([EphemeralStorage] -> ShowS)
-> Show EphemeralStorage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EphemeralStorage] -> ShowS
$cshowList :: [EphemeralStorage] -> ShowS
show :: EphemeralStorage -> String
$cshow :: EphemeralStorage -> String
showsPrec :: Int -> EphemeralStorage -> ShowS
$cshowsPrec :: Int -> EphemeralStorage -> ShowS
Prelude.Show, (forall x. EphemeralStorage -> Rep EphemeralStorage x)
-> (forall x. Rep EphemeralStorage x -> EphemeralStorage)
-> Generic EphemeralStorage
forall x. Rep EphemeralStorage x -> EphemeralStorage
forall x. EphemeralStorage -> Rep EphemeralStorage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EphemeralStorage x -> EphemeralStorage
$cfrom :: forall x. EphemeralStorage -> Rep EphemeralStorage x
Prelude.Generic)

-- |
-- Create a value of 'EphemeralStorage' 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:
--
-- 'sizeInGiB', 'ephemeralStorage_sizeInGiB' - The total amount, in GiB, of ephemeral storage to set for the task. The
-- minimum supported value is @21@ GiB and the maximum supported value is
-- @200@ GiB.
newEphemeralStorage ::
  -- | 'sizeInGiB'
  Prelude.Int ->
  EphemeralStorage
newEphemeralStorage :: Int -> EphemeralStorage
newEphemeralStorage Int
pSizeInGiB_ =
  EphemeralStorage' :: Int -> EphemeralStorage
EphemeralStorage' {$sel:sizeInGiB:EphemeralStorage' :: Int
sizeInGiB = Int
pSizeInGiB_}

-- | The total amount, in GiB, of ephemeral storage to set for the task. The
-- minimum supported value is @21@ GiB and the maximum supported value is
-- @200@ GiB.
ephemeralStorage_sizeInGiB :: Lens.Lens' EphemeralStorage Prelude.Int
ephemeralStorage_sizeInGiB :: (Int -> f Int) -> EphemeralStorage -> f EphemeralStorage
ephemeralStorage_sizeInGiB = (EphemeralStorage -> Int)
-> (EphemeralStorage -> Int -> EphemeralStorage)
-> Lens EphemeralStorage EphemeralStorage Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EphemeralStorage' {Int
sizeInGiB :: Int
$sel:sizeInGiB:EphemeralStorage' :: EphemeralStorage -> Int
sizeInGiB} -> Int
sizeInGiB) (\s :: EphemeralStorage
s@EphemeralStorage' {} Int
a -> EphemeralStorage
s {$sel:sizeInGiB:EphemeralStorage' :: Int
sizeInGiB = Int
a} :: EphemeralStorage)

instance Core.FromJSON EphemeralStorage where
  parseJSON :: Value -> Parser EphemeralStorage
parseJSON =
    String
-> (Object -> Parser EphemeralStorage)
-> Value
-> Parser EphemeralStorage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EphemeralStorage"
      ( \Object
x ->
          Int -> EphemeralStorage
EphemeralStorage'
            (Int -> EphemeralStorage) -> Parser Int -> Parser EphemeralStorage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"sizeInGiB")
      )

instance Prelude.Hashable EphemeralStorage

instance Prelude.NFData EphemeralStorage

instance Core.ToJSON EphemeralStorage where
  toJSON :: EphemeralStorage -> Value
toJSON EphemeralStorage' {Int
sizeInGiB :: Int
$sel:sizeInGiB:EphemeralStorage' :: EphemeralStorage -> Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"sizeInGiB" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
sizeInGiB)]
      )