{-# 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.EMR.Types.VolumeSpecification
-- 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.EMR.Types.VolumeSpecification 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

-- | EBS volume specifications such as volume type, IOPS, size (GiB) and
-- throughput (MiB\/s) that are requested for the EBS volume attached to an
-- EC2 instance in the cluster.
--
-- /See:/ 'newVolumeSpecification' smart constructor.
data VolumeSpecification = VolumeSpecification'
  { -- | The number of I\/O operations per second (IOPS) that the volume
    -- supports.
    VolumeSpecification -> Maybe Int
iops :: Prelude.Maybe Prelude.Int,
    -- | The throughput, in mebibyte per second (MiB\/s). This optional parameter
    -- can be a number from 125 - 1000 and is valid only for gp3 volumes.
    VolumeSpecification -> Maybe Natural
throughput :: Prelude.Maybe Prelude.Natural,
    -- | The volume type. Volume types supported are gp3, gp2, io1, st1, sc1, and
    -- standard.
    VolumeSpecification -> Text
volumeType :: Prelude.Text,
    -- | The volume size, in gibibytes (GiB). This can be a number from 1 - 1024.
    -- If the volume type is EBS-optimized, the minimum value is 10.
    VolumeSpecification -> Int
sizeInGB :: Prelude.Int
  }
  deriving (VolumeSpecification -> VolumeSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VolumeSpecification -> VolumeSpecification -> Bool
$c/= :: VolumeSpecification -> VolumeSpecification -> Bool
== :: VolumeSpecification -> VolumeSpecification -> Bool
$c== :: VolumeSpecification -> VolumeSpecification -> Bool
Prelude.Eq, ReadPrec [VolumeSpecification]
ReadPrec VolumeSpecification
Int -> ReadS VolumeSpecification
ReadS [VolumeSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VolumeSpecification]
$creadListPrec :: ReadPrec [VolumeSpecification]
readPrec :: ReadPrec VolumeSpecification
$creadPrec :: ReadPrec VolumeSpecification
readList :: ReadS [VolumeSpecification]
$creadList :: ReadS [VolumeSpecification]
readsPrec :: Int -> ReadS VolumeSpecification
$creadsPrec :: Int -> ReadS VolumeSpecification
Prelude.Read, Int -> VolumeSpecification -> ShowS
[VolumeSpecification] -> ShowS
VolumeSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VolumeSpecification] -> ShowS
$cshowList :: [VolumeSpecification] -> ShowS
show :: VolumeSpecification -> String
$cshow :: VolumeSpecification -> String
showsPrec :: Int -> VolumeSpecification -> ShowS
$cshowsPrec :: Int -> VolumeSpecification -> ShowS
Prelude.Show, forall x. Rep VolumeSpecification x -> VolumeSpecification
forall x. VolumeSpecification -> Rep VolumeSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VolumeSpecification x -> VolumeSpecification
$cfrom :: forall x. VolumeSpecification -> Rep VolumeSpecification x
Prelude.Generic)

-- |
-- Create a value of 'VolumeSpecification' 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:
--
-- 'iops', 'volumeSpecification_iops' - The number of I\/O operations per second (IOPS) that the volume
-- supports.
--
-- 'throughput', 'volumeSpecification_throughput' - The throughput, in mebibyte per second (MiB\/s). This optional parameter
-- can be a number from 125 - 1000 and is valid only for gp3 volumes.
--
-- 'volumeType', 'volumeSpecification_volumeType' - The volume type. Volume types supported are gp3, gp2, io1, st1, sc1, and
-- standard.
--
-- 'sizeInGB', 'volumeSpecification_sizeInGB' - The volume size, in gibibytes (GiB). This can be a number from 1 - 1024.
-- If the volume type is EBS-optimized, the minimum value is 10.
newVolumeSpecification ::
  -- | 'volumeType'
  Prelude.Text ->
  -- | 'sizeInGB'
  Prelude.Int ->
  VolumeSpecification
newVolumeSpecification :: Text -> Int -> VolumeSpecification
newVolumeSpecification Text
pVolumeType_ Int
pSizeInGB_ =
  VolumeSpecification'
    { $sel:iops:VolumeSpecification' :: Maybe Int
iops = forall a. Maybe a
Prelude.Nothing,
      $sel:throughput:VolumeSpecification' :: Maybe Natural
throughput = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeType:VolumeSpecification' :: Text
volumeType = Text
pVolumeType_,
      $sel:sizeInGB:VolumeSpecification' :: Int
sizeInGB = Int
pSizeInGB_
    }

-- | The number of I\/O operations per second (IOPS) that the volume
-- supports.
volumeSpecification_iops :: Lens.Lens' VolumeSpecification (Prelude.Maybe Prelude.Int)
volumeSpecification_iops :: Lens' VolumeSpecification (Maybe Int)
volumeSpecification_iops = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeSpecification' {Maybe Int
iops :: Maybe Int
$sel:iops:VolumeSpecification' :: VolumeSpecification -> Maybe Int
iops} -> Maybe Int
iops) (\s :: VolumeSpecification
s@VolumeSpecification' {} Maybe Int
a -> VolumeSpecification
s {$sel:iops:VolumeSpecification' :: Maybe Int
iops = Maybe Int
a} :: VolumeSpecification)

-- | The throughput, in mebibyte per second (MiB\/s). This optional parameter
-- can be a number from 125 - 1000 and is valid only for gp3 volumes.
volumeSpecification_throughput :: Lens.Lens' VolumeSpecification (Prelude.Maybe Prelude.Natural)
volumeSpecification_throughput :: Lens' VolumeSpecification (Maybe Natural)
volumeSpecification_throughput = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeSpecification' {Maybe Natural
throughput :: Maybe Natural
$sel:throughput:VolumeSpecification' :: VolumeSpecification -> Maybe Natural
throughput} -> Maybe Natural
throughput) (\s :: VolumeSpecification
s@VolumeSpecification' {} Maybe Natural
a -> VolumeSpecification
s {$sel:throughput:VolumeSpecification' :: Maybe Natural
throughput = Maybe Natural
a} :: VolumeSpecification)

-- | The volume type. Volume types supported are gp3, gp2, io1, st1, sc1, and
-- standard.
volumeSpecification_volumeType :: Lens.Lens' VolumeSpecification Prelude.Text
volumeSpecification_volumeType :: Lens' VolumeSpecification Text
volumeSpecification_volumeType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeSpecification' {Text
volumeType :: Text
$sel:volumeType:VolumeSpecification' :: VolumeSpecification -> Text
volumeType} -> Text
volumeType) (\s :: VolumeSpecification
s@VolumeSpecification' {} Text
a -> VolumeSpecification
s {$sel:volumeType:VolumeSpecification' :: Text
volumeType = Text
a} :: VolumeSpecification)

-- | The volume size, in gibibytes (GiB). This can be a number from 1 - 1024.
-- If the volume type is EBS-optimized, the minimum value is 10.
volumeSpecification_sizeInGB :: Lens.Lens' VolumeSpecification Prelude.Int
volumeSpecification_sizeInGB :: Lens' VolumeSpecification Int
volumeSpecification_sizeInGB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VolumeSpecification' {Int
sizeInGB :: Int
$sel:sizeInGB:VolumeSpecification' :: VolumeSpecification -> Int
sizeInGB} -> Int
sizeInGB) (\s :: VolumeSpecification
s@VolumeSpecification' {} Int
a -> VolumeSpecification
s {$sel:sizeInGB:VolumeSpecification' :: Int
sizeInGB = Int
a} :: VolumeSpecification)

instance Data.FromJSON VolumeSpecification where
  parseJSON :: Value -> Parser VolumeSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VolumeSpecification"
      ( \Object
x ->
          Maybe Int -> Maybe Natural -> Text -> Int -> VolumeSpecification
VolumeSpecification'
            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
"Iops")
            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
"Throughput")
            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
"VolumeType")
            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
"SizeInGB")
      )

instance Prelude.Hashable VolumeSpecification where
  hashWithSalt :: Int -> VolumeSpecification -> Int
hashWithSalt Int
_salt VolumeSpecification' {Int
Maybe Int
Maybe Natural
Text
sizeInGB :: Int
volumeType :: Text
throughput :: Maybe Natural
iops :: Maybe Int
$sel:sizeInGB:VolumeSpecification' :: VolumeSpecification -> Int
$sel:volumeType:VolumeSpecification' :: VolumeSpecification -> Text
$sel:throughput:VolumeSpecification' :: VolumeSpecification -> Maybe Natural
$sel:iops:VolumeSpecification' :: VolumeSpecification -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
iops
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
throughput
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
volumeType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
sizeInGB

instance Prelude.NFData VolumeSpecification where
  rnf :: VolumeSpecification -> ()
rnf VolumeSpecification' {Int
Maybe Int
Maybe Natural
Text
sizeInGB :: Int
volumeType :: Text
throughput :: Maybe Natural
iops :: Maybe Int
$sel:sizeInGB:VolumeSpecification' :: VolumeSpecification -> Int
$sel:volumeType:VolumeSpecification' :: VolumeSpecification -> Text
$sel:throughput:VolumeSpecification' :: VolumeSpecification -> Maybe Natural
$sel:iops:VolumeSpecification' :: VolumeSpecification -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
iops
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
throughput
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
volumeType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
sizeInGB

instance Data.ToJSON VolumeSpecification where
  toJSON :: VolumeSpecification -> Value
toJSON VolumeSpecification' {Int
Maybe Int
Maybe Natural
Text
sizeInGB :: Int
volumeType :: Text
throughput :: Maybe Natural
iops :: Maybe Int
$sel:sizeInGB:VolumeSpecification' :: VolumeSpecification -> Int
$sel:volumeType:VolumeSpecification' :: VolumeSpecification -> Text
$sel:throughput:VolumeSpecification' :: VolumeSpecification -> Maybe Natural
$sel:iops:VolumeSpecification' :: VolumeSpecification -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Iops" 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 Int
iops,
            (Key
"Throughput" 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 Natural
throughput,
            forall a. a -> Maybe a
Prelude.Just (Key
"VolumeType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
volumeType),
            forall a. a -> Maybe a
Prelude.Just (Key
"SizeInGB" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
sizeInGB)
          ]
      )