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

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

-- | Strategy item for the capacity provider strategy that the service uses.
--
-- /See:/ 'newAwsEcsServiceCapacityProviderStrategyDetails' smart constructor.
data AwsEcsServiceCapacityProviderStrategyDetails = AwsEcsServiceCapacityProviderStrategyDetails'
  { -- | The minimum number of tasks to run on the capacity provider. Only one
    -- strategy item can specify a value for @Base@.
    --
    -- The value must be between 0 and 100000.
    AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int
base :: Prelude.Maybe Prelude.Int,
    -- | The short name of the capacity provider.
    AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Text
capacityProvider :: Prelude.Maybe Prelude.Text,
    -- | The relative percentage of the total number of tasks that should use the
    -- capacity provider.
    --
    -- If no weight is specified, the default value is 0. At least one capacity
    -- provider must have a weight greater than 0.
    --
    -- The value can be between 0 and 1000.
    AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int
weight :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsEcsServiceCapacityProviderStrategyDetails
-> AwsEcsServiceCapacityProviderStrategyDetails -> Bool
(AwsEcsServiceCapacityProviderStrategyDetails
 -> AwsEcsServiceCapacityProviderStrategyDetails -> Bool)
-> (AwsEcsServiceCapacityProviderStrategyDetails
    -> AwsEcsServiceCapacityProviderStrategyDetails -> Bool)
-> Eq AwsEcsServiceCapacityProviderStrategyDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEcsServiceCapacityProviderStrategyDetails
-> AwsEcsServiceCapacityProviderStrategyDetails -> Bool
$c/= :: AwsEcsServiceCapacityProviderStrategyDetails
-> AwsEcsServiceCapacityProviderStrategyDetails -> Bool
== :: AwsEcsServiceCapacityProviderStrategyDetails
-> AwsEcsServiceCapacityProviderStrategyDetails -> Bool
$c== :: AwsEcsServiceCapacityProviderStrategyDetails
-> AwsEcsServiceCapacityProviderStrategyDetails -> Bool
Prelude.Eq, ReadPrec [AwsEcsServiceCapacityProviderStrategyDetails]
ReadPrec AwsEcsServiceCapacityProviderStrategyDetails
Int -> ReadS AwsEcsServiceCapacityProviderStrategyDetails
ReadS [AwsEcsServiceCapacityProviderStrategyDetails]
(Int -> ReadS AwsEcsServiceCapacityProviderStrategyDetails)
-> ReadS [AwsEcsServiceCapacityProviderStrategyDetails]
-> ReadPrec AwsEcsServiceCapacityProviderStrategyDetails
-> ReadPrec [AwsEcsServiceCapacityProviderStrategyDetails]
-> Read AwsEcsServiceCapacityProviderStrategyDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEcsServiceCapacityProviderStrategyDetails]
$creadListPrec :: ReadPrec [AwsEcsServiceCapacityProviderStrategyDetails]
readPrec :: ReadPrec AwsEcsServiceCapacityProviderStrategyDetails
$creadPrec :: ReadPrec AwsEcsServiceCapacityProviderStrategyDetails
readList :: ReadS [AwsEcsServiceCapacityProviderStrategyDetails]
$creadList :: ReadS [AwsEcsServiceCapacityProviderStrategyDetails]
readsPrec :: Int -> ReadS AwsEcsServiceCapacityProviderStrategyDetails
$creadsPrec :: Int -> ReadS AwsEcsServiceCapacityProviderStrategyDetails
Prelude.Read, Int -> AwsEcsServiceCapacityProviderStrategyDetails -> ShowS
[AwsEcsServiceCapacityProviderStrategyDetails] -> ShowS
AwsEcsServiceCapacityProviderStrategyDetails -> String
(Int -> AwsEcsServiceCapacityProviderStrategyDetails -> ShowS)
-> (AwsEcsServiceCapacityProviderStrategyDetails -> String)
-> ([AwsEcsServiceCapacityProviderStrategyDetails] -> ShowS)
-> Show AwsEcsServiceCapacityProviderStrategyDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEcsServiceCapacityProviderStrategyDetails] -> ShowS
$cshowList :: [AwsEcsServiceCapacityProviderStrategyDetails] -> ShowS
show :: AwsEcsServiceCapacityProviderStrategyDetails -> String
$cshow :: AwsEcsServiceCapacityProviderStrategyDetails -> String
showsPrec :: Int -> AwsEcsServiceCapacityProviderStrategyDetails -> ShowS
$cshowsPrec :: Int -> AwsEcsServiceCapacityProviderStrategyDetails -> ShowS
Prelude.Show, (forall x.
 AwsEcsServiceCapacityProviderStrategyDetails
 -> Rep AwsEcsServiceCapacityProviderStrategyDetails x)
-> (forall x.
    Rep AwsEcsServiceCapacityProviderStrategyDetails x
    -> AwsEcsServiceCapacityProviderStrategyDetails)
-> Generic AwsEcsServiceCapacityProviderStrategyDetails
forall x.
Rep AwsEcsServiceCapacityProviderStrategyDetails x
-> AwsEcsServiceCapacityProviderStrategyDetails
forall x.
AwsEcsServiceCapacityProviderStrategyDetails
-> Rep AwsEcsServiceCapacityProviderStrategyDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsEcsServiceCapacityProviderStrategyDetails x
-> AwsEcsServiceCapacityProviderStrategyDetails
$cfrom :: forall x.
AwsEcsServiceCapacityProviderStrategyDetails
-> Rep AwsEcsServiceCapacityProviderStrategyDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsEcsServiceCapacityProviderStrategyDetails' 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:
--
-- 'base', 'awsEcsServiceCapacityProviderStrategyDetails_base' - The minimum number of tasks to run on the capacity provider. Only one
-- strategy item can specify a value for @Base@.
--
-- The value must be between 0 and 100000.
--
-- 'capacityProvider', 'awsEcsServiceCapacityProviderStrategyDetails_capacityProvider' - The short name of the capacity provider.
--
-- 'weight', 'awsEcsServiceCapacityProviderStrategyDetails_weight' - The relative percentage of the total number of tasks that should use the
-- capacity provider.
--
-- If no weight is specified, the default value is 0. At least one capacity
-- provider must have a weight greater than 0.
--
-- The value can be between 0 and 1000.
newAwsEcsServiceCapacityProviderStrategyDetails ::
  AwsEcsServiceCapacityProviderStrategyDetails
newAwsEcsServiceCapacityProviderStrategyDetails :: AwsEcsServiceCapacityProviderStrategyDetails
newAwsEcsServiceCapacityProviderStrategyDetails =
  AwsEcsServiceCapacityProviderStrategyDetails' :: Maybe Int
-> Maybe Text
-> Maybe Int
-> AwsEcsServiceCapacityProviderStrategyDetails
AwsEcsServiceCapacityProviderStrategyDetails'
    { $sel:base:AwsEcsServiceCapacityProviderStrategyDetails' :: Maybe Int
base =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:capacityProvider:AwsEcsServiceCapacityProviderStrategyDetails' :: Maybe Text
capacityProvider =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:weight:AwsEcsServiceCapacityProviderStrategyDetails' :: Maybe Int
weight = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The minimum number of tasks to run on the capacity provider. Only one
-- strategy item can specify a value for @Base@.
--
-- The value must be between 0 and 100000.
awsEcsServiceCapacityProviderStrategyDetails_base :: Lens.Lens' AwsEcsServiceCapacityProviderStrategyDetails (Prelude.Maybe Prelude.Int)
awsEcsServiceCapacityProviderStrategyDetails_base :: (Maybe Int -> f (Maybe Int))
-> AwsEcsServiceCapacityProviderStrategyDetails
-> f AwsEcsServiceCapacityProviderStrategyDetails
awsEcsServiceCapacityProviderStrategyDetails_base = (AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int)
-> (AwsEcsServiceCapacityProviderStrategyDetails
    -> Maybe Int -> AwsEcsServiceCapacityProviderStrategyDetails)
-> Lens
     AwsEcsServiceCapacityProviderStrategyDetails
     AwsEcsServiceCapacityProviderStrategyDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceCapacityProviderStrategyDetails' {Maybe Int
base :: Maybe Int
$sel:base:AwsEcsServiceCapacityProviderStrategyDetails' :: AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int
base} -> Maybe Int
base) (\s :: AwsEcsServiceCapacityProviderStrategyDetails
s@AwsEcsServiceCapacityProviderStrategyDetails' {} Maybe Int
a -> AwsEcsServiceCapacityProviderStrategyDetails
s {$sel:base:AwsEcsServiceCapacityProviderStrategyDetails' :: Maybe Int
base = Maybe Int
a} :: AwsEcsServiceCapacityProviderStrategyDetails)

-- | The short name of the capacity provider.
awsEcsServiceCapacityProviderStrategyDetails_capacityProvider :: Lens.Lens' AwsEcsServiceCapacityProviderStrategyDetails (Prelude.Maybe Prelude.Text)
awsEcsServiceCapacityProviderStrategyDetails_capacityProvider :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServiceCapacityProviderStrategyDetails
-> f AwsEcsServiceCapacityProviderStrategyDetails
awsEcsServiceCapacityProviderStrategyDetails_capacityProvider = (AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Text)
-> (AwsEcsServiceCapacityProviderStrategyDetails
    -> Maybe Text -> AwsEcsServiceCapacityProviderStrategyDetails)
-> Lens
     AwsEcsServiceCapacityProviderStrategyDetails
     AwsEcsServiceCapacityProviderStrategyDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceCapacityProviderStrategyDetails' {Maybe Text
capacityProvider :: Maybe Text
$sel:capacityProvider:AwsEcsServiceCapacityProviderStrategyDetails' :: AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Text
capacityProvider} -> Maybe Text
capacityProvider) (\s :: AwsEcsServiceCapacityProviderStrategyDetails
s@AwsEcsServiceCapacityProviderStrategyDetails' {} Maybe Text
a -> AwsEcsServiceCapacityProviderStrategyDetails
s {$sel:capacityProvider:AwsEcsServiceCapacityProviderStrategyDetails' :: Maybe Text
capacityProvider = Maybe Text
a} :: AwsEcsServiceCapacityProviderStrategyDetails)

-- | The relative percentage of the total number of tasks that should use the
-- capacity provider.
--
-- If no weight is specified, the default value is 0. At least one capacity
-- provider must have a weight greater than 0.
--
-- The value can be between 0 and 1000.
awsEcsServiceCapacityProviderStrategyDetails_weight :: Lens.Lens' AwsEcsServiceCapacityProviderStrategyDetails (Prelude.Maybe Prelude.Int)
awsEcsServiceCapacityProviderStrategyDetails_weight :: (Maybe Int -> f (Maybe Int))
-> AwsEcsServiceCapacityProviderStrategyDetails
-> f AwsEcsServiceCapacityProviderStrategyDetails
awsEcsServiceCapacityProviderStrategyDetails_weight = (AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int)
-> (AwsEcsServiceCapacityProviderStrategyDetails
    -> Maybe Int -> AwsEcsServiceCapacityProviderStrategyDetails)
-> Lens
     AwsEcsServiceCapacityProviderStrategyDetails
     AwsEcsServiceCapacityProviderStrategyDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceCapacityProviderStrategyDetails' {Maybe Int
weight :: Maybe Int
$sel:weight:AwsEcsServiceCapacityProviderStrategyDetails' :: AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int
weight} -> Maybe Int
weight) (\s :: AwsEcsServiceCapacityProviderStrategyDetails
s@AwsEcsServiceCapacityProviderStrategyDetails' {} Maybe Int
a -> AwsEcsServiceCapacityProviderStrategyDetails
s {$sel:weight:AwsEcsServiceCapacityProviderStrategyDetails' :: Maybe Int
weight = Maybe Int
a} :: AwsEcsServiceCapacityProviderStrategyDetails)

instance
  Core.FromJSON
    AwsEcsServiceCapacityProviderStrategyDetails
  where
  parseJSON :: Value -> Parser AwsEcsServiceCapacityProviderStrategyDetails
parseJSON =
    String
-> (Object -> Parser AwsEcsServiceCapacityProviderStrategyDetails)
-> Value
-> Parser AwsEcsServiceCapacityProviderStrategyDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEcsServiceCapacityProviderStrategyDetails"
      ( \Object
x ->
          Maybe Int
-> Maybe Text
-> Maybe Int
-> AwsEcsServiceCapacityProviderStrategyDetails
AwsEcsServiceCapacityProviderStrategyDetails'
            (Maybe Int
 -> Maybe Text
 -> Maybe Int
 -> AwsEcsServiceCapacityProviderStrategyDetails)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe Int -> AwsEcsServiceCapacityProviderStrategyDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Base")
              Parser
  (Maybe Text
   -> Maybe Int -> AwsEcsServiceCapacityProviderStrategyDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int -> AwsEcsServiceCapacityProviderStrategyDetails)
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
"CapacityProvider")
              Parser (Maybe Int -> AwsEcsServiceCapacityProviderStrategyDetails)
-> Parser (Maybe Int)
-> Parser AwsEcsServiceCapacityProviderStrategyDetails
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Weight")
      )

instance
  Prelude.Hashable
    AwsEcsServiceCapacityProviderStrategyDetails

instance
  Prelude.NFData
    AwsEcsServiceCapacityProviderStrategyDetails

instance
  Core.ToJSON
    AwsEcsServiceCapacityProviderStrategyDetails
  where
  toJSON :: AwsEcsServiceCapacityProviderStrategyDetails -> Value
toJSON
    AwsEcsServiceCapacityProviderStrategyDetails' {Maybe Int
Maybe Text
weight :: Maybe Int
capacityProvider :: Maybe Text
base :: Maybe Int
$sel:weight:AwsEcsServiceCapacityProviderStrategyDetails' :: AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int
$sel:capacityProvider:AwsEcsServiceCapacityProviderStrategyDetails' :: AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Text
$sel:base:AwsEcsServiceCapacityProviderStrategyDetails' :: AwsEcsServiceCapacityProviderStrategyDetails -> Maybe Int
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"Base" 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
base,
              (Text
"CapacityProvider" 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
capacityProvider,
              (Text
"Weight" 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
weight
            ]
        )