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

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

-- | The Amazon EC2 Availability Zone configuration of the cluster (job
-- flow).
--
-- /See:/ 'newPlacementType' smart constructor.
data PlacementType = PlacementType'
  { -- | When multiple Availability Zones are specified, Amazon EMR evaluates
    -- them and launches instances in the optimal Availability Zone.
    -- @AvailabilityZones@ is used for instance fleets, while
    -- @AvailabilityZone@ (singular) is used for uniform instance groups.
    --
    -- The instance fleet configuration is available only in Amazon EMR
    -- versions 4.8.0 and later, excluding 5.0.x versions.
    PlacementType -> Maybe [Text]
availabilityZones :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon EC2 Availability Zone for the cluster. @AvailabilityZone@ is
    -- used for uniform instance groups, while @AvailabilityZones@ (plural) is
    -- used for instance fleets.
    PlacementType -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text
  }
  deriving (PlacementType -> PlacementType -> Bool
(PlacementType -> PlacementType -> Bool)
-> (PlacementType -> PlacementType -> Bool) -> Eq PlacementType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlacementType -> PlacementType -> Bool
$c/= :: PlacementType -> PlacementType -> Bool
== :: PlacementType -> PlacementType -> Bool
$c== :: PlacementType -> PlacementType -> Bool
Prelude.Eq, ReadPrec [PlacementType]
ReadPrec PlacementType
Int -> ReadS PlacementType
ReadS [PlacementType]
(Int -> ReadS PlacementType)
-> ReadS [PlacementType]
-> ReadPrec PlacementType
-> ReadPrec [PlacementType]
-> Read PlacementType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlacementType]
$creadListPrec :: ReadPrec [PlacementType]
readPrec :: ReadPrec PlacementType
$creadPrec :: ReadPrec PlacementType
readList :: ReadS [PlacementType]
$creadList :: ReadS [PlacementType]
readsPrec :: Int -> ReadS PlacementType
$creadsPrec :: Int -> ReadS PlacementType
Prelude.Read, Int -> PlacementType -> ShowS
[PlacementType] -> ShowS
PlacementType -> String
(Int -> PlacementType -> ShowS)
-> (PlacementType -> String)
-> ([PlacementType] -> ShowS)
-> Show PlacementType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlacementType] -> ShowS
$cshowList :: [PlacementType] -> ShowS
show :: PlacementType -> String
$cshow :: PlacementType -> String
showsPrec :: Int -> PlacementType -> ShowS
$cshowsPrec :: Int -> PlacementType -> ShowS
Prelude.Show, (forall x. PlacementType -> Rep PlacementType x)
-> (forall x. Rep PlacementType x -> PlacementType)
-> Generic PlacementType
forall x. Rep PlacementType x -> PlacementType
forall x. PlacementType -> Rep PlacementType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlacementType x -> PlacementType
$cfrom :: forall x. PlacementType -> Rep PlacementType x
Prelude.Generic)

-- |
-- Create a value of 'PlacementType' 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:
--
-- 'availabilityZones', 'placementType_availabilityZones' - When multiple Availability Zones are specified, Amazon EMR evaluates
-- them and launches instances in the optimal Availability Zone.
-- @AvailabilityZones@ is used for instance fleets, while
-- @AvailabilityZone@ (singular) is used for uniform instance groups.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions.
--
-- 'availabilityZone', 'placementType_availabilityZone' - The Amazon EC2 Availability Zone for the cluster. @AvailabilityZone@ is
-- used for uniform instance groups, while @AvailabilityZones@ (plural) is
-- used for instance fleets.
newPlacementType ::
  PlacementType
newPlacementType :: PlacementType
newPlacementType =
  PlacementType' :: Maybe [Text] -> Maybe Text -> PlacementType
PlacementType'
    { $sel:availabilityZones:PlacementType' :: Maybe [Text]
availabilityZones = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZone:PlacementType' :: Maybe Text
availabilityZone = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | When multiple Availability Zones are specified, Amazon EMR evaluates
-- them and launches instances in the optimal Availability Zone.
-- @AvailabilityZones@ is used for instance fleets, while
-- @AvailabilityZone@ (singular) is used for uniform instance groups.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions.
placementType_availabilityZones :: Lens.Lens' PlacementType (Prelude.Maybe [Prelude.Text])
placementType_availabilityZones :: (Maybe [Text] -> f (Maybe [Text]))
-> PlacementType -> f PlacementType
placementType_availabilityZones = (PlacementType -> Maybe [Text])
-> (PlacementType -> Maybe [Text] -> PlacementType)
-> Lens PlacementType PlacementType (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementType' {Maybe [Text]
availabilityZones :: Maybe [Text]
$sel:availabilityZones:PlacementType' :: PlacementType -> Maybe [Text]
availabilityZones} -> Maybe [Text]
availabilityZones) (\s :: PlacementType
s@PlacementType' {} Maybe [Text]
a -> PlacementType
s {$sel:availabilityZones:PlacementType' :: Maybe [Text]
availabilityZones = Maybe [Text]
a} :: PlacementType) ((Maybe [Text] -> f (Maybe [Text]))
 -> PlacementType -> f PlacementType)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PlacementType
-> f PlacementType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon EC2 Availability Zone for the cluster. @AvailabilityZone@ is
-- used for uniform instance groups, while @AvailabilityZones@ (plural) is
-- used for instance fleets.
placementType_availabilityZone :: Lens.Lens' PlacementType (Prelude.Maybe Prelude.Text)
placementType_availabilityZone :: (Maybe Text -> f (Maybe Text)) -> PlacementType -> f PlacementType
placementType_availabilityZone = (PlacementType -> Maybe Text)
-> (PlacementType -> Maybe Text -> PlacementType)
-> Lens PlacementType PlacementType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlacementType' {Maybe Text
availabilityZone :: Maybe Text
$sel:availabilityZone:PlacementType' :: PlacementType -> Maybe Text
availabilityZone} -> Maybe Text
availabilityZone) (\s :: PlacementType
s@PlacementType' {} Maybe Text
a -> PlacementType
s {$sel:availabilityZone:PlacementType' :: Maybe Text
availabilityZone = Maybe Text
a} :: PlacementType)

instance Prelude.Hashable PlacementType

instance Prelude.NFData PlacementType

instance Core.ToJSON PlacementType where
  toJSON :: PlacementType -> Value
toJSON PlacementType' {Maybe [Text]
Maybe Text
availabilityZone :: Maybe Text
availabilityZones :: Maybe [Text]
$sel:availabilityZone:PlacementType' :: PlacementType -> Maybe Text
$sel:availabilityZones:PlacementType' :: PlacementType -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AvailabilityZones" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
availabilityZones,
            (Text
"AvailabilityZone" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
availabilityZone
          ]
      )