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

-- | The Amazon EC2 Availability Zone configuration of the cluster (job
-- flow).
--
-- /See:/ 'newPlacementType' smart constructor.
data PlacementType = PlacementType'
  { -- | 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,
    -- | 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]
  }
  deriving (PlacementType -> PlacementType -> Bool
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]
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
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. 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:
--
-- '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.
--
-- '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.
newPlacementType ::
  PlacementType
newPlacementType :: PlacementType
newPlacementType =
  PlacementType'
    { $sel:availabilityZone:PlacementType' :: Maybe Text
availabilityZone = forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZones:PlacementType' :: Maybe [Text]
availabilityZones = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' PlacementType (Maybe Text)
placementType_availabilityZone = 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)

-- | 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 :: Lens' PlacementType (Maybe [Text])
placementType_availabilityZones = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable PlacementType where
  hashWithSalt :: Int -> PlacementType -> Int
hashWithSalt Int
_salt PlacementType' {Maybe [Text]
Maybe Text
availabilityZones :: Maybe [Text]
availabilityZone :: Maybe Text
$sel:availabilityZones:PlacementType' :: PlacementType -> Maybe [Text]
$sel:availabilityZone:PlacementType' :: PlacementType -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
availabilityZone
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
availabilityZones

instance Prelude.NFData PlacementType where
  rnf :: PlacementType -> ()
rnf PlacementType' {Maybe [Text]
Maybe Text
availabilityZones :: Maybe [Text]
availabilityZone :: Maybe Text
$sel:availabilityZones:PlacementType' :: PlacementType -> Maybe [Text]
$sel:availabilityZone:PlacementType' :: PlacementType -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
availabilityZone
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
availabilityZones

instance Data.ToJSON PlacementType where
  toJSON :: PlacementType -> Value
toJSON PlacementType' {Maybe [Text]
Maybe Text
availabilityZones :: Maybe [Text]
availabilityZone :: Maybe Text
$sel:availabilityZones:PlacementType' :: PlacementType -> Maybe [Text]
$sel:availabilityZone:PlacementType' :: PlacementType -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AvailabilityZone" 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 Text
availabilityZone,
            (Key
"AvailabilityZones" 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 [Text]
availabilityZones
          ]
      )