{-# 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.SecurityHub.Types.AwsEcsServicePlacementStrategiesDetails
-- 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.SecurityHub.Types.AwsEcsServicePlacementStrategiesDetails where

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

-- | A placement strategy that determines how to place the tasks for the
-- service.
--
-- /See:/ 'newAwsEcsServicePlacementStrategiesDetails' smart constructor.
data AwsEcsServicePlacementStrategiesDetails = AwsEcsServicePlacementStrategiesDetails'
  { -- | The field to apply the placement strategy against.
    --
    -- For the @spread@ placement strategy, valid values are @instanceId@ (or
    -- @host@, which has the same effect), or any platform or custom attribute
    -- that is applied to a container instance, such as
    -- @attribute:ecs.availability-zone@.
    --
    -- For the @binpack@ placement strategy, valid values are @cpu@ and
    -- @memory@.
    --
    -- For the @random@ placement strategy, this attribute is not used.
    AwsEcsServicePlacementStrategiesDetails -> Maybe Text
field :: Prelude.Maybe Prelude.Text,
    -- | The type of placement strategy.
    --
    -- The @random@ placement strategy randomly places tasks on available
    -- candidates.
    --
    -- The @spread@ placement strategy spreads placement across available
    -- candidates evenly based on the value of @Field@.
    --
    -- The @binpack@ strategy places tasks on available candidates that have
    -- the least available amount of the resource that is specified in @Field@.
    --
    -- Valid values: @random@ | @spread@ | @binpack@
    AwsEcsServicePlacementStrategiesDetails -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsEcsServicePlacementStrategiesDetails
-> AwsEcsServicePlacementStrategiesDetails -> Bool
(AwsEcsServicePlacementStrategiesDetails
 -> AwsEcsServicePlacementStrategiesDetails -> Bool)
-> (AwsEcsServicePlacementStrategiesDetails
    -> AwsEcsServicePlacementStrategiesDetails -> Bool)
-> Eq AwsEcsServicePlacementStrategiesDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEcsServicePlacementStrategiesDetails
-> AwsEcsServicePlacementStrategiesDetails -> Bool
$c/= :: AwsEcsServicePlacementStrategiesDetails
-> AwsEcsServicePlacementStrategiesDetails -> Bool
== :: AwsEcsServicePlacementStrategiesDetails
-> AwsEcsServicePlacementStrategiesDetails -> Bool
$c== :: AwsEcsServicePlacementStrategiesDetails
-> AwsEcsServicePlacementStrategiesDetails -> Bool
Prelude.Eq, ReadPrec [AwsEcsServicePlacementStrategiesDetails]
ReadPrec AwsEcsServicePlacementStrategiesDetails
Int -> ReadS AwsEcsServicePlacementStrategiesDetails
ReadS [AwsEcsServicePlacementStrategiesDetails]
(Int -> ReadS AwsEcsServicePlacementStrategiesDetails)
-> ReadS [AwsEcsServicePlacementStrategiesDetails]
-> ReadPrec AwsEcsServicePlacementStrategiesDetails
-> ReadPrec [AwsEcsServicePlacementStrategiesDetails]
-> Read AwsEcsServicePlacementStrategiesDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEcsServicePlacementStrategiesDetails]
$creadListPrec :: ReadPrec [AwsEcsServicePlacementStrategiesDetails]
readPrec :: ReadPrec AwsEcsServicePlacementStrategiesDetails
$creadPrec :: ReadPrec AwsEcsServicePlacementStrategiesDetails
readList :: ReadS [AwsEcsServicePlacementStrategiesDetails]
$creadList :: ReadS [AwsEcsServicePlacementStrategiesDetails]
readsPrec :: Int -> ReadS AwsEcsServicePlacementStrategiesDetails
$creadsPrec :: Int -> ReadS AwsEcsServicePlacementStrategiesDetails
Prelude.Read, Int -> AwsEcsServicePlacementStrategiesDetails -> ShowS
[AwsEcsServicePlacementStrategiesDetails] -> ShowS
AwsEcsServicePlacementStrategiesDetails -> String
(Int -> AwsEcsServicePlacementStrategiesDetails -> ShowS)
-> (AwsEcsServicePlacementStrategiesDetails -> String)
-> ([AwsEcsServicePlacementStrategiesDetails] -> ShowS)
-> Show AwsEcsServicePlacementStrategiesDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEcsServicePlacementStrategiesDetails] -> ShowS
$cshowList :: [AwsEcsServicePlacementStrategiesDetails] -> ShowS
show :: AwsEcsServicePlacementStrategiesDetails -> String
$cshow :: AwsEcsServicePlacementStrategiesDetails -> String
showsPrec :: Int -> AwsEcsServicePlacementStrategiesDetails -> ShowS
$cshowsPrec :: Int -> AwsEcsServicePlacementStrategiesDetails -> ShowS
Prelude.Show, (forall x.
 AwsEcsServicePlacementStrategiesDetails
 -> Rep AwsEcsServicePlacementStrategiesDetails x)
-> (forall x.
    Rep AwsEcsServicePlacementStrategiesDetails x
    -> AwsEcsServicePlacementStrategiesDetails)
-> Generic AwsEcsServicePlacementStrategiesDetails
forall x.
Rep AwsEcsServicePlacementStrategiesDetails x
-> AwsEcsServicePlacementStrategiesDetails
forall x.
AwsEcsServicePlacementStrategiesDetails
-> Rep AwsEcsServicePlacementStrategiesDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsEcsServicePlacementStrategiesDetails x
-> AwsEcsServicePlacementStrategiesDetails
$cfrom :: forall x.
AwsEcsServicePlacementStrategiesDetails
-> Rep AwsEcsServicePlacementStrategiesDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsEcsServicePlacementStrategiesDetails' 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:
--
-- 'field', 'awsEcsServicePlacementStrategiesDetails_field' - The field to apply the placement strategy against.
--
-- For the @spread@ placement strategy, valid values are @instanceId@ (or
-- @host@, which has the same effect), or any platform or custom attribute
-- that is applied to a container instance, such as
-- @attribute:ecs.availability-zone@.
--
-- For the @binpack@ placement strategy, valid values are @cpu@ and
-- @memory@.
--
-- For the @random@ placement strategy, this attribute is not used.
--
-- 'type'', 'awsEcsServicePlacementStrategiesDetails_type' - The type of placement strategy.
--
-- The @random@ placement strategy randomly places tasks on available
-- candidates.
--
-- The @spread@ placement strategy spreads placement across available
-- candidates evenly based on the value of @Field@.
--
-- The @binpack@ strategy places tasks on available candidates that have
-- the least available amount of the resource that is specified in @Field@.
--
-- Valid values: @random@ | @spread@ | @binpack@
newAwsEcsServicePlacementStrategiesDetails ::
  AwsEcsServicePlacementStrategiesDetails
newAwsEcsServicePlacementStrategiesDetails :: AwsEcsServicePlacementStrategiesDetails
newAwsEcsServicePlacementStrategiesDetails =
  AwsEcsServicePlacementStrategiesDetails' :: Maybe Text -> Maybe Text -> AwsEcsServicePlacementStrategiesDetails
AwsEcsServicePlacementStrategiesDetails'
    { $sel:field:AwsEcsServicePlacementStrategiesDetails' :: Maybe Text
field =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':AwsEcsServicePlacementStrategiesDetails' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The field to apply the placement strategy against.
--
-- For the @spread@ placement strategy, valid values are @instanceId@ (or
-- @host@, which has the same effect), or any platform or custom attribute
-- that is applied to a container instance, such as
-- @attribute:ecs.availability-zone@.
--
-- For the @binpack@ placement strategy, valid values are @cpu@ and
-- @memory@.
--
-- For the @random@ placement strategy, this attribute is not used.
awsEcsServicePlacementStrategiesDetails_field :: Lens.Lens' AwsEcsServicePlacementStrategiesDetails (Prelude.Maybe Prelude.Text)
awsEcsServicePlacementStrategiesDetails_field :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServicePlacementStrategiesDetails
-> f AwsEcsServicePlacementStrategiesDetails
awsEcsServicePlacementStrategiesDetails_field = (AwsEcsServicePlacementStrategiesDetails -> Maybe Text)
-> (AwsEcsServicePlacementStrategiesDetails
    -> Maybe Text -> AwsEcsServicePlacementStrategiesDetails)
-> Lens
     AwsEcsServicePlacementStrategiesDetails
     AwsEcsServicePlacementStrategiesDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServicePlacementStrategiesDetails' {Maybe Text
field :: Maybe Text
$sel:field:AwsEcsServicePlacementStrategiesDetails' :: AwsEcsServicePlacementStrategiesDetails -> Maybe Text
field} -> Maybe Text
field) (\s :: AwsEcsServicePlacementStrategiesDetails
s@AwsEcsServicePlacementStrategiesDetails' {} Maybe Text
a -> AwsEcsServicePlacementStrategiesDetails
s {$sel:field:AwsEcsServicePlacementStrategiesDetails' :: Maybe Text
field = Maybe Text
a} :: AwsEcsServicePlacementStrategiesDetails)

-- | The type of placement strategy.
--
-- The @random@ placement strategy randomly places tasks on available
-- candidates.
--
-- The @spread@ placement strategy spreads placement across available
-- candidates evenly based on the value of @Field@.
--
-- The @binpack@ strategy places tasks on available candidates that have
-- the least available amount of the resource that is specified in @Field@.
--
-- Valid values: @random@ | @spread@ | @binpack@
awsEcsServicePlacementStrategiesDetails_type :: Lens.Lens' AwsEcsServicePlacementStrategiesDetails (Prelude.Maybe Prelude.Text)
awsEcsServicePlacementStrategiesDetails_type :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServicePlacementStrategiesDetails
-> f AwsEcsServicePlacementStrategiesDetails
awsEcsServicePlacementStrategiesDetails_type = (AwsEcsServicePlacementStrategiesDetails -> Maybe Text)
-> (AwsEcsServicePlacementStrategiesDetails
    -> Maybe Text -> AwsEcsServicePlacementStrategiesDetails)
-> Lens
     AwsEcsServicePlacementStrategiesDetails
     AwsEcsServicePlacementStrategiesDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServicePlacementStrategiesDetails' {Maybe Text
type' :: Maybe Text
$sel:type':AwsEcsServicePlacementStrategiesDetails' :: AwsEcsServicePlacementStrategiesDetails -> Maybe Text
type'} -> Maybe Text
type') (\s :: AwsEcsServicePlacementStrategiesDetails
s@AwsEcsServicePlacementStrategiesDetails' {} Maybe Text
a -> AwsEcsServicePlacementStrategiesDetails
s {$sel:type':AwsEcsServicePlacementStrategiesDetails' :: Maybe Text
type' = Maybe Text
a} :: AwsEcsServicePlacementStrategiesDetails)

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

instance
  Prelude.Hashable
    AwsEcsServicePlacementStrategiesDetails

instance
  Prelude.NFData
    AwsEcsServicePlacementStrategiesDetails

instance
  Core.ToJSON
    AwsEcsServicePlacementStrategiesDetails
  where
  toJSON :: AwsEcsServicePlacementStrategiesDetails -> Value
toJSON AwsEcsServicePlacementStrategiesDetails' {Maybe Text
type' :: Maybe Text
field :: Maybe Text
$sel:type':AwsEcsServicePlacementStrategiesDetails' :: AwsEcsServicePlacementStrategiesDetails -> Maybe Text
$sel:field:AwsEcsServicePlacementStrategiesDetails' :: AwsEcsServicePlacementStrategiesDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Field" 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
field,
            (Text
"Type" 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
type'
          ]
      )