{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.DesiredWeightAndCapacity 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

-- | 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
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]
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
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.
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'
    { $sel:desiredInstanceCount:DesiredWeightAndCapacity' :: Maybe Natural
desiredInstanceCount =
        forall a. Maybe a
Prelude.Nothing,
      $sel:desiredWeight:DesiredWeightAndCapacity' :: Maybe Double
desiredWeight = 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 :: Lens' DesiredWeightAndCapacity (Maybe Natural)
desiredWeightAndCapacity_desiredInstanceCount = 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 :: Lens' DesiredWeightAndCapacity (Maybe Double)
desiredWeightAndCapacity_desiredWeight = 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 :: Lens' DesiredWeightAndCapacity Text
desiredWeightAndCapacity_variantName = 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 where
  hashWithSalt :: Int -> DesiredWeightAndCapacity -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
desiredInstanceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
desiredWeight
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
variantName

instance Prelude.NFData DesiredWeightAndCapacity where
  rnf :: DesiredWeightAndCapacity -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
desiredInstanceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
desiredWeight
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
variantName

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DesiredInstanceCount" 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 Natural
desiredInstanceCount,
            (Key
"DesiredWeight" 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 Double
desiredWeight,
            forall a. a -> Maybe a
Prelude.Just (Key
"VariantName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
variantName)
          ]
      )