{-# 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.CapacitySize
-- 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.CapacitySize 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
import Amazonka.SageMaker.Types.CapacitySizeType

-- | Specifies the endpoint capacity to activate for production.
--
-- /See:/ 'newCapacitySize' smart constructor.
data CapacitySize = CapacitySize'
  { -- | Specifies the endpoint capacity type.
    --
    -- -   @INSTANCE_COUNT@: The endpoint activates based on the number of
    --     instances.
    --
    -- -   @CAPACITY_PERCENT@: The endpoint activates based on the specified
    --     percentage of capacity.
    CapacitySize -> CapacitySizeType
type' :: CapacitySizeType,
    -- | Defines the capacity size, either as a number of instances or a capacity
    -- percentage.
    CapacitySize -> Natural
value :: Prelude.Natural
  }
  deriving (CapacitySize -> CapacitySize -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CapacitySize -> CapacitySize -> Bool
$c/= :: CapacitySize -> CapacitySize -> Bool
== :: CapacitySize -> CapacitySize -> Bool
$c== :: CapacitySize -> CapacitySize -> Bool
Prelude.Eq, ReadPrec [CapacitySize]
ReadPrec CapacitySize
Int -> ReadS CapacitySize
ReadS [CapacitySize]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CapacitySize]
$creadListPrec :: ReadPrec [CapacitySize]
readPrec :: ReadPrec CapacitySize
$creadPrec :: ReadPrec CapacitySize
readList :: ReadS [CapacitySize]
$creadList :: ReadS [CapacitySize]
readsPrec :: Int -> ReadS CapacitySize
$creadsPrec :: Int -> ReadS CapacitySize
Prelude.Read, Int -> CapacitySize -> ShowS
[CapacitySize] -> ShowS
CapacitySize -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CapacitySize] -> ShowS
$cshowList :: [CapacitySize] -> ShowS
show :: CapacitySize -> String
$cshow :: CapacitySize -> String
showsPrec :: Int -> CapacitySize -> ShowS
$cshowsPrec :: Int -> CapacitySize -> ShowS
Prelude.Show, forall x. Rep CapacitySize x -> CapacitySize
forall x. CapacitySize -> Rep CapacitySize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CapacitySize x -> CapacitySize
$cfrom :: forall x. CapacitySize -> Rep CapacitySize x
Prelude.Generic)

-- |
-- Create a value of 'CapacitySize' 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:
--
-- 'type'', 'capacitySize_type' - Specifies the endpoint capacity type.
--
-- -   @INSTANCE_COUNT@: The endpoint activates based on the number of
--     instances.
--
-- -   @CAPACITY_PERCENT@: The endpoint activates based on the specified
--     percentage of capacity.
--
-- 'value', 'capacitySize_value' - Defines the capacity size, either as a number of instances or a capacity
-- percentage.
newCapacitySize ::
  -- | 'type''
  CapacitySizeType ->
  -- | 'value'
  Prelude.Natural ->
  CapacitySize
newCapacitySize :: CapacitySizeType -> Natural -> CapacitySize
newCapacitySize CapacitySizeType
pType_ Natural
pValue_ =
  CapacitySize' {$sel:type':CapacitySize' :: CapacitySizeType
type' = CapacitySizeType
pType_, $sel:value:CapacitySize' :: Natural
value = Natural
pValue_}

-- | Specifies the endpoint capacity type.
--
-- -   @INSTANCE_COUNT@: The endpoint activates based on the number of
--     instances.
--
-- -   @CAPACITY_PERCENT@: The endpoint activates based on the specified
--     percentage of capacity.
capacitySize_type :: Lens.Lens' CapacitySize CapacitySizeType
capacitySize_type :: Lens' CapacitySize CapacitySizeType
capacitySize_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacitySize' {CapacitySizeType
type' :: CapacitySizeType
$sel:type':CapacitySize' :: CapacitySize -> CapacitySizeType
type'} -> CapacitySizeType
type') (\s :: CapacitySize
s@CapacitySize' {} CapacitySizeType
a -> CapacitySize
s {$sel:type':CapacitySize' :: CapacitySizeType
type' = CapacitySizeType
a} :: CapacitySize)

-- | Defines the capacity size, either as a number of instances or a capacity
-- percentage.
capacitySize_value :: Lens.Lens' CapacitySize Prelude.Natural
capacitySize_value :: Lens' CapacitySize Natural
capacitySize_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CapacitySize' {Natural
value :: Natural
$sel:value:CapacitySize' :: CapacitySize -> Natural
value} -> Natural
value) (\s :: CapacitySize
s@CapacitySize' {} Natural
a -> CapacitySize
s {$sel:value:CapacitySize' :: Natural
value = Natural
a} :: CapacitySize)

instance Data.FromJSON CapacitySize where
  parseJSON :: Value -> Parser CapacitySize
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CapacitySize"
      ( \Object
x ->
          CapacitySizeType -> Natural -> CapacitySize
CapacitySize'
            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
"Type")
            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
"Value")
      )

instance Prelude.Hashable CapacitySize where
  hashWithSalt :: Int -> CapacitySize -> Int
hashWithSalt Int
_salt CapacitySize' {Natural
CapacitySizeType
value :: Natural
type' :: CapacitySizeType
$sel:value:CapacitySize' :: CapacitySize -> Natural
$sel:type':CapacitySize' :: CapacitySize -> CapacitySizeType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CapacitySizeType
type'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
value

instance Prelude.NFData CapacitySize where
  rnf :: CapacitySize -> ()
rnf CapacitySize' {Natural
CapacitySizeType
value :: Natural
type' :: CapacitySizeType
$sel:value:CapacitySize' :: CapacitySize -> Natural
$sel:type':CapacitySize' :: CapacitySize -> CapacitySizeType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf CapacitySizeType
type' seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
value

instance Data.ToJSON CapacitySize where
  toJSON :: CapacitySize -> Value
toJSON CapacitySize' {Natural
CapacitySizeType
value :: Natural
type' :: CapacitySizeType
$sel:value:CapacitySize' :: CapacitySize -> Natural
$sel:type':CapacitySize' :: CapacitySize -> CapacitySizeType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= CapacitySizeType
type'),
            forall a. a -> Maybe a
Prelude.Just (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
value)
          ]
      )