{-# 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.PredictorExecution
-- 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.PredictorExecution where

import qualified Amazonka.Core as Core
import Amazonka.Forecast.Types.TestWindowSummary
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The algorithm used to perform a backtest and the status of those tests.
--
-- /See:/ 'newPredictorExecution' smart constructor.
data PredictorExecution = PredictorExecution'
  { -- | The ARN of the algorithm used to test the predictor.
    PredictorExecution -> Maybe Text
algorithmArn :: Prelude.Maybe Prelude.Text,
    -- | An array of test windows used to evaluate the algorithm. The
    -- @NumberOfBacktestWindows@ from the object determines the number of
    -- windows in the array.
    PredictorExecution -> Maybe [TestWindowSummary]
testWindows :: Prelude.Maybe [TestWindowSummary]
  }
  deriving (PredictorExecution -> PredictorExecution -> Bool
(PredictorExecution -> PredictorExecution -> Bool)
-> (PredictorExecution -> PredictorExecution -> Bool)
-> Eq PredictorExecution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PredictorExecution -> PredictorExecution -> Bool
$c/= :: PredictorExecution -> PredictorExecution -> Bool
== :: PredictorExecution -> PredictorExecution -> Bool
$c== :: PredictorExecution -> PredictorExecution -> Bool
Prelude.Eq, ReadPrec [PredictorExecution]
ReadPrec PredictorExecution
Int -> ReadS PredictorExecution
ReadS [PredictorExecution]
(Int -> ReadS PredictorExecution)
-> ReadS [PredictorExecution]
-> ReadPrec PredictorExecution
-> ReadPrec [PredictorExecution]
-> Read PredictorExecution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PredictorExecution]
$creadListPrec :: ReadPrec [PredictorExecution]
readPrec :: ReadPrec PredictorExecution
$creadPrec :: ReadPrec PredictorExecution
readList :: ReadS [PredictorExecution]
$creadList :: ReadS [PredictorExecution]
readsPrec :: Int -> ReadS PredictorExecution
$creadsPrec :: Int -> ReadS PredictorExecution
Prelude.Read, Int -> PredictorExecution -> ShowS
[PredictorExecution] -> ShowS
PredictorExecution -> String
(Int -> PredictorExecution -> ShowS)
-> (PredictorExecution -> String)
-> ([PredictorExecution] -> ShowS)
-> Show PredictorExecution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PredictorExecution] -> ShowS
$cshowList :: [PredictorExecution] -> ShowS
show :: PredictorExecution -> String
$cshow :: PredictorExecution -> String
showsPrec :: Int -> PredictorExecution -> ShowS
$cshowsPrec :: Int -> PredictorExecution -> ShowS
Prelude.Show, (forall x. PredictorExecution -> Rep PredictorExecution x)
-> (forall x. Rep PredictorExecution x -> PredictorExecution)
-> Generic PredictorExecution
forall x. Rep PredictorExecution x -> PredictorExecution
forall x. PredictorExecution -> Rep PredictorExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PredictorExecution x -> PredictorExecution
$cfrom :: forall x. PredictorExecution -> Rep PredictorExecution x
Prelude.Generic)

-- |
-- Create a value of 'PredictorExecution' 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:
--
-- 'algorithmArn', 'predictorExecution_algorithmArn' - The ARN of the algorithm used to test the predictor.
--
-- 'testWindows', 'predictorExecution_testWindows' - An array of test windows used to evaluate the algorithm. The
-- @NumberOfBacktestWindows@ from the object determines the number of
-- windows in the array.
newPredictorExecution ::
  PredictorExecution
newPredictorExecution :: PredictorExecution
newPredictorExecution =
  PredictorExecution' :: Maybe Text -> Maybe [TestWindowSummary] -> PredictorExecution
PredictorExecution'
    { $sel:algorithmArn:PredictorExecution' :: Maybe Text
algorithmArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:testWindows:PredictorExecution' :: Maybe [TestWindowSummary]
testWindows = Maybe [TestWindowSummary]
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the algorithm used to test the predictor.
predictorExecution_algorithmArn :: Lens.Lens' PredictorExecution (Prelude.Maybe Prelude.Text)
predictorExecution_algorithmArn :: (Maybe Text -> f (Maybe Text))
-> PredictorExecution -> f PredictorExecution
predictorExecution_algorithmArn = (PredictorExecution -> Maybe Text)
-> (PredictorExecution -> Maybe Text -> PredictorExecution)
-> Lens
     PredictorExecution PredictorExecution (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictorExecution' {Maybe Text
algorithmArn :: Maybe Text
$sel:algorithmArn:PredictorExecution' :: PredictorExecution -> Maybe Text
algorithmArn} -> Maybe Text
algorithmArn) (\s :: PredictorExecution
s@PredictorExecution' {} Maybe Text
a -> PredictorExecution
s {$sel:algorithmArn:PredictorExecution' :: Maybe Text
algorithmArn = Maybe Text
a} :: PredictorExecution)

-- | An array of test windows used to evaluate the algorithm. The
-- @NumberOfBacktestWindows@ from the object determines the number of
-- windows in the array.
predictorExecution_testWindows :: Lens.Lens' PredictorExecution (Prelude.Maybe [TestWindowSummary])
predictorExecution_testWindows :: (Maybe [TestWindowSummary] -> f (Maybe [TestWindowSummary]))
-> PredictorExecution -> f PredictorExecution
predictorExecution_testWindows = (PredictorExecution -> Maybe [TestWindowSummary])
-> (PredictorExecution
    -> Maybe [TestWindowSummary] -> PredictorExecution)
-> Lens
     PredictorExecution
     PredictorExecution
     (Maybe [TestWindowSummary])
     (Maybe [TestWindowSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PredictorExecution' {Maybe [TestWindowSummary]
testWindows :: Maybe [TestWindowSummary]
$sel:testWindows:PredictorExecution' :: PredictorExecution -> Maybe [TestWindowSummary]
testWindows} -> Maybe [TestWindowSummary]
testWindows) (\s :: PredictorExecution
s@PredictorExecution' {} Maybe [TestWindowSummary]
a -> PredictorExecution
s {$sel:testWindows:PredictorExecution' :: Maybe [TestWindowSummary]
testWindows = Maybe [TestWindowSummary]
a} :: PredictorExecution) ((Maybe [TestWindowSummary] -> f (Maybe [TestWindowSummary]))
 -> PredictorExecution -> f PredictorExecution)
-> ((Maybe [TestWindowSummary] -> f (Maybe [TestWindowSummary]))
    -> Maybe [TestWindowSummary] -> f (Maybe [TestWindowSummary]))
-> (Maybe [TestWindowSummary] -> f (Maybe [TestWindowSummary]))
-> PredictorExecution
-> f PredictorExecution
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TestWindowSummary]
  [TestWindowSummary]
  [TestWindowSummary]
  [TestWindowSummary]
-> Iso
     (Maybe [TestWindowSummary])
     (Maybe [TestWindowSummary])
     (Maybe [TestWindowSummary])
     (Maybe [TestWindowSummary])
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
  [TestWindowSummary]
  [TestWindowSummary]
  [TestWindowSummary]
  [TestWindowSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON PredictorExecution where
  parseJSON :: Value -> Parser PredictorExecution
parseJSON =
    String
-> (Object -> Parser PredictorExecution)
-> Value
-> Parser PredictorExecution
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PredictorExecution"
      ( \Object
x ->
          Maybe Text -> Maybe [TestWindowSummary] -> PredictorExecution
PredictorExecution'
            (Maybe Text -> Maybe [TestWindowSummary] -> PredictorExecution)
-> Parser (Maybe Text)
-> Parser (Maybe [TestWindowSummary] -> PredictorExecution)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AlgorithmArn")
            Parser (Maybe [TestWindowSummary] -> PredictorExecution)
-> Parser (Maybe [TestWindowSummary]) -> Parser PredictorExecution
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [TestWindowSummary]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TestWindows" Parser (Maybe (Maybe [TestWindowSummary]))
-> Maybe [TestWindowSummary] -> Parser (Maybe [TestWindowSummary])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [TestWindowSummary]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PredictorExecution

instance Prelude.NFData PredictorExecution