{-# 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.Evidently.Types.ExperimentExecution
-- 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.Evidently.Types.ExperimentExecution 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

-- | This structure contains the date and time that the experiment started
-- and ended.
--
-- /See:/ 'newExperimentExecution' smart constructor.
data ExperimentExecution = ExperimentExecution'
  { -- | The date and time that the experiment ended.
    ExperimentExecution -> Maybe POSIX
endedTime :: Prelude.Maybe Data.POSIX,
    -- | The date and time that the experiment started.
    ExperimentExecution -> Maybe POSIX
startedTime :: Prelude.Maybe Data.POSIX
  }
  deriving (ExperimentExecution -> ExperimentExecution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExperimentExecution -> ExperimentExecution -> Bool
$c/= :: ExperimentExecution -> ExperimentExecution -> Bool
== :: ExperimentExecution -> ExperimentExecution -> Bool
$c== :: ExperimentExecution -> ExperimentExecution -> Bool
Prelude.Eq, ReadPrec [ExperimentExecution]
ReadPrec ExperimentExecution
Int -> ReadS ExperimentExecution
ReadS [ExperimentExecution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExperimentExecution]
$creadListPrec :: ReadPrec [ExperimentExecution]
readPrec :: ReadPrec ExperimentExecution
$creadPrec :: ReadPrec ExperimentExecution
readList :: ReadS [ExperimentExecution]
$creadList :: ReadS [ExperimentExecution]
readsPrec :: Int -> ReadS ExperimentExecution
$creadsPrec :: Int -> ReadS ExperimentExecution
Prelude.Read, Int -> ExperimentExecution -> ShowS
[ExperimentExecution] -> ShowS
ExperimentExecution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExperimentExecution] -> ShowS
$cshowList :: [ExperimentExecution] -> ShowS
show :: ExperimentExecution -> String
$cshow :: ExperimentExecution -> String
showsPrec :: Int -> ExperimentExecution -> ShowS
$cshowsPrec :: Int -> ExperimentExecution -> ShowS
Prelude.Show, forall x. Rep ExperimentExecution x -> ExperimentExecution
forall x. ExperimentExecution -> Rep ExperimentExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExperimentExecution x -> ExperimentExecution
$cfrom :: forall x. ExperimentExecution -> Rep ExperimentExecution x
Prelude.Generic)

-- |
-- Create a value of 'ExperimentExecution' 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:
--
-- 'endedTime', 'experimentExecution_endedTime' - The date and time that the experiment ended.
--
-- 'startedTime', 'experimentExecution_startedTime' - The date and time that the experiment started.
newExperimentExecution ::
  ExperimentExecution
newExperimentExecution :: ExperimentExecution
newExperimentExecution =
  ExperimentExecution'
    { $sel:endedTime:ExperimentExecution' :: Maybe POSIX
endedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:startedTime:ExperimentExecution' :: Maybe POSIX
startedTime = forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time that the experiment ended.
experimentExecution_endedTime :: Lens.Lens' ExperimentExecution (Prelude.Maybe Prelude.UTCTime)
experimentExecution_endedTime :: Lens' ExperimentExecution (Maybe UTCTime)
experimentExecution_endedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentExecution' {Maybe POSIX
endedTime :: Maybe POSIX
$sel:endedTime:ExperimentExecution' :: ExperimentExecution -> Maybe POSIX
endedTime} -> Maybe POSIX
endedTime) (\s :: ExperimentExecution
s@ExperimentExecution' {} Maybe POSIX
a -> ExperimentExecution
s {$sel:endedTime:ExperimentExecution' :: Maybe POSIX
endedTime = Maybe POSIX
a} :: ExperimentExecution) 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 date and time that the experiment started.
experimentExecution_startedTime :: Lens.Lens' ExperimentExecution (Prelude.Maybe Prelude.UTCTime)
experimentExecution_startedTime :: Lens' ExperimentExecution (Maybe UTCTime)
experimentExecution_startedTime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentExecution' {Maybe POSIX
startedTime :: Maybe POSIX
$sel:startedTime:ExperimentExecution' :: ExperimentExecution -> Maybe POSIX
startedTime} -> Maybe POSIX
startedTime) (\s :: ExperimentExecution
s@ExperimentExecution' {} Maybe POSIX
a -> ExperimentExecution
s {$sel:startedTime:ExperimentExecution' :: Maybe POSIX
startedTime = Maybe POSIX
a} :: ExperimentExecution) 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 ExperimentExecution where
  parseJSON :: Value -> Parser ExperimentExecution
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExperimentExecution"
      ( \Object
x ->
          Maybe POSIX -> Maybe POSIX -> ExperimentExecution
ExperimentExecution'
            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
"endedTime")
            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
"startedTime")
      )

instance Prelude.Hashable ExperimentExecution where
  hashWithSalt :: Int -> ExperimentExecution -> Int
hashWithSalt Int
_salt ExperimentExecution' {Maybe POSIX
startedTime :: Maybe POSIX
endedTime :: Maybe POSIX
$sel:startedTime:ExperimentExecution' :: ExperimentExecution -> Maybe POSIX
$sel:endedTime:ExperimentExecution' :: ExperimentExecution -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
endedTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
startedTime

instance Prelude.NFData ExperimentExecution where
  rnf :: ExperimentExecution -> ()
rnf ExperimentExecution' {Maybe POSIX
startedTime :: Maybe POSIX
endedTime :: Maybe POSIX
$sel:startedTime:ExperimentExecution' :: ExperimentExecution -> Maybe POSIX
$sel:endedTime:ExperimentExecution' :: ExperimentExecution -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
endedTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
startedTime