{-# 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.ModelLatencyThreshold
-- 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.ModelLatencyThreshold 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

-- | The model latency threshold.
--
-- /See:/ 'newModelLatencyThreshold' smart constructor.
data ModelLatencyThreshold = ModelLatencyThreshold'
  { -- | The model latency percentile threshold.
    ModelLatencyThreshold -> Maybe Text
percentile :: Prelude.Maybe Prelude.Text,
    -- | The model latency percentile value in milliseconds.
    ModelLatencyThreshold -> Maybe Int
valueInMilliseconds :: Prelude.Maybe Prelude.Int
  }
  deriving (ModelLatencyThreshold -> ModelLatencyThreshold -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelLatencyThreshold -> ModelLatencyThreshold -> Bool
$c/= :: ModelLatencyThreshold -> ModelLatencyThreshold -> Bool
== :: ModelLatencyThreshold -> ModelLatencyThreshold -> Bool
$c== :: ModelLatencyThreshold -> ModelLatencyThreshold -> Bool
Prelude.Eq, ReadPrec [ModelLatencyThreshold]
ReadPrec ModelLatencyThreshold
Int -> ReadS ModelLatencyThreshold
ReadS [ModelLatencyThreshold]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModelLatencyThreshold]
$creadListPrec :: ReadPrec [ModelLatencyThreshold]
readPrec :: ReadPrec ModelLatencyThreshold
$creadPrec :: ReadPrec ModelLatencyThreshold
readList :: ReadS [ModelLatencyThreshold]
$creadList :: ReadS [ModelLatencyThreshold]
readsPrec :: Int -> ReadS ModelLatencyThreshold
$creadsPrec :: Int -> ReadS ModelLatencyThreshold
Prelude.Read, Int -> ModelLatencyThreshold -> ShowS
[ModelLatencyThreshold] -> ShowS
ModelLatencyThreshold -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelLatencyThreshold] -> ShowS
$cshowList :: [ModelLatencyThreshold] -> ShowS
show :: ModelLatencyThreshold -> String
$cshow :: ModelLatencyThreshold -> String
showsPrec :: Int -> ModelLatencyThreshold -> ShowS
$cshowsPrec :: Int -> ModelLatencyThreshold -> ShowS
Prelude.Show, forall x. Rep ModelLatencyThreshold x -> ModelLatencyThreshold
forall x. ModelLatencyThreshold -> Rep ModelLatencyThreshold x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelLatencyThreshold x -> ModelLatencyThreshold
$cfrom :: forall x. ModelLatencyThreshold -> Rep ModelLatencyThreshold x
Prelude.Generic)

-- |
-- Create a value of 'ModelLatencyThreshold' 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:
--
-- 'percentile', 'modelLatencyThreshold_percentile' - The model latency percentile threshold.
--
-- 'valueInMilliseconds', 'modelLatencyThreshold_valueInMilliseconds' - The model latency percentile value in milliseconds.
newModelLatencyThreshold ::
  ModelLatencyThreshold
newModelLatencyThreshold :: ModelLatencyThreshold
newModelLatencyThreshold =
  ModelLatencyThreshold'
    { $sel:percentile:ModelLatencyThreshold' :: Maybe Text
percentile =
        forall a. Maybe a
Prelude.Nothing,
      $sel:valueInMilliseconds:ModelLatencyThreshold' :: Maybe Int
valueInMilliseconds = forall a. Maybe a
Prelude.Nothing
    }

-- | The model latency percentile threshold.
modelLatencyThreshold_percentile :: Lens.Lens' ModelLatencyThreshold (Prelude.Maybe Prelude.Text)
modelLatencyThreshold_percentile :: Lens' ModelLatencyThreshold (Maybe Text)
modelLatencyThreshold_percentile = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelLatencyThreshold' {Maybe Text
percentile :: Maybe Text
$sel:percentile:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Text
percentile} -> Maybe Text
percentile) (\s :: ModelLatencyThreshold
s@ModelLatencyThreshold' {} Maybe Text
a -> ModelLatencyThreshold
s {$sel:percentile:ModelLatencyThreshold' :: Maybe Text
percentile = Maybe Text
a} :: ModelLatencyThreshold)

-- | The model latency percentile value in milliseconds.
modelLatencyThreshold_valueInMilliseconds :: Lens.Lens' ModelLatencyThreshold (Prelude.Maybe Prelude.Int)
modelLatencyThreshold_valueInMilliseconds :: Lens' ModelLatencyThreshold (Maybe Int)
modelLatencyThreshold_valueInMilliseconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelLatencyThreshold' {Maybe Int
valueInMilliseconds :: Maybe Int
$sel:valueInMilliseconds:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Int
valueInMilliseconds} -> Maybe Int
valueInMilliseconds) (\s :: ModelLatencyThreshold
s@ModelLatencyThreshold' {} Maybe Int
a -> ModelLatencyThreshold
s {$sel:valueInMilliseconds:ModelLatencyThreshold' :: Maybe Int
valueInMilliseconds = Maybe Int
a} :: ModelLatencyThreshold)

instance Data.FromJSON ModelLatencyThreshold where
  parseJSON :: Value -> Parser ModelLatencyThreshold
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ModelLatencyThreshold"
      ( \Object
x ->
          Maybe Text -> Maybe Int -> ModelLatencyThreshold
ModelLatencyThreshold'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Percentile")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ValueInMilliseconds")
      )

instance Prelude.Hashable ModelLatencyThreshold where
  hashWithSalt :: Int -> ModelLatencyThreshold -> Int
hashWithSalt Int
_salt ModelLatencyThreshold' {Maybe Int
Maybe Text
valueInMilliseconds :: Maybe Int
percentile :: Maybe Text
$sel:valueInMilliseconds:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Int
$sel:percentile:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
percentile
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
valueInMilliseconds

instance Prelude.NFData ModelLatencyThreshold where
  rnf :: ModelLatencyThreshold -> ()
rnf ModelLatencyThreshold' {Maybe Int
Maybe Text
valueInMilliseconds :: Maybe Int
percentile :: Maybe Text
$sel:valueInMilliseconds:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Int
$sel:percentile:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
percentile
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
valueInMilliseconds

instance Data.ToJSON ModelLatencyThreshold where
  toJSON :: ModelLatencyThreshold -> Value
toJSON ModelLatencyThreshold' {Maybe Int
Maybe Text
valueInMilliseconds :: Maybe Int
percentile :: Maybe Text
$sel:valueInMilliseconds:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Int
$sel:percentile:ModelLatencyThreshold' :: ModelLatencyThreshold -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Percentile" 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 Text
percentile,
            (Key
"ValueInMilliseconds" 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 Int
valueInMilliseconds
          ]
      )