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

-- | Specifies conditions for stopping a job. When a job reaches a stopping
-- condition limit, SageMaker ends the job.
--
-- /See:/ 'newRecommendationJobStoppingConditions' smart constructor.
data RecommendationJobStoppingConditions = RecommendationJobStoppingConditions'
  { -- | The maximum number of requests per minute expected for the endpoint.
    RecommendationJobStoppingConditions -> Maybe Int
maxInvocations :: Prelude.Maybe Prelude.Int,
    -- | The interval of time taken by a model to respond as viewed from
    -- SageMaker. The interval includes the local communication time taken to
    -- send the request and to fetch the response from the container of a model
    -- and the time taken to complete the inference in the container.
    RecommendationJobStoppingConditions
-> Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds :: Prelude.Maybe (Prelude.NonEmpty ModelLatencyThreshold)
  }
  deriving (RecommendationJobStoppingConditions
-> RecommendationJobStoppingConditions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecommendationJobStoppingConditions
-> RecommendationJobStoppingConditions -> Bool
$c/= :: RecommendationJobStoppingConditions
-> RecommendationJobStoppingConditions -> Bool
== :: RecommendationJobStoppingConditions
-> RecommendationJobStoppingConditions -> Bool
$c== :: RecommendationJobStoppingConditions
-> RecommendationJobStoppingConditions -> Bool
Prelude.Eq, ReadPrec [RecommendationJobStoppingConditions]
ReadPrec RecommendationJobStoppingConditions
Int -> ReadS RecommendationJobStoppingConditions
ReadS [RecommendationJobStoppingConditions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecommendationJobStoppingConditions]
$creadListPrec :: ReadPrec [RecommendationJobStoppingConditions]
readPrec :: ReadPrec RecommendationJobStoppingConditions
$creadPrec :: ReadPrec RecommendationJobStoppingConditions
readList :: ReadS [RecommendationJobStoppingConditions]
$creadList :: ReadS [RecommendationJobStoppingConditions]
readsPrec :: Int -> ReadS RecommendationJobStoppingConditions
$creadsPrec :: Int -> ReadS RecommendationJobStoppingConditions
Prelude.Read, Int -> RecommendationJobStoppingConditions -> ShowS
[RecommendationJobStoppingConditions] -> ShowS
RecommendationJobStoppingConditions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecommendationJobStoppingConditions] -> ShowS
$cshowList :: [RecommendationJobStoppingConditions] -> ShowS
show :: RecommendationJobStoppingConditions -> String
$cshow :: RecommendationJobStoppingConditions -> String
showsPrec :: Int -> RecommendationJobStoppingConditions -> ShowS
$cshowsPrec :: Int -> RecommendationJobStoppingConditions -> ShowS
Prelude.Show, forall x.
Rep RecommendationJobStoppingConditions x
-> RecommendationJobStoppingConditions
forall x.
RecommendationJobStoppingConditions
-> Rep RecommendationJobStoppingConditions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RecommendationJobStoppingConditions x
-> RecommendationJobStoppingConditions
$cfrom :: forall x.
RecommendationJobStoppingConditions
-> Rep RecommendationJobStoppingConditions x
Prelude.Generic)

-- |
-- Create a value of 'RecommendationJobStoppingConditions' 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:
--
-- 'maxInvocations', 'recommendationJobStoppingConditions_maxInvocations' - The maximum number of requests per minute expected for the endpoint.
--
-- 'modelLatencyThresholds', 'recommendationJobStoppingConditions_modelLatencyThresholds' - The interval of time taken by a model to respond as viewed from
-- SageMaker. The interval includes the local communication time taken to
-- send the request and to fetch the response from the container of a model
-- and the time taken to complete the inference in the container.
newRecommendationJobStoppingConditions ::
  RecommendationJobStoppingConditions
newRecommendationJobStoppingConditions :: RecommendationJobStoppingConditions
newRecommendationJobStoppingConditions =
  RecommendationJobStoppingConditions'
    { $sel:maxInvocations:RecommendationJobStoppingConditions' :: Maybe Int
maxInvocations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:modelLatencyThresholds:RecommendationJobStoppingConditions' :: Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of requests per minute expected for the endpoint.
recommendationJobStoppingConditions_maxInvocations :: Lens.Lens' RecommendationJobStoppingConditions (Prelude.Maybe Prelude.Int)
recommendationJobStoppingConditions_maxInvocations :: Lens' RecommendationJobStoppingConditions (Maybe Int)
recommendationJobStoppingConditions_maxInvocations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationJobStoppingConditions' {Maybe Int
maxInvocations :: Maybe Int
$sel:maxInvocations:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions -> Maybe Int
maxInvocations} -> Maybe Int
maxInvocations) (\s :: RecommendationJobStoppingConditions
s@RecommendationJobStoppingConditions' {} Maybe Int
a -> RecommendationJobStoppingConditions
s {$sel:maxInvocations:RecommendationJobStoppingConditions' :: Maybe Int
maxInvocations = Maybe Int
a} :: RecommendationJobStoppingConditions)

-- | The interval of time taken by a model to respond as viewed from
-- SageMaker. The interval includes the local communication time taken to
-- send the request and to fetch the response from the container of a model
-- and the time taken to complete the inference in the container.
recommendationJobStoppingConditions_modelLatencyThresholds :: Lens.Lens' RecommendationJobStoppingConditions (Prelude.Maybe (Prelude.NonEmpty ModelLatencyThreshold))
recommendationJobStoppingConditions_modelLatencyThresholds :: Lens'
  RecommendationJobStoppingConditions
  (Maybe (NonEmpty ModelLatencyThreshold))
recommendationJobStoppingConditions_modelLatencyThresholds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationJobStoppingConditions' {Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds :: Maybe (NonEmpty ModelLatencyThreshold)
$sel:modelLatencyThresholds:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions
-> Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds} -> Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds) (\s :: RecommendationJobStoppingConditions
s@RecommendationJobStoppingConditions' {} Maybe (NonEmpty ModelLatencyThreshold)
a -> RecommendationJobStoppingConditions
s {$sel:modelLatencyThresholds:RecommendationJobStoppingConditions' :: Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds = Maybe (NonEmpty ModelLatencyThreshold)
a} :: RecommendationJobStoppingConditions) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Data.FromJSON
    RecommendationJobStoppingConditions
  where
  parseJSON :: Value -> Parser RecommendationJobStoppingConditions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RecommendationJobStoppingConditions"
      ( \Object
x ->
          Maybe Int
-> Maybe (NonEmpty ModelLatencyThreshold)
-> RecommendationJobStoppingConditions
RecommendationJobStoppingConditions'
            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
"MaxInvocations")
            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
"ModelLatencyThresholds")
      )

instance
  Prelude.Hashable
    RecommendationJobStoppingConditions
  where
  hashWithSalt :: Int -> RecommendationJobStoppingConditions -> Int
hashWithSalt
    Int
_salt
    RecommendationJobStoppingConditions' {Maybe Int
Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds :: Maybe (NonEmpty ModelLatencyThreshold)
maxInvocations :: Maybe Int
$sel:modelLatencyThresholds:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions
-> Maybe (NonEmpty ModelLatencyThreshold)
$sel:maxInvocations:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions -> Maybe Int
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
maxInvocations
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds

instance
  Prelude.NFData
    RecommendationJobStoppingConditions
  where
  rnf :: RecommendationJobStoppingConditions -> ()
rnf RecommendationJobStoppingConditions' {Maybe Int
Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds :: Maybe (NonEmpty ModelLatencyThreshold)
maxInvocations :: Maybe Int
$sel:modelLatencyThresholds:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions
-> Maybe (NonEmpty ModelLatencyThreshold)
$sel:maxInvocations:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
maxInvocations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds

instance
  Data.ToJSON
    RecommendationJobStoppingConditions
  where
  toJSON :: RecommendationJobStoppingConditions -> Value
toJSON RecommendationJobStoppingConditions' {Maybe Int
Maybe (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds :: Maybe (NonEmpty ModelLatencyThreshold)
maxInvocations :: Maybe Int
$sel:modelLatencyThresholds:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions
-> Maybe (NonEmpty ModelLatencyThreshold)
$sel:maxInvocations:RecommendationJobStoppingConditions' :: RecommendationJobStoppingConditions -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxInvocations" 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
maxInvocations,
            (Key
"ModelLatencyThresholds" 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 (NonEmpty ModelLatencyThreshold)
modelLatencyThresholds
          ]
      )