{-# 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.SageMakerEdge.Types.Model
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMakerEdge.Types.Model where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMakerEdge.Types.EdgeMetric

-- | Information about a model deployed on an edge device that is registered
-- with SageMaker Edge Manager.
--
-- /See:/ 'newModel' smart constructor.
data Model = Model'
  { -- | The name of the model.
    Model -> Maybe Text
modelName :: Prelude.Maybe Prelude.Text,
    -- | Information required for model metrics.
    Model -> Maybe [EdgeMetric]
modelMetrics :: Prelude.Maybe [EdgeMetric],
    -- | The version of the model.
    Model -> Maybe Text
modelVersion :: Prelude.Maybe Prelude.Text,
    -- | The timestamp of the last inference that was made.
    Model -> Maybe POSIX
latestInference :: Prelude.Maybe Core.POSIX,
    -- | The timestamp of the last data sample taken.
    Model -> Maybe POSIX
latestSampleTime :: Prelude.Maybe Core.POSIX
  }
  deriving (Model -> Model -> Bool
(Model -> Model -> Bool) -> (Model -> Model -> Bool) -> Eq Model
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Model -> Model -> Bool
$c/= :: Model -> Model -> Bool
== :: Model -> Model -> Bool
$c== :: Model -> Model -> Bool
Prelude.Eq, ReadPrec [Model]
ReadPrec Model
Int -> ReadS Model
ReadS [Model]
(Int -> ReadS Model)
-> ReadS [Model]
-> ReadPrec Model
-> ReadPrec [Model]
-> Read Model
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Model]
$creadListPrec :: ReadPrec [Model]
readPrec :: ReadPrec Model
$creadPrec :: ReadPrec Model
readList :: ReadS [Model]
$creadList :: ReadS [Model]
readsPrec :: Int -> ReadS Model
$creadsPrec :: Int -> ReadS Model
Prelude.Read, Int -> Model -> ShowS
[Model] -> ShowS
Model -> String
(Int -> Model -> ShowS)
-> (Model -> String) -> ([Model] -> ShowS) -> Show Model
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Model] -> ShowS
$cshowList :: [Model] -> ShowS
show :: Model -> String
$cshow :: Model -> String
showsPrec :: Int -> Model -> ShowS
$cshowsPrec :: Int -> Model -> ShowS
Prelude.Show, (forall x. Model -> Rep Model x)
-> (forall x. Rep Model x -> Model) -> Generic Model
forall x. Rep Model x -> Model
forall x. Model -> Rep Model x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Model x -> Model
$cfrom :: forall x. Model -> Rep Model x
Prelude.Generic)

-- |
-- Create a value of 'Model' 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:
--
-- 'modelName', 'model_modelName' - The name of the model.
--
-- 'modelMetrics', 'model_modelMetrics' - Information required for model metrics.
--
-- 'modelVersion', 'model_modelVersion' - The version of the model.
--
-- 'latestInference', 'model_latestInference' - The timestamp of the last inference that was made.
--
-- 'latestSampleTime', 'model_latestSampleTime' - The timestamp of the last data sample taken.
newModel ::
  Model
newModel :: Model
newModel =
  Model' :: Maybe Text
-> Maybe [EdgeMetric]
-> Maybe Text
-> Maybe POSIX
-> Maybe POSIX
-> Model
Model'
    { $sel:modelName:Model' :: Maybe Text
modelName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:modelMetrics:Model' :: Maybe [EdgeMetric]
modelMetrics = Maybe [EdgeMetric]
forall a. Maybe a
Prelude.Nothing,
      $sel:modelVersion:Model' :: Maybe Text
modelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:latestInference:Model' :: Maybe POSIX
latestInference = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:latestSampleTime:Model' :: Maybe POSIX
latestSampleTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the model.
model_modelName :: Lens.Lens' Model (Prelude.Maybe Prelude.Text)
model_modelName :: (Maybe Text -> f (Maybe Text)) -> Model -> f Model
model_modelName = (Model -> Maybe Text)
-> (Model -> Maybe Text -> Model)
-> Lens Model Model (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Model' {Maybe Text
modelName :: Maybe Text
$sel:modelName:Model' :: Model -> Maybe Text
modelName} -> Maybe Text
modelName) (\s :: Model
s@Model' {} Maybe Text
a -> Model
s {$sel:modelName:Model' :: Maybe Text
modelName = Maybe Text
a} :: Model)

-- | Information required for model metrics.
model_modelMetrics :: Lens.Lens' Model (Prelude.Maybe [EdgeMetric])
model_modelMetrics :: (Maybe [EdgeMetric] -> f (Maybe [EdgeMetric])) -> Model -> f Model
model_modelMetrics = (Model -> Maybe [EdgeMetric])
-> (Model -> Maybe [EdgeMetric] -> Model)
-> Lens Model Model (Maybe [EdgeMetric]) (Maybe [EdgeMetric])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Model' {Maybe [EdgeMetric]
modelMetrics :: Maybe [EdgeMetric]
$sel:modelMetrics:Model' :: Model -> Maybe [EdgeMetric]
modelMetrics} -> Maybe [EdgeMetric]
modelMetrics) (\s :: Model
s@Model' {} Maybe [EdgeMetric]
a -> Model
s {$sel:modelMetrics:Model' :: Maybe [EdgeMetric]
modelMetrics = Maybe [EdgeMetric]
a} :: Model) ((Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
 -> Model -> f Model)
-> ((Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
    -> Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
-> (Maybe [EdgeMetric] -> f (Maybe [EdgeMetric]))
-> Model
-> f Model
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [EdgeMetric] [EdgeMetric] [EdgeMetric] [EdgeMetric]
-> Iso
     (Maybe [EdgeMetric])
     (Maybe [EdgeMetric])
     (Maybe [EdgeMetric])
     (Maybe [EdgeMetric])
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 AnIso [EdgeMetric] [EdgeMetric] [EdgeMetric] [EdgeMetric]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The version of the model.
model_modelVersion :: Lens.Lens' Model (Prelude.Maybe Prelude.Text)
model_modelVersion :: (Maybe Text -> f (Maybe Text)) -> Model -> f Model
model_modelVersion = (Model -> Maybe Text)
-> (Model -> Maybe Text -> Model)
-> Lens Model Model (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Model' {Maybe Text
modelVersion :: Maybe Text
$sel:modelVersion:Model' :: Model -> Maybe Text
modelVersion} -> Maybe Text
modelVersion) (\s :: Model
s@Model' {} Maybe Text
a -> Model
s {$sel:modelVersion:Model' :: Maybe Text
modelVersion = Maybe Text
a} :: Model)

-- | The timestamp of the last inference that was made.
model_latestInference :: Lens.Lens' Model (Prelude.Maybe Prelude.UTCTime)
model_latestInference :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Model -> f Model
model_latestInference = (Model -> Maybe POSIX)
-> (Model -> Maybe POSIX -> Model)
-> Lens Model Model (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Model' {Maybe POSIX
latestInference :: Maybe POSIX
$sel:latestInference:Model' :: Model -> Maybe POSIX
latestInference} -> Maybe POSIX
latestInference) (\s :: Model
s@Model' {} Maybe POSIX
a -> Model
s {$sel:latestInference:Model' :: Maybe POSIX
latestInference = Maybe POSIX
a} :: Model) ((Maybe POSIX -> f (Maybe POSIX)) -> Model -> f Model)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Model
-> f Model
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The timestamp of the last data sample taken.
model_latestSampleTime :: Lens.Lens' Model (Prelude.Maybe Prelude.UTCTime)
model_latestSampleTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Model -> f Model
model_latestSampleTime = (Model -> Maybe POSIX)
-> (Model -> Maybe POSIX -> Model)
-> Lens Model Model (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Model' {Maybe POSIX
latestSampleTime :: Maybe POSIX
$sel:latestSampleTime:Model' :: Model -> Maybe POSIX
latestSampleTime} -> Maybe POSIX
latestSampleTime) (\s :: Model
s@Model' {} Maybe POSIX
a -> Model
s {$sel:latestSampleTime:Model' :: Maybe POSIX
latestSampleTime = Maybe POSIX
a} :: Model) ((Maybe POSIX -> f (Maybe POSIX)) -> Model -> f Model)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Model
-> f Model
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Prelude.Hashable Model

instance Prelude.NFData Model

instance Core.ToJSON Model where
  toJSON :: Model -> Value
toJSON Model' {Maybe [EdgeMetric]
Maybe Text
Maybe POSIX
latestSampleTime :: Maybe POSIX
latestInference :: Maybe POSIX
modelVersion :: Maybe Text
modelMetrics :: Maybe [EdgeMetric]
modelName :: Maybe Text
$sel:latestSampleTime:Model' :: Model -> Maybe POSIX
$sel:latestInference:Model' :: Model -> Maybe POSIX
$sel:modelVersion:Model' :: Model -> Maybe Text
$sel:modelMetrics:Model' :: Model -> Maybe [EdgeMetric]
$sel:modelName:Model' :: Model -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ModelName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
modelName,
            (Text
"ModelMetrics" Text -> [EdgeMetric] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([EdgeMetric] -> Pair) -> Maybe [EdgeMetric] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [EdgeMetric]
modelMetrics,
            (Text
"ModelVersion" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
modelVersion,
            (Text
"LatestInference" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
latestInference,
            (Text
"LatestSampleTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
latestSampleTime
          ]
      )