{-# 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.SageMaker.Types.DesiredWeightAndCapacity
-- 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.SageMaker.Types.DesiredWeightAndCapacity where

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

-- | Specifies weight and capacity values for a production variant.
--
-- /See:/ 'newDesiredWeightAndCapacity' smart constructor.
data DesiredWeightAndCapacity = DesiredWeightAndCapacity'
  { -- | The variant\'s capacity.
    DesiredWeightAndCapacity -> Maybe Natural
desiredInstanceCount :: Prelude.Maybe Prelude.Natural,
    -- | The variant\'s weight.
    DesiredWeightAndCapacity -> Maybe Double
desiredWeight :: Prelude.Maybe Prelude.Double,
    -- | The name of the variant to update.
    DesiredWeightAndCapacity -> Text
variantName :: Prelude.Text
  }
  deriving (DesiredWeightAndCapacity -> DesiredWeightAndCapacity -> Bool
(DesiredWeightAndCapacity -> DesiredWeightAndCapacity -> Bool)
-> (DesiredWeightAndCapacity -> DesiredWeightAndCapacity -> Bool)
-> Eq DesiredWeightAndCapacity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DesiredWeightAndCapacity -> DesiredWeightAndCapacity -> Bool
$c/= :: DesiredWeightAndCapacity -> DesiredWeightAndCapacity -> Bool
== :: DesiredWeightAndCapacity -> DesiredWeightAndCapacity -> Bool
$c== :: DesiredWeightAndCapacity -> DesiredWeightAndCapacity -> Bool
Prelude.Eq, ReadPrec [DesiredWeightAndCapacity]
ReadPrec DesiredWeightAndCapacity
Int -> ReadS DesiredWeightAndCapacity
ReadS [DesiredWeightAndCapacity]
(Int -> ReadS DesiredWeightAndCapacity)
-> ReadS [DesiredWeightAndCapacity]
-> ReadPrec DesiredWeightAndCapacity
-> ReadPrec [DesiredWeightAndCapacity]
-> Read DesiredWeightAndCapacity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DesiredWeightAndCapacity]
$creadListPrec :: ReadPrec [DesiredWeightAndCapacity]
readPrec :: ReadPrec DesiredWeightAndCapacity
$creadPrec :: ReadPrec DesiredWeightAndCapacity
readList :: ReadS [DesiredWeightAndCapacity]
$creadList :: ReadS [DesiredWeightAndCapacity]
readsPrec :: Int -> ReadS DesiredWeightAndCapacity
$creadsPrec :: Int -> ReadS DesiredWeightAndCapacity
Prelude.Read, Int -> DesiredWeightAndCapacity -> ShowS
[DesiredWeightAndCapacity] -> ShowS
DesiredWeightAndCapacity -> String
(Int -> DesiredWeightAndCapacity -> ShowS)
-> (DesiredWeightAndCapacity -> String)
-> ([DesiredWeightAndCapacity] -> ShowS)
-> Show DesiredWeightAndCapacity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DesiredWeightAndCapacity] -> ShowS
$cshowList :: [DesiredWeightAndCapacity] -> ShowS
show :: DesiredWeightAndCapacity -> String
$cshow :: DesiredWeightAndCapacity -> String
showsPrec :: Int -> DesiredWeightAndCapacity -> ShowS
$cshowsPrec :: Int -> DesiredWeightAndCapacity -> ShowS
Prelude.Show, (forall x.
 DesiredWeightAndCapacity -> Rep DesiredWeightAndCapacity x)
-> (forall x.
    Rep DesiredWeightAndCapacity x -> DesiredWeightAndCapacity)
-> Generic DesiredWeightAndCapacity
forall x.
Rep DesiredWeightAndCapacity x -> DesiredWeightAndCapacity
forall x.
DesiredWeightAndCapacity -> Rep DesiredWeightAndCapacity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DesiredWeightAndCapacity x -> DesiredWeightAndCapacity
$cfrom :: forall x.
DesiredWeightAndCapacity -> Rep DesiredWeightAndCapacity x
Prelude.Generic)

-- |
-- Create a value of 'DesiredWeightAndCapacity' 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:
--
-- 'desiredInstanceCount', 'desiredWeightAndCapacity_desiredInstanceCount' - The variant\'s capacity.
--
-- 'desiredWeight', 'desiredWeightAndCapacity_desiredWeight' - The variant\'s weight.
--
-- 'variantName', 'desiredWeightAndCapacity_variantName' - The name of the variant to update.
newDesiredWeightAndCapacity ::
  -- | 'variantName'
  Prelude.Text ->
  DesiredWeightAndCapacity
newDesiredWeightAndCapacity :: Text -> DesiredWeightAndCapacity
newDesiredWeightAndCapacity Text
pVariantName_ =
  DesiredWeightAndCapacity' :: Maybe Natural -> Maybe Double -> Text -> DesiredWeightAndCapacity
DesiredWeightAndCapacity'
    { $sel:desiredInstanceCount:DesiredWeightAndCapacity' :: Maybe Natural
desiredInstanceCount =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:desiredWeight:DesiredWeightAndCapacity' :: Maybe Double
desiredWeight = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:variantName:DesiredWeightAndCapacity' :: Text
variantName = Text
pVariantName_
    }

-- | The variant\'s capacity.
desiredWeightAndCapacity_desiredInstanceCount :: Lens.Lens' DesiredWeightAndCapacity (Prelude.Maybe Prelude.Natural)
desiredWeightAndCapacity_desiredInstanceCount :: (Maybe Natural -> f (Maybe Natural))
-> DesiredWeightAndCapacity -> f DesiredWeightAndCapacity
desiredWeightAndCapacity_desiredInstanceCount = (DesiredWeightAndCapacity -> Maybe Natural)
-> (DesiredWeightAndCapacity
    -> Maybe Natural -> DesiredWeightAndCapacity)
-> Lens
     DesiredWeightAndCapacity
     DesiredWeightAndCapacity
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DesiredWeightAndCapacity' {Maybe Natural
desiredInstanceCount :: Maybe Natural
$sel:desiredInstanceCount:DesiredWeightAndCapacity' :: DesiredWeightAndCapacity -> Maybe Natural
desiredInstanceCount} -> Maybe Natural
desiredInstanceCount) (\s :: DesiredWeightAndCapacity
s@DesiredWeightAndCapacity' {} Maybe Natural
a -> DesiredWeightAndCapacity
s {$sel:desiredInstanceCount:DesiredWeightAndCapacity' :: Maybe Natural
desiredInstanceCount = Maybe Natural
a} :: DesiredWeightAndCapacity)

-- | The variant\'s weight.
desiredWeightAndCapacity_desiredWeight :: Lens.Lens' DesiredWeightAndCapacity (Prelude.Maybe Prelude.Double)
desiredWeightAndCapacity_desiredWeight :: (Maybe Double -> f (Maybe Double))
-> DesiredWeightAndCapacity -> f DesiredWeightAndCapacity
desiredWeightAndCapacity_desiredWeight = (DesiredWeightAndCapacity -> Maybe Double)
-> (DesiredWeightAndCapacity
    -> Maybe Double -> DesiredWeightAndCapacity)
-> Lens
     DesiredWeightAndCapacity
     DesiredWeightAndCapacity
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DesiredWeightAndCapacity' {Maybe Double
desiredWeight :: Maybe Double
$sel:desiredWeight:DesiredWeightAndCapacity' :: DesiredWeightAndCapacity -> Maybe Double
desiredWeight} -> Maybe Double
desiredWeight) (\s :: DesiredWeightAndCapacity
s@DesiredWeightAndCapacity' {} Maybe Double
a -> DesiredWeightAndCapacity
s {$sel:desiredWeight:DesiredWeightAndCapacity' :: Maybe Double
desiredWeight = Maybe Double
a} :: DesiredWeightAndCapacity)

-- | The name of the variant to update.
desiredWeightAndCapacity_variantName :: Lens.Lens' DesiredWeightAndCapacity Prelude.Text
desiredWeightAndCapacity_variantName :: (Text -> f Text)
-> DesiredWeightAndCapacity -> f DesiredWeightAndCapacity
desiredWeightAndCapacity_variantName = (DesiredWeightAndCapacity -> Text)
-> (DesiredWeightAndCapacity -> Text -> DesiredWeightAndCapacity)
-> Lens DesiredWeightAndCapacity DesiredWeightAndCapacity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DesiredWeightAndCapacity' {Text
variantName :: Text
$sel:variantName:DesiredWeightAndCapacity' :: DesiredWeightAndCapacity -> Text
variantName} -> Text
variantName) (\s :: DesiredWeightAndCapacity
s@DesiredWeightAndCapacity' {} Text
a -> DesiredWeightAndCapacity
s {$sel:variantName:DesiredWeightAndCapacity' :: Text
variantName = Text
a} :: DesiredWeightAndCapacity)

instance Prelude.Hashable DesiredWeightAndCapacity

instance Prelude.NFData DesiredWeightAndCapacity

instance Core.ToJSON DesiredWeightAndCapacity where
  toJSON :: DesiredWeightAndCapacity -> Value
toJSON DesiredWeightAndCapacity' {Maybe Double
Maybe Natural
Text
variantName :: Text
desiredWeight :: Maybe Double
desiredInstanceCount :: Maybe Natural
$sel:variantName:DesiredWeightAndCapacity' :: DesiredWeightAndCapacity -> Text
$sel:desiredWeight:DesiredWeightAndCapacity' :: DesiredWeightAndCapacity -> Maybe Double
$sel:desiredInstanceCount:DesiredWeightAndCapacity' :: DesiredWeightAndCapacity -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DesiredInstanceCount" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
desiredInstanceCount,
            (Text
"DesiredWeight" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
desiredWeight,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"VariantName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
variantName)
          ]
      )