{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Forecast.Types.PredictorExecution where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Forecast.Types.TestWindowSummary
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
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]
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
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. 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'
    { $sel:algorithmArn:PredictorExecution' :: Maybe Text
algorithmArn = forall a. Maybe a
Prelude.Nothing,
      $sel:testWindows:PredictorExecution' :: Maybe [TestWindowSummary]
testWindows = 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 :: Lens' PredictorExecution (Maybe Text)
predictorExecution_algorithmArn = 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 :: Lens' PredictorExecution (Maybe [TestWindowSummary])
predictorExecution_testWindows = 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) 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 PredictorExecution where
  parseJSON :: Value -> Parser PredictorExecution
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PredictorExecution"
      ( \Object
x ->
          Maybe Text -> Maybe [TestWindowSummary] -> PredictorExecution
PredictorExecution'
            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
"AlgorithmArn")
            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
"TestWindows" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable PredictorExecution where
  hashWithSalt :: Int -> PredictorExecution -> Int
hashWithSalt Int
_salt PredictorExecution' {Maybe [TestWindowSummary]
Maybe Text
testWindows :: Maybe [TestWindowSummary]
algorithmArn :: Maybe Text
$sel:testWindows:PredictorExecution' :: PredictorExecution -> Maybe [TestWindowSummary]
$sel:algorithmArn:PredictorExecution' :: PredictorExecution -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
algorithmArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TestWindowSummary]
testWindows

instance Prelude.NFData PredictorExecution where
  rnf :: PredictorExecution -> ()
rnf PredictorExecution' {Maybe [TestWindowSummary]
Maybe Text
testWindows :: Maybe [TestWindowSummary]
algorithmArn :: Maybe Text
$sel:testWindows:PredictorExecution' :: PredictorExecution -> Maybe [TestWindowSummary]
$sel:algorithmArn:PredictorExecution' :: PredictorExecution -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
algorithmArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TestWindowSummary]
testWindows