{-# 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.ProductionVariantServerlessConfig
-- 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.ProductionVariantServerlessConfig 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 the serverless configuration for an endpoint variant.
--
-- /See:/ 'newProductionVariantServerlessConfig' smart constructor.
data ProductionVariantServerlessConfig = ProductionVariantServerlessConfig'
  { -- | The memory size of your serverless endpoint. Valid values are in 1 GB
    -- increments: 1024 MB, 2048 MB, 3072 MB, 4096 MB, 5120 MB, or 6144 MB.
    ProductionVariantServerlessConfig -> Natural
memorySizeInMB :: Prelude.Natural,
    -- | The maximum number of concurrent invocations your serverless endpoint
    -- can process.
    ProductionVariantServerlessConfig -> Natural
maxConcurrency :: Prelude.Natural
  }
  deriving (ProductionVariantServerlessConfig
-> ProductionVariantServerlessConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProductionVariantServerlessConfig
-> ProductionVariantServerlessConfig -> Bool
$c/= :: ProductionVariantServerlessConfig
-> ProductionVariantServerlessConfig -> Bool
== :: ProductionVariantServerlessConfig
-> ProductionVariantServerlessConfig -> Bool
$c== :: ProductionVariantServerlessConfig
-> ProductionVariantServerlessConfig -> Bool
Prelude.Eq, ReadPrec [ProductionVariantServerlessConfig]
ReadPrec ProductionVariantServerlessConfig
Int -> ReadS ProductionVariantServerlessConfig
ReadS [ProductionVariantServerlessConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProductionVariantServerlessConfig]
$creadListPrec :: ReadPrec [ProductionVariantServerlessConfig]
readPrec :: ReadPrec ProductionVariantServerlessConfig
$creadPrec :: ReadPrec ProductionVariantServerlessConfig
readList :: ReadS [ProductionVariantServerlessConfig]
$creadList :: ReadS [ProductionVariantServerlessConfig]
readsPrec :: Int -> ReadS ProductionVariantServerlessConfig
$creadsPrec :: Int -> ReadS ProductionVariantServerlessConfig
Prelude.Read, Int -> ProductionVariantServerlessConfig -> ShowS
[ProductionVariantServerlessConfig] -> ShowS
ProductionVariantServerlessConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProductionVariantServerlessConfig] -> ShowS
$cshowList :: [ProductionVariantServerlessConfig] -> ShowS
show :: ProductionVariantServerlessConfig -> String
$cshow :: ProductionVariantServerlessConfig -> String
showsPrec :: Int -> ProductionVariantServerlessConfig -> ShowS
$cshowsPrec :: Int -> ProductionVariantServerlessConfig -> ShowS
Prelude.Show, forall x.
Rep ProductionVariantServerlessConfig x
-> ProductionVariantServerlessConfig
forall x.
ProductionVariantServerlessConfig
-> Rep ProductionVariantServerlessConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ProductionVariantServerlessConfig x
-> ProductionVariantServerlessConfig
$cfrom :: forall x.
ProductionVariantServerlessConfig
-> Rep ProductionVariantServerlessConfig x
Prelude.Generic)

-- |
-- Create a value of 'ProductionVariantServerlessConfig' 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:
--
-- 'memorySizeInMB', 'productionVariantServerlessConfig_memorySizeInMB' - The memory size of your serverless endpoint. Valid values are in 1 GB
-- increments: 1024 MB, 2048 MB, 3072 MB, 4096 MB, 5120 MB, or 6144 MB.
--
-- 'maxConcurrency', 'productionVariantServerlessConfig_maxConcurrency' - The maximum number of concurrent invocations your serverless endpoint
-- can process.
newProductionVariantServerlessConfig ::
  -- | 'memorySizeInMB'
  Prelude.Natural ->
  -- | 'maxConcurrency'
  Prelude.Natural ->
  ProductionVariantServerlessConfig
newProductionVariantServerlessConfig :: Natural -> Natural -> ProductionVariantServerlessConfig
newProductionVariantServerlessConfig
  Natural
pMemorySizeInMB_
  Natural
pMaxConcurrency_ =
    ProductionVariantServerlessConfig'
      { $sel:memorySizeInMB:ProductionVariantServerlessConfig' :: Natural
memorySizeInMB =
          Natural
pMemorySizeInMB_,
        $sel:maxConcurrency:ProductionVariantServerlessConfig' :: Natural
maxConcurrency = Natural
pMaxConcurrency_
      }

-- | The memory size of your serverless endpoint. Valid values are in 1 GB
-- increments: 1024 MB, 2048 MB, 3072 MB, 4096 MB, 5120 MB, or 6144 MB.
productionVariantServerlessConfig_memorySizeInMB :: Lens.Lens' ProductionVariantServerlessConfig Prelude.Natural
productionVariantServerlessConfig_memorySizeInMB :: Lens' ProductionVariantServerlessConfig Natural
productionVariantServerlessConfig_memorySizeInMB = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductionVariantServerlessConfig' {Natural
memorySizeInMB :: Natural
$sel:memorySizeInMB:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
memorySizeInMB} -> Natural
memorySizeInMB) (\s :: ProductionVariantServerlessConfig
s@ProductionVariantServerlessConfig' {} Natural
a -> ProductionVariantServerlessConfig
s {$sel:memorySizeInMB:ProductionVariantServerlessConfig' :: Natural
memorySizeInMB = Natural
a} :: ProductionVariantServerlessConfig)

-- | The maximum number of concurrent invocations your serverless endpoint
-- can process.
productionVariantServerlessConfig_maxConcurrency :: Lens.Lens' ProductionVariantServerlessConfig Prelude.Natural
productionVariantServerlessConfig_maxConcurrency :: Lens' ProductionVariantServerlessConfig Natural
productionVariantServerlessConfig_maxConcurrency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProductionVariantServerlessConfig' {Natural
maxConcurrency :: Natural
$sel:maxConcurrency:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
maxConcurrency} -> Natural
maxConcurrency) (\s :: ProductionVariantServerlessConfig
s@ProductionVariantServerlessConfig' {} Natural
a -> ProductionVariantServerlessConfig
s {$sel:maxConcurrency:ProductionVariantServerlessConfig' :: Natural
maxConcurrency = Natural
a} :: ProductionVariantServerlessConfig)

instance
  Data.FromJSON
    ProductionVariantServerlessConfig
  where
  parseJSON :: Value -> Parser ProductionVariantServerlessConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ProductionVariantServerlessConfig"
      ( \Object
x ->
          Natural -> Natural -> ProductionVariantServerlessConfig
ProductionVariantServerlessConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MemorySizeInMB")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MaxConcurrency")
      )

instance
  Prelude.Hashable
    ProductionVariantServerlessConfig
  where
  hashWithSalt :: Int -> ProductionVariantServerlessConfig -> Int
hashWithSalt
    Int
_salt
    ProductionVariantServerlessConfig' {Natural
maxConcurrency :: Natural
memorySizeInMB :: Natural
$sel:maxConcurrency:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
$sel:memorySizeInMB:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
memorySizeInMB
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maxConcurrency

instance
  Prelude.NFData
    ProductionVariantServerlessConfig
  where
  rnf :: ProductionVariantServerlessConfig -> ()
rnf ProductionVariantServerlessConfig' {Natural
maxConcurrency :: Natural
memorySizeInMB :: Natural
$sel:maxConcurrency:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
$sel:memorySizeInMB:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
memorySizeInMB
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
maxConcurrency

instance
  Data.ToJSON
    ProductionVariantServerlessConfig
  where
  toJSON :: ProductionVariantServerlessConfig -> Value
toJSON ProductionVariantServerlessConfig' {Natural
maxConcurrency :: Natural
memorySizeInMB :: Natural
$sel:maxConcurrency:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
$sel:memorySizeInMB:ProductionVariantServerlessConfig' :: ProductionVariantServerlessConfig -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"MemorySizeInMB" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
memorySizeInMB),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"MaxConcurrency" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maxConcurrency)
          ]
      )