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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.OnDemandProvisioningSpecification
import Amazonka.EMR.Types.SpotProvisioningSpecification
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The launch specification for Spot Instances in the fleet, which
-- determines the defined duration, provisioning timeout behavior, and
-- allocation strategy.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions. On-Demand and Spot
-- Instance allocation strategies are available in Amazon EMR version
-- 5.12.1 and later.
--
-- /See:/ 'newInstanceFleetProvisioningSpecifications' smart constructor.
data InstanceFleetProvisioningSpecifications = InstanceFleetProvisioningSpecifications'
  { -- | The launch specification for Spot Instances in the fleet, which
    -- determines the defined duration, provisioning timeout behavior, and
    -- allocation strategy.
    InstanceFleetProvisioningSpecifications
-> Maybe SpotProvisioningSpecification
spotSpecification :: Prelude.Maybe SpotProvisioningSpecification,
    -- | The launch specification for On-Demand Instances in the instance fleet,
    -- which determines the allocation strategy.
    --
    -- The instance fleet configuration is available only in Amazon EMR
    -- versions 4.8.0 and later, excluding 5.0.x versions. On-Demand Instances
    -- allocation strategy is available in Amazon EMR version 5.12.1 and later.
    InstanceFleetProvisioningSpecifications
-> Maybe OnDemandProvisioningSpecification
onDemandSpecification :: Prelude.Maybe OnDemandProvisioningSpecification
  }
  deriving (InstanceFleetProvisioningSpecifications
-> InstanceFleetProvisioningSpecifications -> Bool
(InstanceFleetProvisioningSpecifications
 -> InstanceFleetProvisioningSpecifications -> Bool)
-> (InstanceFleetProvisioningSpecifications
    -> InstanceFleetProvisioningSpecifications -> Bool)
-> Eq InstanceFleetProvisioningSpecifications
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceFleetProvisioningSpecifications
-> InstanceFleetProvisioningSpecifications -> Bool
$c/= :: InstanceFleetProvisioningSpecifications
-> InstanceFleetProvisioningSpecifications -> Bool
== :: InstanceFleetProvisioningSpecifications
-> InstanceFleetProvisioningSpecifications -> Bool
$c== :: InstanceFleetProvisioningSpecifications
-> InstanceFleetProvisioningSpecifications -> Bool
Prelude.Eq, ReadPrec [InstanceFleetProvisioningSpecifications]
ReadPrec InstanceFleetProvisioningSpecifications
Int -> ReadS InstanceFleetProvisioningSpecifications
ReadS [InstanceFleetProvisioningSpecifications]
(Int -> ReadS InstanceFleetProvisioningSpecifications)
-> ReadS [InstanceFleetProvisioningSpecifications]
-> ReadPrec InstanceFleetProvisioningSpecifications
-> ReadPrec [InstanceFleetProvisioningSpecifications]
-> Read InstanceFleetProvisioningSpecifications
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceFleetProvisioningSpecifications]
$creadListPrec :: ReadPrec [InstanceFleetProvisioningSpecifications]
readPrec :: ReadPrec InstanceFleetProvisioningSpecifications
$creadPrec :: ReadPrec InstanceFleetProvisioningSpecifications
readList :: ReadS [InstanceFleetProvisioningSpecifications]
$creadList :: ReadS [InstanceFleetProvisioningSpecifications]
readsPrec :: Int -> ReadS InstanceFleetProvisioningSpecifications
$creadsPrec :: Int -> ReadS InstanceFleetProvisioningSpecifications
Prelude.Read, Int -> InstanceFleetProvisioningSpecifications -> ShowS
[InstanceFleetProvisioningSpecifications] -> ShowS
InstanceFleetProvisioningSpecifications -> String
(Int -> InstanceFleetProvisioningSpecifications -> ShowS)
-> (InstanceFleetProvisioningSpecifications -> String)
-> ([InstanceFleetProvisioningSpecifications] -> ShowS)
-> Show InstanceFleetProvisioningSpecifications
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceFleetProvisioningSpecifications] -> ShowS
$cshowList :: [InstanceFleetProvisioningSpecifications] -> ShowS
show :: InstanceFleetProvisioningSpecifications -> String
$cshow :: InstanceFleetProvisioningSpecifications -> String
showsPrec :: Int -> InstanceFleetProvisioningSpecifications -> ShowS
$cshowsPrec :: Int -> InstanceFleetProvisioningSpecifications -> ShowS
Prelude.Show, (forall x.
 InstanceFleetProvisioningSpecifications
 -> Rep InstanceFleetProvisioningSpecifications x)
-> (forall x.
    Rep InstanceFleetProvisioningSpecifications x
    -> InstanceFleetProvisioningSpecifications)
-> Generic InstanceFleetProvisioningSpecifications
forall x.
Rep InstanceFleetProvisioningSpecifications x
-> InstanceFleetProvisioningSpecifications
forall x.
InstanceFleetProvisioningSpecifications
-> Rep InstanceFleetProvisioningSpecifications x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstanceFleetProvisioningSpecifications x
-> InstanceFleetProvisioningSpecifications
$cfrom :: forall x.
InstanceFleetProvisioningSpecifications
-> Rep InstanceFleetProvisioningSpecifications x
Prelude.Generic)

-- |
-- Create a value of 'InstanceFleetProvisioningSpecifications' 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:
--
-- 'spotSpecification', 'instanceFleetProvisioningSpecifications_spotSpecification' - The launch specification for Spot Instances in the fleet, which
-- determines the defined duration, provisioning timeout behavior, and
-- allocation strategy.
--
-- 'onDemandSpecification', 'instanceFleetProvisioningSpecifications_onDemandSpecification' - The launch specification for On-Demand Instances in the instance fleet,
-- which determines the allocation strategy.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions. On-Demand Instances
-- allocation strategy is available in Amazon EMR version 5.12.1 and later.
newInstanceFleetProvisioningSpecifications ::
  InstanceFleetProvisioningSpecifications
newInstanceFleetProvisioningSpecifications :: InstanceFleetProvisioningSpecifications
newInstanceFleetProvisioningSpecifications =
  InstanceFleetProvisioningSpecifications' :: Maybe SpotProvisioningSpecification
-> Maybe OnDemandProvisioningSpecification
-> InstanceFleetProvisioningSpecifications
InstanceFleetProvisioningSpecifications'
    { $sel:spotSpecification:InstanceFleetProvisioningSpecifications' :: Maybe SpotProvisioningSpecification
spotSpecification =
        Maybe SpotProvisioningSpecification
forall a. Maybe a
Prelude.Nothing,
      $sel:onDemandSpecification:InstanceFleetProvisioningSpecifications' :: Maybe OnDemandProvisioningSpecification
onDemandSpecification =
        Maybe OnDemandProvisioningSpecification
forall a. Maybe a
Prelude.Nothing
    }

-- | The launch specification for Spot Instances in the fleet, which
-- determines the defined duration, provisioning timeout behavior, and
-- allocation strategy.
instanceFleetProvisioningSpecifications_spotSpecification :: Lens.Lens' InstanceFleetProvisioningSpecifications (Prelude.Maybe SpotProvisioningSpecification)
instanceFleetProvisioningSpecifications_spotSpecification :: (Maybe SpotProvisioningSpecification
 -> f (Maybe SpotProvisioningSpecification))
-> InstanceFleetProvisioningSpecifications
-> f InstanceFleetProvisioningSpecifications
instanceFleetProvisioningSpecifications_spotSpecification = (InstanceFleetProvisioningSpecifications
 -> Maybe SpotProvisioningSpecification)
-> (InstanceFleetProvisioningSpecifications
    -> Maybe SpotProvisioningSpecification
    -> InstanceFleetProvisioningSpecifications)
-> Lens
     InstanceFleetProvisioningSpecifications
     InstanceFleetProvisioningSpecifications
     (Maybe SpotProvisioningSpecification)
     (Maybe SpotProvisioningSpecification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceFleetProvisioningSpecifications' {Maybe SpotProvisioningSpecification
spotSpecification :: Maybe SpotProvisioningSpecification
$sel:spotSpecification:InstanceFleetProvisioningSpecifications' :: InstanceFleetProvisioningSpecifications
-> Maybe SpotProvisioningSpecification
spotSpecification} -> Maybe SpotProvisioningSpecification
spotSpecification) (\s :: InstanceFleetProvisioningSpecifications
s@InstanceFleetProvisioningSpecifications' {} Maybe SpotProvisioningSpecification
a -> InstanceFleetProvisioningSpecifications
s {$sel:spotSpecification:InstanceFleetProvisioningSpecifications' :: Maybe SpotProvisioningSpecification
spotSpecification = Maybe SpotProvisioningSpecification
a} :: InstanceFleetProvisioningSpecifications)

-- | The launch specification for On-Demand Instances in the instance fleet,
-- which determines the allocation strategy.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions. On-Demand Instances
-- allocation strategy is available in Amazon EMR version 5.12.1 and later.
instanceFleetProvisioningSpecifications_onDemandSpecification :: Lens.Lens' InstanceFleetProvisioningSpecifications (Prelude.Maybe OnDemandProvisioningSpecification)
instanceFleetProvisioningSpecifications_onDemandSpecification :: (Maybe OnDemandProvisioningSpecification
 -> f (Maybe OnDemandProvisioningSpecification))
-> InstanceFleetProvisioningSpecifications
-> f InstanceFleetProvisioningSpecifications
instanceFleetProvisioningSpecifications_onDemandSpecification = (InstanceFleetProvisioningSpecifications
 -> Maybe OnDemandProvisioningSpecification)
-> (InstanceFleetProvisioningSpecifications
    -> Maybe OnDemandProvisioningSpecification
    -> InstanceFleetProvisioningSpecifications)
-> Lens
     InstanceFleetProvisioningSpecifications
     InstanceFleetProvisioningSpecifications
     (Maybe OnDemandProvisioningSpecification)
     (Maybe OnDemandProvisioningSpecification)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceFleetProvisioningSpecifications' {Maybe OnDemandProvisioningSpecification
onDemandSpecification :: Maybe OnDemandProvisioningSpecification
$sel:onDemandSpecification:InstanceFleetProvisioningSpecifications' :: InstanceFleetProvisioningSpecifications
-> Maybe OnDemandProvisioningSpecification
onDemandSpecification} -> Maybe OnDemandProvisioningSpecification
onDemandSpecification) (\s :: InstanceFleetProvisioningSpecifications
s@InstanceFleetProvisioningSpecifications' {} Maybe OnDemandProvisioningSpecification
a -> InstanceFleetProvisioningSpecifications
s {$sel:onDemandSpecification:InstanceFleetProvisioningSpecifications' :: Maybe OnDemandProvisioningSpecification
onDemandSpecification = Maybe OnDemandProvisioningSpecification
a} :: InstanceFleetProvisioningSpecifications)

instance
  Core.FromJSON
    InstanceFleetProvisioningSpecifications
  where
  parseJSON :: Value -> Parser InstanceFleetProvisioningSpecifications
parseJSON =
    String
-> (Object -> Parser InstanceFleetProvisioningSpecifications)
-> Value
-> Parser InstanceFleetProvisioningSpecifications
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceFleetProvisioningSpecifications"
      ( \Object
x ->
          Maybe SpotProvisioningSpecification
-> Maybe OnDemandProvisioningSpecification
-> InstanceFleetProvisioningSpecifications
InstanceFleetProvisioningSpecifications'
            (Maybe SpotProvisioningSpecification
 -> Maybe OnDemandProvisioningSpecification
 -> InstanceFleetProvisioningSpecifications)
-> Parser (Maybe SpotProvisioningSpecification)
-> Parser
     (Maybe OnDemandProvisioningSpecification
      -> InstanceFleetProvisioningSpecifications)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SpotProvisioningSpecification)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SpotSpecification")
            Parser
  (Maybe OnDemandProvisioningSpecification
   -> InstanceFleetProvisioningSpecifications)
-> Parser (Maybe OnDemandProvisioningSpecification)
-> Parser InstanceFleetProvisioningSpecifications
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OnDemandProvisioningSpecification)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OnDemandSpecification")
      )

instance
  Prelude.Hashable
    InstanceFleetProvisioningSpecifications

instance
  Prelude.NFData
    InstanceFleetProvisioningSpecifications

instance
  Core.ToJSON
    InstanceFleetProvisioningSpecifications
  where
  toJSON :: InstanceFleetProvisioningSpecifications -> Value
toJSON InstanceFleetProvisioningSpecifications' {Maybe OnDemandProvisioningSpecification
Maybe SpotProvisioningSpecification
onDemandSpecification :: Maybe OnDemandProvisioningSpecification
spotSpecification :: Maybe SpotProvisioningSpecification
$sel:onDemandSpecification:InstanceFleetProvisioningSpecifications' :: InstanceFleetProvisioningSpecifications
-> Maybe OnDemandProvisioningSpecification
$sel:spotSpecification:InstanceFleetProvisioningSpecifications' :: InstanceFleetProvisioningSpecifications
-> Maybe SpotProvisioningSpecification
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SpotSpecification" Text -> SpotProvisioningSpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SpotProvisioningSpecification -> Pair)
-> Maybe SpotProvisioningSpecification -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SpotProvisioningSpecification
spotSpecification,
            (Text
"OnDemandSpecification" Text -> OnDemandProvisioningSpecification -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OnDemandProvisioningSpecification -> Pair)
-> Maybe OnDemandProvisioningSpecification -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OnDemandProvisioningSpecification
onDemandSpecification
          ]
      )