{-# 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.TimeStreamQuery.Types.ScheduledQueryRunSummary
-- 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.TimeStreamQuery.Types.ScheduledQueryRunSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.TimeStreamQuery.Types.ErrorReportLocation
import Amazonka.TimeStreamQuery.Types.ExecutionStats
import Amazonka.TimeStreamQuery.Types.ScheduledQueryRunStatus

-- | Run summary for the scheduled query
--
-- /See:/ 'newScheduledQueryRunSummary' smart constructor.
data ScheduledQueryRunSummary = ScheduledQueryRunSummary'
  { -- | S3 location for error report.
    ScheduledQueryRunSummary -> Maybe ErrorReportLocation
errorReportLocation :: Prelude.Maybe ErrorReportLocation,
    -- | Runtime statistics for a scheduled run.
    ScheduledQueryRunSummary -> Maybe ExecutionStats
executionStats :: Prelude.Maybe ExecutionStats,
    -- | Error message for the scheduled query in case of failure. You might have
    -- to look at the error report to get more detailed error reasons.
    ScheduledQueryRunSummary -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | InvocationTime for this run. This is the time at which the query is
    -- scheduled to run. Parameter @\@scheduled_runtime@ can be used in the
    -- query to get the value.
    ScheduledQueryRunSummary -> Maybe POSIX
invocationTime :: Prelude.Maybe Data.POSIX,
    -- | The status of a scheduled query run.
    ScheduledQueryRunSummary -> Maybe ScheduledQueryRunStatus
runStatus :: Prelude.Maybe ScheduledQueryRunStatus,
    -- | The actual time when the query was run.
    ScheduledQueryRunSummary -> Maybe POSIX
triggerTime :: Prelude.Maybe Data.POSIX
  }
  deriving (ScheduledQueryRunSummary -> ScheduledQueryRunSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduledQueryRunSummary -> ScheduledQueryRunSummary -> Bool
$c/= :: ScheduledQueryRunSummary -> ScheduledQueryRunSummary -> Bool
== :: ScheduledQueryRunSummary -> ScheduledQueryRunSummary -> Bool
$c== :: ScheduledQueryRunSummary -> ScheduledQueryRunSummary -> Bool
Prelude.Eq, ReadPrec [ScheduledQueryRunSummary]
ReadPrec ScheduledQueryRunSummary
Int -> ReadS ScheduledQueryRunSummary
ReadS [ScheduledQueryRunSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduledQueryRunSummary]
$creadListPrec :: ReadPrec [ScheduledQueryRunSummary]
readPrec :: ReadPrec ScheduledQueryRunSummary
$creadPrec :: ReadPrec ScheduledQueryRunSummary
readList :: ReadS [ScheduledQueryRunSummary]
$creadList :: ReadS [ScheduledQueryRunSummary]
readsPrec :: Int -> ReadS ScheduledQueryRunSummary
$creadsPrec :: Int -> ReadS ScheduledQueryRunSummary
Prelude.Read, Int -> ScheduledQueryRunSummary -> ShowS
[ScheduledQueryRunSummary] -> ShowS
ScheduledQueryRunSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduledQueryRunSummary] -> ShowS
$cshowList :: [ScheduledQueryRunSummary] -> ShowS
show :: ScheduledQueryRunSummary -> String
$cshow :: ScheduledQueryRunSummary -> String
showsPrec :: Int -> ScheduledQueryRunSummary -> ShowS
$cshowsPrec :: Int -> ScheduledQueryRunSummary -> ShowS
Prelude.Show, forall x.
Rep ScheduledQueryRunSummary x -> ScheduledQueryRunSummary
forall x.
ScheduledQueryRunSummary -> Rep ScheduledQueryRunSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ScheduledQueryRunSummary x -> ScheduledQueryRunSummary
$cfrom :: forall x.
ScheduledQueryRunSummary -> Rep ScheduledQueryRunSummary x
Prelude.Generic)

-- |
-- Create a value of 'ScheduledQueryRunSummary' 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:
--
-- 'errorReportLocation', 'scheduledQueryRunSummary_errorReportLocation' - S3 location for error report.
--
-- 'executionStats', 'scheduledQueryRunSummary_executionStats' - Runtime statistics for a scheduled run.
--
-- 'failureReason', 'scheduledQueryRunSummary_failureReason' - Error message for the scheduled query in case of failure. You might have
-- to look at the error report to get more detailed error reasons.
--
-- 'invocationTime', 'scheduledQueryRunSummary_invocationTime' - InvocationTime for this run. This is the time at which the query is
-- scheduled to run. Parameter @\@scheduled_runtime@ can be used in the
-- query to get the value.
--
-- 'runStatus', 'scheduledQueryRunSummary_runStatus' - The status of a scheduled query run.
--
-- 'triggerTime', 'scheduledQueryRunSummary_triggerTime' - The actual time when the query was run.
newScheduledQueryRunSummary ::
  ScheduledQueryRunSummary
newScheduledQueryRunSummary :: ScheduledQueryRunSummary
newScheduledQueryRunSummary =
  ScheduledQueryRunSummary'
    { $sel:errorReportLocation:ScheduledQueryRunSummary' :: Maybe ErrorReportLocation
errorReportLocation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:executionStats:ScheduledQueryRunSummary' :: Maybe ExecutionStats
executionStats = forall a. Maybe a
Prelude.Nothing,
      $sel:failureReason:ScheduledQueryRunSummary' :: Maybe Text
failureReason = forall a. Maybe a
Prelude.Nothing,
      $sel:invocationTime:ScheduledQueryRunSummary' :: Maybe POSIX
invocationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:runStatus:ScheduledQueryRunSummary' :: Maybe ScheduledQueryRunStatus
runStatus = forall a. Maybe a
Prelude.Nothing,
      $sel:triggerTime:ScheduledQueryRunSummary' :: Maybe POSIX
triggerTime = forall a. Maybe a
Prelude.Nothing
    }

-- | S3 location for error report.
scheduledQueryRunSummary_errorReportLocation :: Lens.Lens' ScheduledQueryRunSummary (Prelude.Maybe ErrorReportLocation)
scheduledQueryRunSummary_errorReportLocation :: Lens' ScheduledQueryRunSummary (Maybe ErrorReportLocation)
scheduledQueryRunSummary_errorReportLocation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledQueryRunSummary' {Maybe ErrorReportLocation
errorReportLocation :: Maybe ErrorReportLocation
$sel:errorReportLocation:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ErrorReportLocation
errorReportLocation} -> Maybe ErrorReportLocation
errorReportLocation) (\s :: ScheduledQueryRunSummary
s@ScheduledQueryRunSummary' {} Maybe ErrorReportLocation
a -> ScheduledQueryRunSummary
s {$sel:errorReportLocation:ScheduledQueryRunSummary' :: Maybe ErrorReportLocation
errorReportLocation = Maybe ErrorReportLocation
a} :: ScheduledQueryRunSummary)

-- | Runtime statistics for a scheduled run.
scheduledQueryRunSummary_executionStats :: Lens.Lens' ScheduledQueryRunSummary (Prelude.Maybe ExecutionStats)
scheduledQueryRunSummary_executionStats :: Lens' ScheduledQueryRunSummary (Maybe ExecutionStats)
scheduledQueryRunSummary_executionStats = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledQueryRunSummary' {Maybe ExecutionStats
executionStats :: Maybe ExecutionStats
$sel:executionStats:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ExecutionStats
executionStats} -> Maybe ExecutionStats
executionStats) (\s :: ScheduledQueryRunSummary
s@ScheduledQueryRunSummary' {} Maybe ExecutionStats
a -> ScheduledQueryRunSummary
s {$sel:executionStats:ScheduledQueryRunSummary' :: Maybe ExecutionStats
executionStats = Maybe ExecutionStats
a} :: ScheduledQueryRunSummary)

-- | Error message for the scheduled query in case of failure. You might have
-- to look at the error report to get more detailed error reasons.
scheduledQueryRunSummary_failureReason :: Lens.Lens' ScheduledQueryRunSummary (Prelude.Maybe Prelude.Text)
scheduledQueryRunSummary_failureReason :: Lens' ScheduledQueryRunSummary (Maybe Text)
scheduledQueryRunSummary_failureReason = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledQueryRunSummary' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: ScheduledQueryRunSummary
s@ScheduledQueryRunSummary' {} Maybe Text
a -> ScheduledQueryRunSummary
s {$sel:failureReason:ScheduledQueryRunSummary' :: Maybe Text
failureReason = Maybe Text
a} :: ScheduledQueryRunSummary)

-- | InvocationTime for this run. This is the time at which the query is
-- scheduled to run. Parameter @\@scheduled_runtime@ can be used in the
-- query to get the value.
scheduledQueryRunSummary_invocationTime :: Lens.Lens' ScheduledQueryRunSummary (Prelude.Maybe Prelude.UTCTime)
scheduledQueryRunSummary_invocationTime :: Lens' ScheduledQueryRunSummary (Maybe UTCTime)
scheduledQueryRunSummary_invocationTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledQueryRunSummary' {Maybe POSIX
invocationTime :: Maybe POSIX
$sel:invocationTime:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe POSIX
invocationTime} -> Maybe POSIX
invocationTime) (\s :: ScheduledQueryRunSummary
s@ScheduledQueryRunSummary' {} Maybe POSIX
a -> ScheduledQueryRunSummary
s {$sel:invocationTime:ScheduledQueryRunSummary' :: Maybe POSIX
invocationTime = Maybe POSIX
a} :: ScheduledQueryRunSummary) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The status of a scheduled query run.
scheduledQueryRunSummary_runStatus :: Lens.Lens' ScheduledQueryRunSummary (Prelude.Maybe ScheduledQueryRunStatus)
scheduledQueryRunSummary_runStatus :: Lens' ScheduledQueryRunSummary (Maybe ScheduledQueryRunStatus)
scheduledQueryRunSummary_runStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledQueryRunSummary' {Maybe ScheduledQueryRunStatus
runStatus :: Maybe ScheduledQueryRunStatus
$sel:runStatus:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ScheduledQueryRunStatus
runStatus} -> Maybe ScheduledQueryRunStatus
runStatus) (\s :: ScheduledQueryRunSummary
s@ScheduledQueryRunSummary' {} Maybe ScheduledQueryRunStatus
a -> ScheduledQueryRunSummary
s {$sel:runStatus:ScheduledQueryRunSummary' :: Maybe ScheduledQueryRunStatus
runStatus = Maybe ScheduledQueryRunStatus
a} :: ScheduledQueryRunSummary)

-- | The actual time when the query was run.
scheduledQueryRunSummary_triggerTime :: Lens.Lens' ScheduledQueryRunSummary (Prelude.Maybe Prelude.UTCTime)
scheduledQueryRunSummary_triggerTime :: Lens' ScheduledQueryRunSummary (Maybe UTCTime)
scheduledQueryRunSummary_triggerTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledQueryRunSummary' {Maybe POSIX
triggerTime :: Maybe POSIX
$sel:triggerTime:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe POSIX
triggerTime} -> Maybe POSIX
triggerTime) (\s :: ScheduledQueryRunSummary
s@ScheduledQueryRunSummary' {} Maybe POSIX
a -> ScheduledQueryRunSummary
s {$sel:triggerTime:ScheduledQueryRunSummary' :: Maybe POSIX
triggerTime = Maybe POSIX
a} :: ScheduledQueryRunSummary) 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 (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromJSON ScheduledQueryRunSummary where
  parseJSON :: Value -> Parser ScheduledQueryRunSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ScheduledQueryRunSummary"
      ( \Object
x ->
          Maybe ErrorReportLocation
-> Maybe ExecutionStats
-> Maybe Text
-> Maybe POSIX
-> Maybe ScheduledQueryRunStatus
-> Maybe POSIX
-> ScheduledQueryRunSummary
ScheduledQueryRunSummary'
            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
"ErrorReportLocation")
            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
"ExecutionStats")
            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
"FailureReason")
            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
"InvocationTime")
            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
"RunStatus")
            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
"TriggerTime")
      )

instance Prelude.Hashable ScheduledQueryRunSummary where
  hashWithSalt :: Int -> ScheduledQueryRunSummary -> Int
hashWithSalt Int
_salt ScheduledQueryRunSummary' {Maybe Text
Maybe POSIX
Maybe ExecutionStats
Maybe ErrorReportLocation
Maybe ScheduledQueryRunStatus
triggerTime :: Maybe POSIX
runStatus :: Maybe ScheduledQueryRunStatus
invocationTime :: Maybe POSIX
failureReason :: Maybe Text
executionStats :: Maybe ExecutionStats
errorReportLocation :: Maybe ErrorReportLocation
$sel:triggerTime:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe POSIX
$sel:runStatus:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ScheduledQueryRunStatus
$sel:invocationTime:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe POSIX
$sel:failureReason:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe Text
$sel:executionStats:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ExecutionStats
$sel:errorReportLocation:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ErrorReportLocation
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorReportLocation
errorReportLocation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExecutionStats
executionStats
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
failureReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
invocationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScheduledQueryRunStatus
runStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
triggerTime

instance Prelude.NFData ScheduledQueryRunSummary where
  rnf :: ScheduledQueryRunSummary -> ()
rnf ScheduledQueryRunSummary' {Maybe Text
Maybe POSIX
Maybe ExecutionStats
Maybe ErrorReportLocation
Maybe ScheduledQueryRunStatus
triggerTime :: Maybe POSIX
runStatus :: Maybe ScheduledQueryRunStatus
invocationTime :: Maybe POSIX
failureReason :: Maybe Text
executionStats :: Maybe ExecutionStats
errorReportLocation :: Maybe ErrorReportLocation
$sel:triggerTime:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe POSIX
$sel:runStatus:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ScheduledQueryRunStatus
$sel:invocationTime:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe POSIX
$sel:failureReason:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe Text
$sel:executionStats:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ExecutionStats
$sel:errorReportLocation:ScheduledQueryRunSummary' :: ScheduledQueryRunSummary -> Maybe ErrorReportLocation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorReportLocation
errorReportLocation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ExecutionStats
executionStats
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
failureReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
invocationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ScheduledQueryRunStatus
runStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
triggerTime