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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The status, start time, and end time of a backtest, as well as a failure
-- reason if applicable.
--
-- /See:/ 'newTestWindowSummary' smart constructor.
data TestWindowSummary = TestWindowSummary'
  { -- | The status of the test. Possible status values are:
    --
    -- -   @ACTIVE@
    --
    -- -   @CREATE_IN_PROGRESS@
    --
    -- -   @CREATE_FAILED@
    TestWindowSummary -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The time at which the test ended.
    TestWindowSummary -> Maybe POSIX
testWindowEnd :: Prelude.Maybe Core.POSIX,
    -- | The time at which the test began.
    TestWindowSummary -> Maybe POSIX
testWindowStart :: Prelude.Maybe Core.POSIX,
    -- | If the test failed, the reason why it failed.
    TestWindowSummary -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (TestWindowSummary -> TestWindowSummary -> Bool
(TestWindowSummary -> TestWindowSummary -> Bool)
-> (TestWindowSummary -> TestWindowSummary -> Bool)
-> Eq TestWindowSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TestWindowSummary -> TestWindowSummary -> Bool
$c/= :: TestWindowSummary -> TestWindowSummary -> Bool
== :: TestWindowSummary -> TestWindowSummary -> Bool
$c== :: TestWindowSummary -> TestWindowSummary -> Bool
Prelude.Eq, ReadPrec [TestWindowSummary]
ReadPrec TestWindowSummary
Int -> ReadS TestWindowSummary
ReadS [TestWindowSummary]
(Int -> ReadS TestWindowSummary)
-> ReadS [TestWindowSummary]
-> ReadPrec TestWindowSummary
-> ReadPrec [TestWindowSummary]
-> Read TestWindowSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TestWindowSummary]
$creadListPrec :: ReadPrec [TestWindowSummary]
readPrec :: ReadPrec TestWindowSummary
$creadPrec :: ReadPrec TestWindowSummary
readList :: ReadS [TestWindowSummary]
$creadList :: ReadS [TestWindowSummary]
readsPrec :: Int -> ReadS TestWindowSummary
$creadsPrec :: Int -> ReadS TestWindowSummary
Prelude.Read, Int -> TestWindowSummary -> ShowS
[TestWindowSummary] -> ShowS
TestWindowSummary -> String
(Int -> TestWindowSummary -> ShowS)
-> (TestWindowSummary -> String)
-> ([TestWindowSummary] -> ShowS)
-> Show TestWindowSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TestWindowSummary] -> ShowS
$cshowList :: [TestWindowSummary] -> ShowS
show :: TestWindowSummary -> String
$cshow :: TestWindowSummary -> String
showsPrec :: Int -> TestWindowSummary -> ShowS
$cshowsPrec :: Int -> TestWindowSummary -> ShowS
Prelude.Show, (forall x. TestWindowSummary -> Rep TestWindowSummary x)
-> (forall x. Rep TestWindowSummary x -> TestWindowSummary)
-> Generic TestWindowSummary
forall x. Rep TestWindowSummary x -> TestWindowSummary
forall x. TestWindowSummary -> Rep TestWindowSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TestWindowSummary x -> TestWindowSummary
$cfrom :: forall x. TestWindowSummary -> Rep TestWindowSummary x
Prelude.Generic)

-- |
-- Create a value of 'TestWindowSummary' 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:
--
-- 'status', 'testWindowSummary_status' - The status of the test. Possible status values are:
--
-- -   @ACTIVE@
--
-- -   @CREATE_IN_PROGRESS@
--
-- -   @CREATE_FAILED@
--
-- 'testWindowEnd', 'testWindowSummary_testWindowEnd' - The time at which the test ended.
--
-- 'testWindowStart', 'testWindowSummary_testWindowStart' - The time at which the test began.
--
-- 'message', 'testWindowSummary_message' - If the test failed, the reason why it failed.
newTestWindowSummary ::
  TestWindowSummary
newTestWindowSummary :: TestWindowSummary
newTestWindowSummary =
  TestWindowSummary' :: Maybe Text
-> Maybe POSIX -> Maybe POSIX -> Maybe Text -> TestWindowSummary
TestWindowSummary'
    { $sel:status:TestWindowSummary' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:testWindowEnd:TestWindowSummary' :: Maybe POSIX
testWindowEnd = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:testWindowStart:TestWindowSummary' :: Maybe POSIX
testWindowStart = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:message:TestWindowSummary' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the test. Possible status values are:
--
-- -   @ACTIVE@
--
-- -   @CREATE_IN_PROGRESS@
--
-- -   @CREATE_FAILED@
testWindowSummary_status :: Lens.Lens' TestWindowSummary (Prelude.Maybe Prelude.Text)
testWindowSummary_status :: (Maybe Text -> f (Maybe Text))
-> TestWindowSummary -> f TestWindowSummary
testWindowSummary_status = (TestWindowSummary -> Maybe Text)
-> (TestWindowSummary -> Maybe Text -> TestWindowSummary)
-> Lens
     TestWindowSummary TestWindowSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestWindowSummary' {Maybe Text
status :: Maybe Text
$sel:status:TestWindowSummary' :: TestWindowSummary -> Maybe Text
status} -> Maybe Text
status) (\s :: TestWindowSummary
s@TestWindowSummary' {} Maybe Text
a -> TestWindowSummary
s {$sel:status:TestWindowSummary' :: Maybe Text
status = Maybe Text
a} :: TestWindowSummary)

-- | The time at which the test ended.
testWindowSummary_testWindowEnd :: Lens.Lens' TestWindowSummary (Prelude.Maybe Prelude.UTCTime)
testWindowSummary_testWindowEnd :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TestWindowSummary -> f TestWindowSummary
testWindowSummary_testWindowEnd = (TestWindowSummary -> Maybe POSIX)
-> (TestWindowSummary -> Maybe POSIX -> TestWindowSummary)
-> Lens
     TestWindowSummary TestWindowSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestWindowSummary' {Maybe POSIX
testWindowEnd :: Maybe POSIX
$sel:testWindowEnd:TestWindowSummary' :: TestWindowSummary -> Maybe POSIX
testWindowEnd} -> Maybe POSIX
testWindowEnd) (\s :: TestWindowSummary
s@TestWindowSummary' {} Maybe POSIX
a -> TestWindowSummary
s {$sel:testWindowEnd:TestWindowSummary' :: Maybe POSIX
testWindowEnd = Maybe POSIX
a} :: TestWindowSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> TestWindowSummary -> f TestWindowSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TestWindowSummary
-> f TestWindowSummary
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 time at which the test began.
testWindowSummary_testWindowStart :: Lens.Lens' TestWindowSummary (Prelude.Maybe Prelude.UTCTime)
testWindowSummary_testWindowStart :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TestWindowSummary -> f TestWindowSummary
testWindowSummary_testWindowStart = (TestWindowSummary -> Maybe POSIX)
-> (TestWindowSummary -> Maybe POSIX -> TestWindowSummary)
-> Lens
     TestWindowSummary TestWindowSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestWindowSummary' {Maybe POSIX
testWindowStart :: Maybe POSIX
$sel:testWindowStart:TestWindowSummary' :: TestWindowSummary -> Maybe POSIX
testWindowStart} -> Maybe POSIX
testWindowStart) (\s :: TestWindowSummary
s@TestWindowSummary' {} Maybe POSIX
a -> TestWindowSummary
s {$sel:testWindowStart:TestWindowSummary' :: Maybe POSIX
testWindowStart = Maybe POSIX
a} :: TestWindowSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> TestWindowSummary -> f TestWindowSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TestWindowSummary
-> f TestWindowSummary
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

-- | If the test failed, the reason why it failed.
testWindowSummary_message :: Lens.Lens' TestWindowSummary (Prelude.Maybe Prelude.Text)
testWindowSummary_message :: (Maybe Text -> f (Maybe Text))
-> TestWindowSummary -> f TestWindowSummary
testWindowSummary_message = (TestWindowSummary -> Maybe Text)
-> (TestWindowSummary -> Maybe Text -> TestWindowSummary)
-> Lens
     TestWindowSummary TestWindowSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TestWindowSummary' {Maybe Text
message :: Maybe Text
$sel:message:TestWindowSummary' :: TestWindowSummary -> Maybe Text
message} -> Maybe Text
message) (\s :: TestWindowSummary
s@TestWindowSummary' {} Maybe Text
a -> TestWindowSummary
s {$sel:message:TestWindowSummary' :: Maybe Text
message = Maybe Text
a} :: TestWindowSummary)

instance Core.FromJSON TestWindowSummary where
  parseJSON :: Value -> Parser TestWindowSummary
parseJSON =
    String
-> (Object -> Parser TestWindowSummary)
-> Value
-> Parser TestWindowSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TestWindowSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX -> Maybe POSIX -> Maybe Text -> TestWindowSummary
TestWindowSummary'
            (Maybe Text
 -> Maybe POSIX -> Maybe POSIX -> Maybe Text -> TestWindowSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX -> Maybe POSIX -> Maybe Text -> TestWindowSummary)
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
"Status")
            Parser
  (Maybe POSIX -> Maybe POSIX -> Maybe Text -> TestWindowSummary)
-> Parser (Maybe POSIX)
-> Parser (Maybe POSIX -> Maybe Text -> TestWindowSummary)
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 POSIX -> Maybe Text -> TestWindowSummary)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> TestWindowSummary)
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 Text -> TestWindowSummary)
-> Parser (Maybe Text) -> Parser TestWindowSummary
forall (f :: * -> *) a b. Applicative f => 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
"Message")
      )

instance Prelude.Hashable TestWindowSummary

instance Prelude.NFData TestWindowSummary