{-# 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.LaunchExecution
-- 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.LaunchExecution 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 information about the start and end times of the
-- launch.
--
-- /See:/ 'newLaunchExecution' smart constructor.
data LaunchExecution = LaunchExecution'
  { -- | The date and time that the launch ended.
    LaunchExecution -> Maybe POSIX
endedTime :: Prelude.Maybe Data.POSIX,
    -- | The date and time that the launch started.
    LaunchExecution -> Maybe POSIX
startedTime :: Prelude.Maybe Data.POSIX
  }
  deriving (LaunchExecution -> LaunchExecution -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LaunchExecution -> LaunchExecution -> Bool
$c/= :: LaunchExecution -> LaunchExecution -> Bool
== :: LaunchExecution -> LaunchExecution -> Bool
$c== :: LaunchExecution -> LaunchExecution -> Bool
Prelude.Eq, ReadPrec [LaunchExecution]
ReadPrec LaunchExecution
Int -> ReadS LaunchExecution
ReadS [LaunchExecution]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LaunchExecution]
$creadListPrec :: ReadPrec [LaunchExecution]
readPrec :: ReadPrec LaunchExecution
$creadPrec :: ReadPrec LaunchExecution
readList :: ReadS [LaunchExecution]
$creadList :: ReadS [LaunchExecution]
readsPrec :: Int -> ReadS LaunchExecution
$creadsPrec :: Int -> ReadS LaunchExecution
Prelude.Read, Int -> LaunchExecution -> ShowS
[LaunchExecution] -> ShowS
LaunchExecution -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LaunchExecution] -> ShowS
$cshowList :: [LaunchExecution] -> ShowS
show :: LaunchExecution -> String
$cshow :: LaunchExecution -> String
showsPrec :: Int -> LaunchExecution -> ShowS
$cshowsPrec :: Int -> LaunchExecution -> ShowS
Prelude.Show, forall x. Rep LaunchExecution x -> LaunchExecution
forall x. LaunchExecution -> Rep LaunchExecution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LaunchExecution x -> LaunchExecution
$cfrom :: forall x. LaunchExecution -> Rep LaunchExecution x
Prelude.Generic)

-- |
-- Create a value of 'LaunchExecution' 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', 'launchExecution_endedTime' - The date and time that the launch ended.
--
-- 'startedTime', 'launchExecution_startedTime' - The date and time that the launch started.
newLaunchExecution ::
  LaunchExecution
newLaunchExecution :: LaunchExecution
newLaunchExecution =
  LaunchExecution'
    { $sel:endedTime:LaunchExecution' :: Maybe POSIX
endedTime = forall a. Maybe a
Prelude.Nothing,
      $sel:startedTime:LaunchExecution' :: Maybe POSIX
startedTime = forall a. Maybe a
Prelude.Nothing
    }

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