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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.VolumeSpecification
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration of requested EBS block device associated with the instance
-- group with count of volumes that will be associated to every instance.
--
-- /See:/ 'newEbsBlockDeviceConfig' smart constructor.
data EbsBlockDeviceConfig = EbsBlockDeviceConfig'
  { -- | Number of EBS volumes with a specific volume configuration that will be
    -- associated with every instance in the instance group
    EbsBlockDeviceConfig -> Maybe Int
volumesPerInstance :: Prelude.Maybe Prelude.Int,
    -- | 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.
    EbsBlockDeviceConfig -> VolumeSpecification
volumeSpecification :: VolumeSpecification
  }
  deriving (EbsBlockDeviceConfig -> EbsBlockDeviceConfig -> Bool
(EbsBlockDeviceConfig -> EbsBlockDeviceConfig -> Bool)
-> (EbsBlockDeviceConfig -> EbsBlockDeviceConfig -> Bool)
-> Eq EbsBlockDeviceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EbsBlockDeviceConfig -> EbsBlockDeviceConfig -> Bool
$c/= :: EbsBlockDeviceConfig -> EbsBlockDeviceConfig -> Bool
== :: EbsBlockDeviceConfig -> EbsBlockDeviceConfig -> Bool
$c== :: EbsBlockDeviceConfig -> EbsBlockDeviceConfig -> Bool
Prelude.Eq, ReadPrec [EbsBlockDeviceConfig]
ReadPrec EbsBlockDeviceConfig
Int -> ReadS EbsBlockDeviceConfig
ReadS [EbsBlockDeviceConfig]
(Int -> ReadS EbsBlockDeviceConfig)
-> ReadS [EbsBlockDeviceConfig]
-> ReadPrec EbsBlockDeviceConfig
-> ReadPrec [EbsBlockDeviceConfig]
-> Read EbsBlockDeviceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EbsBlockDeviceConfig]
$creadListPrec :: ReadPrec [EbsBlockDeviceConfig]
readPrec :: ReadPrec EbsBlockDeviceConfig
$creadPrec :: ReadPrec EbsBlockDeviceConfig
readList :: ReadS [EbsBlockDeviceConfig]
$creadList :: ReadS [EbsBlockDeviceConfig]
readsPrec :: Int -> ReadS EbsBlockDeviceConfig
$creadsPrec :: Int -> ReadS EbsBlockDeviceConfig
Prelude.Read, Int -> EbsBlockDeviceConfig -> ShowS
[EbsBlockDeviceConfig] -> ShowS
EbsBlockDeviceConfig -> String
(Int -> EbsBlockDeviceConfig -> ShowS)
-> (EbsBlockDeviceConfig -> String)
-> ([EbsBlockDeviceConfig] -> ShowS)
-> Show EbsBlockDeviceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EbsBlockDeviceConfig] -> ShowS
$cshowList :: [EbsBlockDeviceConfig] -> ShowS
show :: EbsBlockDeviceConfig -> String
$cshow :: EbsBlockDeviceConfig -> String
showsPrec :: Int -> EbsBlockDeviceConfig -> ShowS
$cshowsPrec :: Int -> EbsBlockDeviceConfig -> ShowS
Prelude.Show, (forall x. EbsBlockDeviceConfig -> Rep EbsBlockDeviceConfig x)
-> (forall x. Rep EbsBlockDeviceConfig x -> EbsBlockDeviceConfig)
-> Generic EbsBlockDeviceConfig
forall x. Rep EbsBlockDeviceConfig x -> EbsBlockDeviceConfig
forall x. EbsBlockDeviceConfig -> Rep EbsBlockDeviceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EbsBlockDeviceConfig x -> EbsBlockDeviceConfig
$cfrom :: forall x. EbsBlockDeviceConfig -> Rep EbsBlockDeviceConfig x
Prelude.Generic)

-- |
-- Create a value of 'EbsBlockDeviceConfig' 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:
--
-- 'volumesPerInstance', 'ebsBlockDeviceConfig_volumesPerInstance' - Number of EBS volumes with a specific volume configuration that will be
-- associated with every instance in the instance group
--
-- 'volumeSpecification', 'ebsBlockDeviceConfig_volumeSpecification' - 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.
newEbsBlockDeviceConfig ::
  -- | 'volumeSpecification'
  VolumeSpecification ->
  EbsBlockDeviceConfig
newEbsBlockDeviceConfig :: VolumeSpecification -> EbsBlockDeviceConfig
newEbsBlockDeviceConfig VolumeSpecification
pVolumeSpecification_ =
  EbsBlockDeviceConfig' :: Maybe Int -> VolumeSpecification -> EbsBlockDeviceConfig
EbsBlockDeviceConfig'
    { $sel:volumesPerInstance:EbsBlockDeviceConfig' :: Maybe Int
volumesPerInstance =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:volumeSpecification:EbsBlockDeviceConfig' :: VolumeSpecification
volumeSpecification = VolumeSpecification
pVolumeSpecification_
    }

-- | Number of EBS volumes with a specific volume configuration that will be
-- associated with every instance in the instance group
ebsBlockDeviceConfig_volumesPerInstance :: Lens.Lens' EbsBlockDeviceConfig (Prelude.Maybe Prelude.Int)
ebsBlockDeviceConfig_volumesPerInstance :: (Maybe Int -> f (Maybe Int))
-> EbsBlockDeviceConfig -> f EbsBlockDeviceConfig
ebsBlockDeviceConfig_volumesPerInstance = (EbsBlockDeviceConfig -> Maybe Int)
-> (EbsBlockDeviceConfig -> Maybe Int -> EbsBlockDeviceConfig)
-> Lens
     EbsBlockDeviceConfig EbsBlockDeviceConfig (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EbsBlockDeviceConfig' {Maybe Int
volumesPerInstance :: Maybe Int
$sel:volumesPerInstance:EbsBlockDeviceConfig' :: EbsBlockDeviceConfig -> Maybe Int
volumesPerInstance} -> Maybe Int
volumesPerInstance) (\s :: EbsBlockDeviceConfig
s@EbsBlockDeviceConfig' {} Maybe Int
a -> EbsBlockDeviceConfig
s {$sel:volumesPerInstance:EbsBlockDeviceConfig' :: Maybe Int
volumesPerInstance = Maybe Int
a} :: EbsBlockDeviceConfig)

-- | 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.
ebsBlockDeviceConfig_volumeSpecification :: Lens.Lens' EbsBlockDeviceConfig VolumeSpecification
ebsBlockDeviceConfig_volumeSpecification :: (VolumeSpecification -> f VolumeSpecification)
-> EbsBlockDeviceConfig -> f EbsBlockDeviceConfig
ebsBlockDeviceConfig_volumeSpecification = (EbsBlockDeviceConfig -> VolumeSpecification)
-> (EbsBlockDeviceConfig
    -> VolumeSpecification -> EbsBlockDeviceConfig)
-> Lens
     EbsBlockDeviceConfig
     EbsBlockDeviceConfig
     VolumeSpecification
     VolumeSpecification
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EbsBlockDeviceConfig' {VolumeSpecification
volumeSpecification :: VolumeSpecification
$sel:volumeSpecification:EbsBlockDeviceConfig' :: EbsBlockDeviceConfig -> VolumeSpecification
volumeSpecification} -> VolumeSpecification
volumeSpecification) (\s :: EbsBlockDeviceConfig
s@EbsBlockDeviceConfig' {} VolumeSpecification
a -> EbsBlockDeviceConfig
s {$sel:volumeSpecification:EbsBlockDeviceConfig' :: VolumeSpecification
volumeSpecification = VolumeSpecification
a} :: EbsBlockDeviceConfig)

instance Prelude.Hashable EbsBlockDeviceConfig

instance Prelude.NFData EbsBlockDeviceConfig

instance Core.ToJSON EbsBlockDeviceConfig where
  toJSON :: EbsBlockDeviceConfig -> Value
toJSON EbsBlockDeviceConfig' {Maybe Int
VolumeSpecification
volumeSpecification :: VolumeSpecification
volumesPerInstance :: Maybe Int
$sel:volumeSpecification:EbsBlockDeviceConfig' :: EbsBlockDeviceConfig -> VolumeSpecification
$sel:volumesPerInstance:EbsBlockDeviceConfig' :: EbsBlockDeviceConfig -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VolumesPerInstance" 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
volumesPerInstance,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"VolumeSpecification" Text -> VolumeSpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= VolumeSpecification
volumeSpecification)
          ]
      )