{-# 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.LookoutMetrics.Types.ExecutionStatus
-- 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.LookoutMetrics.Types.ExecutionStatus where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types.AnomalyDetectionTaskStatus
import qualified Amazonka.Prelude as Prelude

-- | The status of an anomaly detector run.
--
-- /See:/ 'newExecutionStatus' smart constructor.
data ExecutionStatus = ExecutionStatus'
  { -- | The run\'s status.
    ExecutionStatus -> Maybe AnomalyDetectionTaskStatus
status :: Prelude.Maybe AnomalyDetectionTaskStatus,
    -- | The reason that the run failed, if applicable.
    ExecutionStatus -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | The run\'s timestamp.
    ExecutionStatus -> Maybe Text
timestamp :: Prelude.Maybe Prelude.Text
  }
  deriving (ExecutionStatus -> ExecutionStatus -> Bool
(ExecutionStatus -> ExecutionStatus -> Bool)
-> (ExecutionStatus -> ExecutionStatus -> Bool)
-> Eq ExecutionStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionStatus -> ExecutionStatus -> Bool
$c/= :: ExecutionStatus -> ExecutionStatus -> Bool
== :: ExecutionStatus -> ExecutionStatus -> Bool
$c== :: ExecutionStatus -> ExecutionStatus -> Bool
Prelude.Eq, ReadPrec [ExecutionStatus]
ReadPrec ExecutionStatus
Int -> ReadS ExecutionStatus
ReadS [ExecutionStatus]
(Int -> ReadS ExecutionStatus)
-> ReadS [ExecutionStatus]
-> ReadPrec ExecutionStatus
-> ReadPrec [ExecutionStatus]
-> Read ExecutionStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionStatus]
$creadListPrec :: ReadPrec [ExecutionStatus]
readPrec :: ReadPrec ExecutionStatus
$creadPrec :: ReadPrec ExecutionStatus
readList :: ReadS [ExecutionStatus]
$creadList :: ReadS [ExecutionStatus]
readsPrec :: Int -> ReadS ExecutionStatus
$creadsPrec :: Int -> ReadS ExecutionStatus
Prelude.Read, Int -> ExecutionStatus -> ShowS
[ExecutionStatus] -> ShowS
ExecutionStatus -> String
(Int -> ExecutionStatus -> ShowS)
-> (ExecutionStatus -> String)
-> ([ExecutionStatus] -> ShowS)
-> Show ExecutionStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionStatus] -> ShowS
$cshowList :: [ExecutionStatus] -> ShowS
show :: ExecutionStatus -> String
$cshow :: ExecutionStatus -> String
showsPrec :: Int -> ExecutionStatus -> ShowS
$cshowsPrec :: Int -> ExecutionStatus -> ShowS
Prelude.Show, (forall x. ExecutionStatus -> Rep ExecutionStatus x)
-> (forall x. Rep ExecutionStatus x -> ExecutionStatus)
-> Generic ExecutionStatus
forall x. Rep ExecutionStatus x -> ExecutionStatus
forall x. ExecutionStatus -> Rep ExecutionStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionStatus x -> ExecutionStatus
$cfrom :: forall x. ExecutionStatus -> Rep ExecutionStatus x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionStatus' 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', 'executionStatus_status' - The run\'s status.
--
-- 'failureReason', 'executionStatus_failureReason' - The reason that the run failed, if applicable.
--
-- 'timestamp', 'executionStatus_timestamp' - The run\'s timestamp.
newExecutionStatus ::
  ExecutionStatus
newExecutionStatus :: ExecutionStatus
newExecutionStatus =
  ExecutionStatus' :: Maybe AnomalyDetectionTaskStatus
-> Maybe Text -> Maybe Text -> ExecutionStatus
ExecutionStatus'
    { $sel:status:ExecutionStatus' :: Maybe AnomalyDetectionTaskStatus
status = Maybe AnomalyDetectionTaskStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:failureReason:ExecutionStatus' :: Maybe Text
failureReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:ExecutionStatus' :: Maybe Text
timestamp = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The run\'s status.
executionStatus_status :: Lens.Lens' ExecutionStatus (Prelude.Maybe AnomalyDetectionTaskStatus)
executionStatus_status :: (Maybe AnomalyDetectionTaskStatus
 -> f (Maybe AnomalyDetectionTaskStatus))
-> ExecutionStatus -> f ExecutionStatus
executionStatus_status = (ExecutionStatus -> Maybe AnomalyDetectionTaskStatus)
-> (ExecutionStatus
    -> Maybe AnomalyDetectionTaskStatus -> ExecutionStatus)
-> Lens
     ExecutionStatus
     ExecutionStatus
     (Maybe AnomalyDetectionTaskStatus)
     (Maybe AnomalyDetectionTaskStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionStatus' {Maybe AnomalyDetectionTaskStatus
status :: Maybe AnomalyDetectionTaskStatus
$sel:status:ExecutionStatus' :: ExecutionStatus -> Maybe AnomalyDetectionTaskStatus
status} -> Maybe AnomalyDetectionTaskStatus
status) (\s :: ExecutionStatus
s@ExecutionStatus' {} Maybe AnomalyDetectionTaskStatus
a -> ExecutionStatus
s {$sel:status:ExecutionStatus' :: Maybe AnomalyDetectionTaskStatus
status = Maybe AnomalyDetectionTaskStatus
a} :: ExecutionStatus)

-- | The reason that the run failed, if applicable.
executionStatus_failureReason :: Lens.Lens' ExecutionStatus (Prelude.Maybe Prelude.Text)
executionStatus_failureReason :: (Maybe Text -> f (Maybe Text))
-> ExecutionStatus -> f ExecutionStatus
executionStatus_failureReason = (ExecutionStatus -> Maybe Text)
-> (ExecutionStatus -> Maybe Text -> ExecutionStatus)
-> Lens ExecutionStatus ExecutionStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionStatus' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:ExecutionStatus' :: ExecutionStatus -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: ExecutionStatus
s@ExecutionStatus' {} Maybe Text
a -> ExecutionStatus
s {$sel:failureReason:ExecutionStatus' :: Maybe Text
failureReason = Maybe Text
a} :: ExecutionStatus)

-- | The run\'s timestamp.
executionStatus_timestamp :: Lens.Lens' ExecutionStatus (Prelude.Maybe Prelude.Text)
executionStatus_timestamp :: (Maybe Text -> f (Maybe Text))
-> ExecutionStatus -> f ExecutionStatus
executionStatus_timestamp = (ExecutionStatus -> Maybe Text)
-> (ExecutionStatus -> Maybe Text -> ExecutionStatus)
-> Lens ExecutionStatus ExecutionStatus (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionStatus' {Maybe Text
timestamp :: Maybe Text
$sel:timestamp:ExecutionStatus' :: ExecutionStatus -> Maybe Text
timestamp} -> Maybe Text
timestamp) (\s :: ExecutionStatus
s@ExecutionStatus' {} Maybe Text
a -> ExecutionStatus
s {$sel:timestamp:ExecutionStatus' :: Maybe Text
timestamp = Maybe Text
a} :: ExecutionStatus)

instance Core.FromJSON ExecutionStatus where
  parseJSON :: Value -> Parser ExecutionStatus
parseJSON =
    String
-> (Object -> Parser ExecutionStatus)
-> Value
-> Parser ExecutionStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecutionStatus"
      ( \Object
x ->
          Maybe AnomalyDetectionTaskStatus
-> Maybe Text -> Maybe Text -> ExecutionStatus
ExecutionStatus'
            (Maybe AnomalyDetectionTaskStatus
 -> Maybe Text -> Maybe Text -> ExecutionStatus)
-> Parser (Maybe AnomalyDetectionTaskStatus)
-> Parser (Maybe Text -> Maybe Text -> ExecutionStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AnomalyDetectionTaskStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser (Maybe Text -> Maybe Text -> ExecutionStatus)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ExecutionStatus)
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
"FailureReason")
            Parser (Maybe Text -> ExecutionStatus)
-> Parser (Maybe Text) -> Parser ExecutionStatus
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
"Timestamp")
      )

instance Prelude.Hashable ExecutionStatus

instance Prelude.NFData ExecutionStatus