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

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

-- | EBS volume specifications such as volume type, IOPS, and size (GiB) that
-- will be 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 volume type. Volume types supported are gp2, io1, 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
(VolumeSpecification -> VolumeSpecification -> Bool)
-> (VolumeSpecification -> VolumeSpecification -> Bool)
-> Eq VolumeSpecification
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]
(Int -> ReadS VolumeSpecification)
-> ReadS [VolumeSpecification]
-> ReadPrec VolumeSpecification
-> ReadPrec [VolumeSpecification]
-> Read 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
(Int -> VolumeSpecification -> ShowS)
-> (VolumeSpecification -> String)
-> ([VolumeSpecification] -> ShowS)
-> Show VolumeSpecification
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. VolumeSpecification -> Rep VolumeSpecification x)
-> (forall x. Rep VolumeSpecification x -> VolumeSpecification)
-> Generic VolumeSpecification
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.
--
-- 'volumeType', 'volumeSpecification_volumeType' - The volume type. Volume types supported are gp2, io1, 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' :: Maybe Int -> Text -> Int -> VolumeSpecification
VolumeSpecification'
    { $sel:iops:VolumeSpecification' :: Maybe Int
iops = Maybe Int
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 :: (Maybe Int -> f (Maybe Int))
-> VolumeSpecification -> f VolumeSpecification
volumeSpecification_iops = (VolumeSpecification -> Maybe Int)
-> (VolumeSpecification -> Maybe Int -> VolumeSpecification)
-> Lens
     VolumeSpecification VolumeSpecification (Maybe Int) (Maybe Int)
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 volume type. Volume types supported are gp2, io1, standard.
volumeSpecification_volumeType :: Lens.Lens' VolumeSpecification Prelude.Text
volumeSpecification_volumeType :: (Text -> f Text) -> VolumeSpecification -> f VolumeSpecification
volumeSpecification_volumeType = (VolumeSpecification -> Text)
-> (VolumeSpecification -> Text -> VolumeSpecification)
-> Lens VolumeSpecification VolumeSpecification Text Text
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 :: (Int -> f Int) -> VolumeSpecification -> f VolumeSpecification
volumeSpecification_sizeInGB = (VolumeSpecification -> Int)
-> (VolumeSpecification -> Int -> VolumeSpecification)
-> Lens VolumeSpecification VolumeSpecification Int Int
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 Core.FromJSON VolumeSpecification where
  parseJSON :: Value -> Parser VolumeSpecification
parseJSON =
    String
-> (Object -> Parser VolumeSpecification)
-> Value
-> Parser VolumeSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VolumeSpecification"
      ( \Object
x ->
          Maybe Int -> Text -> Int -> VolumeSpecification
VolumeSpecification'
            (Maybe Int -> Text -> Int -> VolumeSpecification)
-> Parser (Maybe Int)
-> Parser (Text -> Int -> VolumeSpecification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Iops")
            Parser (Text -> Int -> VolumeSpecification)
-> Parser Text -> Parser (Int -> VolumeSpecification)
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
"VolumeType")
            Parser (Int -> VolumeSpecification)
-> Parser Int -> Parser VolumeSpecification
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
"SizeInGB")
      )

instance Prelude.Hashable VolumeSpecification

instance Prelude.NFData VolumeSpecification

instance Core.ToJSON VolumeSpecification where
  toJSON :: VolumeSpecification -> Value
toJSON VolumeSpecification' {Int
Maybe Int
Text
sizeInGB :: Int
volumeType :: Text
iops :: Maybe Int
$sel:sizeInGB:VolumeSpecification' :: VolumeSpecification -> Int
$sel:volumeType:VolumeSpecification' :: VolumeSpecification -> Text
$sel:iops:VolumeSpecification' :: VolumeSpecification -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Iops" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
iops,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"VolumeType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
volumeType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SizeInGB" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
sizeInGB)
          ]
      )