{-# 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.EC2.Types.HistoryRecordEntry
-- 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.EC2.Types.HistoryRecordEntry where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.EventInformation
import Amazonka.EC2.Types.FleetEventType
import qualified Amazonka.Prelude as Prelude

-- | Describes an event in the history of an EC2 Fleet.
--
-- /See:/ 'newHistoryRecordEntry' smart constructor.
data HistoryRecordEntry = HistoryRecordEntry'
  { -- | Information about the event.
    HistoryRecordEntry -> Maybe EventInformation
eventInformation :: Prelude.Maybe EventInformation,
    -- | The event type.
    HistoryRecordEntry -> Maybe FleetEventType
eventType :: Prelude.Maybe FleetEventType,
    -- | The date and time of the event, in UTC format (for example,
    -- /YYYY/-/MM/-/DD/T/HH/:/MM/:/SS/Z).
    HistoryRecordEntry -> Maybe ISO8601
timestamp :: Prelude.Maybe Data.ISO8601
  }
  deriving (HistoryRecordEntry -> HistoryRecordEntry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HistoryRecordEntry -> HistoryRecordEntry -> Bool
$c/= :: HistoryRecordEntry -> HistoryRecordEntry -> Bool
== :: HistoryRecordEntry -> HistoryRecordEntry -> Bool
$c== :: HistoryRecordEntry -> HistoryRecordEntry -> Bool
Prelude.Eq, ReadPrec [HistoryRecordEntry]
ReadPrec HistoryRecordEntry
Int -> ReadS HistoryRecordEntry
ReadS [HistoryRecordEntry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HistoryRecordEntry]
$creadListPrec :: ReadPrec [HistoryRecordEntry]
readPrec :: ReadPrec HistoryRecordEntry
$creadPrec :: ReadPrec HistoryRecordEntry
readList :: ReadS [HistoryRecordEntry]
$creadList :: ReadS [HistoryRecordEntry]
readsPrec :: Int -> ReadS HistoryRecordEntry
$creadsPrec :: Int -> ReadS HistoryRecordEntry
Prelude.Read, Int -> HistoryRecordEntry -> ShowS
[HistoryRecordEntry] -> ShowS
HistoryRecordEntry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HistoryRecordEntry] -> ShowS
$cshowList :: [HistoryRecordEntry] -> ShowS
show :: HistoryRecordEntry -> String
$cshow :: HistoryRecordEntry -> String
showsPrec :: Int -> HistoryRecordEntry -> ShowS
$cshowsPrec :: Int -> HistoryRecordEntry -> ShowS
Prelude.Show, forall x. Rep HistoryRecordEntry x -> HistoryRecordEntry
forall x. HistoryRecordEntry -> Rep HistoryRecordEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HistoryRecordEntry x -> HistoryRecordEntry
$cfrom :: forall x. HistoryRecordEntry -> Rep HistoryRecordEntry x
Prelude.Generic)

-- |
-- Create a value of 'HistoryRecordEntry' 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:
--
-- 'eventInformation', 'historyRecordEntry_eventInformation' - Information about the event.
--
-- 'eventType', 'historyRecordEntry_eventType' - The event type.
--
-- 'timestamp', 'historyRecordEntry_timestamp' - The date and time of the event, in UTC format (for example,
-- /YYYY/-/MM/-/DD/T/HH/:/MM/:/SS/Z).
newHistoryRecordEntry ::
  HistoryRecordEntry
newHistoryRecordEntry :: HistoryRecordEntry
newHistoryRecordEntry =
  HistoryRecordEntry'
    { $sel:eventInformation:HistoryRecordEntry' :: Maybe EventInformation
eventInformation =
        forall a. Maybe a
Prelude.Nothing,
      $sel:eventType:HistoryRecordEntry' :: Maybe FleetEventType
eventType = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:HistoryRecordEntry' :: Maybe ISO8601
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the event.
historyRecordEntry_eventInformation :: Lens.Lens' HistoryRecordEntry (Prelude.Maybe EventInformation)
historyRecordEntry_eventInformation :: Lens' HistoryRecordEntry (Maybe EventInformation)
historyRecordEntry_eventInformation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoryRecordEntry' {Maybe EventInformation
eventInformation :: Maybe EventInformation
$sel:eventInformation:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe EventInformation
eventInformation} -> Maybe EventInformation
eventInformation) (\s :: HistoryRecordEntry
s@HistoryRecordEntry' {} Maybe EventInformation
a -> HistoryRecordEntry
s {$sel:eventInformation:HistoryRecordEntry' :: Maybe EventInformation
eventInformation = Maybe EventInformation
a} :: HistoryRecordEntry)

-- | The event type.
historyRecordEntry_eventType :: Lens.Lens' HistoryRecordEntry (Prelude.Maybe FleetEventType)
historyRecordEntry_eventType :: Lens' HistoryRecordEntry (Maybe FleetEventType)
historyRecordEntry_eventType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoryRecordEntry' {Maybe FleetEventType
eventType :: Maybe FleetEventType
$sel:eventType:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe FleetEventType
eventType} -> Maybe FleetEventType
eventType) (\s :: HistoryRecordEntry
s@HistoryRecordEntry' {} Maybe FleetEventType
a -> HistoryRecordEntry
s {$sel:eventType:HistoryRecordEntry' :: Maybe FleetEventType
eventType = Maybe FleetEventType
a} :: HistoryRecordEntry)

-- | The date and time of the event, in UTC format (for example,
-- /YYYY/-/MM/-/DD/T/HH/:/MM/:/SS/Z).
historyRecordEntry_timestamp :: Lens.Lens' HistoryRecordEntry (Prelude.Maybe Prelude.UTCTime)
historyRecordEntry_timestamp :: Lens' HistoryRecordEntry (Maybe UTCTime)
historyRecordEntry_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoryRecordEntry' {Maybe ISO8601
timestamp :: Maybe ISO8601
$sel:timestamp:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe ISO8601
timestamp} -> Maybe ISO8601
timestamp) (\s :: HistoryRecordEntry
s@HistoryRecordEntry' {} Maybe ISO8601
a -> HistoryRecordEntry
s {$sel:timestamp:HistoryRecordEntry' :: Maybe ISO8601
timestamp = Maybe ISO8601
a} :: HistoryRecordEntry) 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.FromXML HistoryRecordEntry where
  parseXML :: [Node] -> Either String HistoryRecordEntry
parseXML [Node]
x =
    Maybe EventInformation
-> Maybe FleetEventType -> Maybe ISO8601 -> HistoryRecordEntry
HistoryRecordEntry'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"eventInformation")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"eventType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"timestamp")

instance Prelude.Hashable HistoryRecordEntry where
  hashWithSalt :: Int -> HistoryRecordEntry -> Int
hashWithSalt Int
_salt HistoryRecordEntry' {Maybe ISO8601
Maybe EventInformation
Maybe FleetEventType
timestamp :: Maybe ISO8601
eventType :: Maybe FleetEventType
eventInformation :: Maybe EventInformation
$sel:timestamp:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe ISO8601
$sel:eventType:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe FleetEventType
$sel:eventInformation:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe EventInformation
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EventInformation
eventInformation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FleetEventType
eventType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
timestamp

instance Prelude.NFData HistoryRecordEntry where
  rnf :: HistoryRecordEntry -> ()
rnf HistoryRecordEntry' {Maybe ISO8601
Maybe EventInformation
Maybe FleetEventType
timestamp :: Maybe ISO8601
eventType :: Maybe FleetEventType
eventInformation :: Maybe EventInformation
$sel:timestamp:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe ISO8601
$sel:eventType:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe FleetEventType
$sel:eventInformation:HistoryRecordEntry' :: HistoryRecordEntry -> Maybe EventInformation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EventInformation
eventInformation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FleetEventType
eventType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
timestamp