{-# 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.GlobalAccelerator.Types.AcceleratorEvent
-- 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.GlobalAccelerator.Types.AcceleratorEvent 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

-- | A complex type that contains a @Timestamp@ value and @Message@ for
-- changes that you make to an accelerator in Global Accelerator. Messages
-- stored here provide progress or error information when you update an
-- accelerator from IPv4 to dual-stack, or from dual-stack to IPv4. Global
-- Accelerator stores a maximum of ten event messages.
--
-- /See:/ 'newAcceleratorEvent' smart constructor.
data AcceleratorEvent = AcceleratorEvent'
  { -- | A string that contains an @Event@ message describing changes or errors
    -- when you update an accelerator in Global Accelerator from IPv4 to
    -- dual-stack, or dual-stack to IPv4.
    AcceleratorEvent -> Maybe Text
message :: Prelude.Maybe Prelude.Text,
    -- | A timestamp for when you update an accelerator in Global Accelerator
    -- from IPv4 to dual-stack, or dual-stack to IPv4.
    AcceleratorEvent -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX
  }
  deriving (AcceleratorEvent -> AcceleratorEvent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AcceleratorEvent -> AcceleratorEvent -> Bool
$c/= :: AcceleratorEvent -> AcceleratorEvent -> Bool
== :: AcceleratorEvent -> AcceleratorEvent -> Bool
$c== :: AcceleratorEvent -> AcceleratorEvent -> Bool
Prelude.Eq, ReadPrec [AcceleratorEvent]
ReadPrec AcceleratorEvent
Int -> ReadS AcceleratorEvent
ReadS [AcceleratorEvent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AcceleratorEvent]
$creadListPrec :: ReadPrec [AcceleratorEvent]
readPrec :: ReadPrec AcceleratorEvent
$creadPrec :: ReadPrec AcceleratorEvent
readList :: ReadS [AcceleratorEvent]
$creadList :: ReadS [AcceleratorEvent]
readsPrec :: Int -> ReadS AcceleratorEvent
$creadsPrec :: Int -> ReadS AcceleratorEvent
Prelude.Read, Int -> AcceleratorEvent -> ShowS
[AcceleratorEvent] -> ShowS
AcceleratorEvent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AcceleratorEvent] -> ShowS
$cshowList :: [AcceleratorEvent] -> ShowS
show :: AcceleratorEvent -> String
$cshow :: AcceleratorEvent -> String
showsPrec :: Int -> AcceleratorEvent -> ShowS
$cshowsPrec :: Int -> AcceleratorEvent -> ShowS
Prelude.Show, forall x. Rep AcceleratorEvent x -> AcceleratorEvent
forall x. AcceleratorEvent -> Rep AcceleratorEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AcceleratorEvent x -> AcceleratorEvent
$cfrom :: forall x. AcceleratorEvent -> Rep AcceleratorEvent x
Prelude.Generic)

-- |
-- Create a value of 'AcceleratorEvent' 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:
--
-- 'message', 'acceleratorEvent_message' - A string that contains an @Event@ message describing changes or errors
-- when you update an accelerator in Global Accelerator from IPv4 to
-- dual-stack, or dual-stack to IPv4.
--
-- 'timestamp', 'acceleratorEvent_timestamp' - A timestamp for when you update an accelerator in Global Accelerator
-- from IPv4 to dual-stack, or dual-stack to IPv4.
newAcceleratorEvent ::
  AcceleratorEvent
newAcceleratorEvent :: AcceleratorEvent
newAcceleratorEvent =
  AcceleratorEvent'
    { $sel:message:AcceleratorEvent' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:AcceleratorEvent' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | A string that contains an @Event@ message describing changes or errors
-- when you update an accelerator in Global Accelerator from IPv4 to
-- dual-stack, or dual-stack to IPv4.
acceleratorEvent_message :: Lens.Lens' AcceleratorEvent (Prelude.Maybe Prelude.Text)
acceleratorEvent_message :: Lens' AcceleratorEvent (Maybe Text)
acceleratorEvent_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceleratorEvent' {Maybe Text
message :: Maybe Text
$sel:message:AcceleratorEvent' :: AcceleratorEvent -> Maybe Text
message} -> Maybe Text
message) (\s :: AcceleratorEvent
s@AcceleratorEvent' {} Maybe Text
a -> AcceleratorEvent
s {$sel:message:AcceleratorEvent' :: Maybe Text
message = Maybe Text
a} :: AcceleratorEvent)

-- | A timestamp for when you update an accelerator in Global Accelerator
-- from IPv4 to dual-stack, or dual-stack to IPv4.
acceleratorEvent_timestamp :: Lens.Lens' AcceleratorEvent (Prelude.Maybe Prelude.UTCTime)
acceleratorEvent_timestamp :: Lens' AcceleratorEvent (Maybe UTCTime)
acceleratorEvent_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceleratorEvent' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:AcceleratorEvent' :: AcceleratorEvent -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: AcceleratorEvent
s@AcceleratorEvent' {} Maybe POSIX
a -> AcceleratorEvent
s {$sel:timestamp:AcceleratorEvent' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: AcceleratorEvent) 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 AcceleratorEvent where
  parseJSON :: Value -> Parser AcceleratorEvent
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AcceleratorEvent"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> AcceleratorEvent
AcceleratorEvent'
            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
"Message")
            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
"Timestamp")
      )

instance Prelude.Hashable AcceleratorEvent where
  hashWithSalt :: Int -> AcceleratorEvent -> Int
hashWithSalt Int
_salt AcceleratorEvent' {Maybe Text
Maybe POSIX
timestamp :: Maybe POSIX
message :: Maybe Text
$sel:timestamp:AcceleratorEvent' :: AcceleratorEvent -> Maybe POSIX
$sel:message:AcceleratorEvent' :: AcceleratorEvent -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp

instance Prelude.NFData AcceleratorEvent where
  rnf :: AcceleratorEvent -> ()
rnf AcceleratorEvent' {Maybe Text
Maybe POSIX
timestamp :: Maybe POSIX
message :: Maybe Text
$sel:timestamp:AcceleratorEvent' :: AcceleratorEvent -> Maybe POSIX
$sel:message:AcceleratorEvent' :: AcceleratorEvent -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
timestamp