{-# 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.Forecast.Types.WindowSummary
-- 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.Forecast.Types.WindowSummary where

import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types.EvaluationType
import Amazonka.Forecast.Types.Metrics
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The metrics for a time range within the evaluation portion of a dataset.
-- This object is part of the EvaluationResult object.
--
-- The @TestWindowStart@ and @TestWindowEnd@ parameters are determined by
-- the @BackTestWindowOffset@ parameter of the EvaluationParameters object.
--
-- /See:/ 'newWindowSummary' smart constructor.
data WindowSummary = WindowSummary'
  { -- | Provides metrics used to evaluate the performance of a predictor.
    WindowSummary -> Maybe Metrics
metrics :: Prelude.Maybe Metrics,
    -- | The timestamp that defines the end of the window.
    WindowSummary -> Maybe POSIX
testWindowEnd :: Prelude.Maybe Core.POSIX,
    -- | The type of evaluation.
    --
    -- -   @SUMMARY@ - The average metrics across all windows.
    --
    -- -   @COMPUTED@ - The metrics for the specified window.
    WindowSummary -> Maybe EvaluationType
evaluationType :: Prelude.Maybe EvaluationType,
    -- | The timestamp that defines the start of the window.
    WindowSummary -> Maybe POSIX
testWindowStart :: Prelude.Maybe Core.POSIX,
    -- | The number of data points within the window.
    WindowSummary -> Maybe Int
itemCount :: Prelude.Maybe Prelude.Int
  }
  deriving (WindowSummary -> WindowSummary -> Bool
(WindowSummary -> WindowSummary -> Bool)
-> (WindowSummary -> WindowSummary -> Bool) -> Eq WindowSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WindowSummary -> WindowSummary -> Bool
$c/= :: WindowSummary -> WindowSummary -> Bool
== :: WindowSummary -> WindowSummary -> Bool
$c== :: WindowSummary -> WindowSummary -> Bool
Prelude.Eq, ReadPrec [WindowSummary]
ReadPrec WindowSummary
Int -> ReadS WindowSummary
ReadS [WindowSummary]
(Int -> ReadS WindowSummary)
-> ReadS [WindowSummary]
-> ReadPrec WindowSummary
-> ReadPrec [WindowSummary]
-> Read WindowSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WindowSummary]
$creadListPrec :: ReadPrec [WindowSummary]
readPrec :: ReadPrec WindowSummary
$creadPrec :: ReadPrec WindowSummary
readList :: ReadS [WindowSummary]
$creadList :: ReadS [WindowSummary]
readsPrec :: Int -> ReadS WindowSummary
$creadsPrec :: Int -> ReadS WindowSummary
Prelude.Read, Int -> WindowSummary -> ShowS
[WindowSummary] -> ShowS
WindowSummary -> String
(Int -> WindowSummary -> ShowS)
-> (WindowSummary -> String)
-> ([WindowSummary] -> ShowS)
-> Show WindowSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WindowSummary] -> ShowS
$cshowList :: [WindowSummary] -> ShowS
show :: WindowSummary -> String
$cshow :: WindowSummary -> String
showsPrec :: Int -> WindowSummary -> ShowS
$cshowsPrec :: Int -> WindowSummary -> ShowS
Prelude.Show, (forall x. WindowSummary -> Rep WindowSummary x)
-> (forall x. Rep WindowSummary x -> WindowSummary)
-> Generic WindowSummary
forall x. Rep WindowSummary x -> WindowSummary
forall x. WindowSummary -> Rep WindowSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WindowSummary x -> WindowSummary
$cfrom :: forall x. WindowSummary -> Rep WindowSummary x
Prelude.Generic)

-- |
-- Create a value of 'WindowSummary' 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:
--
-- 'metrics', 'windowSummary_metrics' - Provides metrics used to evaluate the performance of a predictor.
--
-- 'testWindowEnd', 'windowSummary_testWindowEnd' - The timestamp that defines the end of the window.
--
-- 'evaluationType', 'windowSummary_evaluationType' - The type of evaluation.
--
-- -   @SUMMARY@ - The average metrics across all windows.
--
-- -   @COMPUTED@ - The metrics for the specified window.
--
-- 'testWindowStart', 'windowSummary_testWindowStart' - The timestamp that defines the start of the window.
--
-- 'itemCount', 'windowSummary_itemCount' - The number of data points within the window.
newWindowSummary ::
  WindowSummary
newWindowSummary :: WindowSummary
newWindowSummary =
  WindowSummary' :: Maybe Metrics
-> Maybe POSIX
-> Maybe EvaluationType
-> Maybe POSIX
-> Maybe Int
-> WindowSummary
WindowSummary'
    { $sel:metrics:WindowSummary' :: Maybe Metrics
metrics = Maybe Metrics
forall a. Maybe a
Prelude.Nothing,
      $sel:testWindowEnd:WindowSummary' :: Maybe POSIX
testWindowEnd = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:evaluationType:WindowSummary' :: Maybe EvaluationType
evaluationType = Maybe EvaluationType
forall a. Maybe a
Prelude.Nothing,
      $sel:testWindowStart:WindowSummary' :: Maybe POSIX
testWindowStart = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:itemCount:WindowSummary' :: Maybe Int
itemCount = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Provides metrics used to evaluate the performance of a predictor.
windowSummary_metrics :: Lens.Lens' WindowSummary (Prelude.Maybe Metrics)
windowSummary_metrics :: (Maybe Metrics -> f (Maybe Metrics))
-> WindowSummary -> f WindowSummary
windowSummary_metrics = (WindowSummary -> Maybe Metrics)
-> (WindowSummary -> Maybe Metrics -> WindowSummary)
-> Lens WindowSummary WindowSummary (Maybe Metrics) (Maybe Metrics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe Metrics
metrics :: Maybe Metrics
$sel:metrics:WindowSummary' :: WindowSummary -> Maybe Metrics
metrics} -> Maybe Metrics
metrics) (\s :: WindowSummary
s@WindowSummary' {} Maybe Metrics
a -> WindowSummary
s {$sel:metrics:WindowSummary' :: Maybe Metrics
metrics = Maybe Metrics
a} :: WindowSummary)

-- | The timestamp that defines the end of the window.
windowSummary_testWindowEnd :: Lens.Lens' WindowSummary (Prelude.Maybe Prelude.UTCTime)
windowSummary_testWindowEnd :: (Maybe UTCTime -> f (Maybe UTCTime))
-> WindowSummary -> f WindowSummary
windowSummary_testWindowEnd = (WindowSummary -> Maybe POSIX)
-> (WindowSummary -> Maybe POSIX -> WindowSummary)
-> Lens WindowSummary WindowSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe POSIX
testWindowEnd :: Maybe POSIX
$sel:testWindowEnd:WindowSummary' :: WindowSummary -> Maybe POSIX
testWindowEnd} -> Maybe POSIX
testWindowEnd) (\s :: WindowSummary
s@WindowSummary' {} Maybe POSIX
a -> WindowSummary
s {$sel:testWindowEnd:WindowSummary' :: Maybe POSIX
testWindowEnd = Maybe POSIX
a} :: WindowSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> WindowSummary -> f WindowSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> WindowSummary
-> f WindowSummary
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 type of evaluation.
--
-- -   @SUMMARY@ - The average metrics across all windows.
--
-- -   @COMPUTED@ - The metrics for the specified window.
windowSummary_evaluationType :: Lens.Lens' WindowSummary (Prelude.Maybe EvaluationType)
windowSummary_evaluationType :: (Maybe EvaluationType -> f (Maybe EvaluationType))
-> WindowSummary -> f WindowSummary
windowSummary_evaluationType = (WindowSummary -> Maybe EvaluationType)
-> (WindowSummary -> Maybe EvaluationType -> WindowSummary)
-> Lens
     WindowSummary
     WindowSummary
     (Maybe EvaluationType)
     (Maybe EvaluationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe EvaluationType
evaluationType :: Maybe EvaluationType
$sel:evaluationType:WindowSummary' :: WindowSummary -> Maybe EvaluationType
evaluationType} -> Maybe EvaluationType
evaluationType) (\s :: WindowSummary
s@WindowSummary' {} Maybe EvaluationType
a -> WindowSummary
s {$sel:evaluationType:WindowSummary' :: Maybe EvaluationType
evaluationType = Maybe EvaluationType
a} :: WindowSummary)

-- | The timestamp that defines the start of the window.
windowSummary_testWindowStart :: Lens.Lens' WindowSummary (Prelude.Maybe Prelude.UTCTime)
windowSummary_testWindowStart :: (Maybe UTCTime -> f (Maybe UTCTime))
-> WindowSummary -> f WindowSummary
windowSummary_testWindowStart = (WindowSummary -> Maybe POSIX)
-> (WindowSummary -> Maybe POSIX -> WindowSummary)
-> Lens WindowSummary WindowSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe POSIX
testWindowStart :: Maybe POSIX
$sel:testWindowStart:WindowSummary' :: WindowSummary -> Maybe POSIX
testWindowStart} -> Maybe POSIX
testWindowStart) (\s :: WindowSummary
s@WindowSummary' {} Maybe POSIX
a -> WindowSummary
s {$sel:testWindowStart:WindowSummary' :: Maybe POSIX
testWindowStart = Maybe POSIX
a} :: WindowSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> WindowSummary -> f WindowSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> WindowSummary
-> f WindowSummary
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 number of data points within the window.
windowSummary_itemCount :: Lens.Lens' WindowSummary (Prelude.Maybe Prelude.Int)
windowSummary_itemCount :: (Maybe Int -> f (Maybe Int)) -> WindowSummary -> f WindowSummary
windowSummary_itemCount = (WindowSummary -> Maybe Int)
-> (WindowSummary -> Maybe Int -> WindowSummary)
-> Lens WindowSummary WindowSummary (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WindowSummary' {Maybe Int
itemCount :: Maybe Int
$sel:itemCount:WindowSummary' :: WindowSummary -> Maybe Int
itemCount} -> Maybe Int
itemCount) (\s :: WindowSummary
s@WindowSummary' {} Maybe Int
a -> WindowSummary
s {$sel:itemCount:WindowSummary' :: Maybe Int
itemCount = Maybe Int
a} :: WindowSummary)

instance Core.FromJSON WindowSummary where
  parseJSON :: Value -> Parser WindowSummary
parseJSON =
    String
-> (Object -> Parser WindowSummary)
-> Value
-> Parser WindowSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"WindowSummary"
      ( \Object
x ->
          Maybe Metrics
-> Maybe POSIX
-> Maybe EvaluationType
-> Maybe POSIX
-> Maybe Int
-> WindowSummary
WindowSummary'
            (Maybe Metrics
 -> Maybe POSIX
 -> Maybe EvaluationType
 -> Maybe POSIX
 -> Maybe Int
 -> WindowSummary)
-> Parser (Maybe Metrics)
-> Parser
     (Maybe POSIX
      -> Maybe EvaluationType
      -> Maybe POSIX
      -> Maybe Int
      -> WindowSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Metrics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Metrics")
            Parser
  (Maybe POSIX
   -> Maybe EvaluationType
   -> Maybe POSIX
   -> Maybe Int
   -> WindowSummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe EvaluationType -> Maybe POSIX -> Maybe Int -> WindowSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TestWindowEnd")
            Parser
  (Maybe EvaluationType -> Maybe POSIX -> Maybe Int -> WindowSummary)
-> Parser (Maybe EvaluationType)
-> Parser (Maybe POSIX -> Maybe Int -> WindowSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EvaluationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EvaluationType")
            Parser (Maybe POSIX -> Maybe Int -> WindowSummary)
-> Parser (Maybe POSIX) -> Parser (Maybe Int -> WindowSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TestWindowStart")
            Parser (Maybe Int -> WindowSummary)
-> Parser (Maybe Int) -> Parser WindowSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ItemCount")
      )

instance Prelude.Hashable WindowSummary

instance Prelude.NFData WindowSummary