{-# 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.Chime.Types.TerminationHealth
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Chime.Types.TerminationHealth where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The termination health details, including the source IP address and
-- timestamp of the last successful SIP @OPTIONS@ message from your SIP
-- infrastructure.
--
-- /See:/ 'newTerminationHealth' smart constructor.
data TerminationHealth = TerminationHealth'
  { -- | The source IP address.
    TerminationHealth -> Maybe Text
source :: Prelude.Maybe Prelude.Text,
    -- | The timestamp, in ISO 8601 format.
    TerminationHealth -> Maybe POSIX
timestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (TerminationHealth -> TerminationHealth -> Bool
(TerminationHealth -> TerminationHealth -> Bool)
-> (TerminationHealth -> TerminationHealth -> Bool)
-> Eq TerminationHealth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TerminationHealth -> TerminationHealth -> Bool
$c/= :: TerminationHealth -> TerminationHealth -> Bool
== :: TerminationHealth -> TerminationHealth -> Bool
$c== :: TerminationHealth -> TerminationHealth -> Bool
Prelude.Eq, ReadPrec [TerminationHealth]
ReadPrec TerminationHealth
Int -> ReadS TerminationHealth
ReadS [TerminationHealth]
(Int -> ReadS TerminationHealth)
-> ReadS [TerminationHealth]
-> ReadPrec TerminationHealth
-> ReadPrec [TerminationHealth]
-> Read TerminationHealth
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TerminationHealth]
$creadListPrec :: ReadPrec [TerminationHealth]
readPrec :: ReadPrec TerminationHealth
$creadPrec :: ReadPrec TerminationHealth
readList :: ReadS [TerminationHealth]
$creadList :: ReadS [TerminationHealth]
readsPrec :: Int -> ReadS TerminationHealth
$creadsPrec :: Int -> ReadS TerminationHealth
Prelude.Read, Int -> TerminationHealth -> ShowS
[TerminationHealth] -> ShowS
TerminationHealth -> String
(Int -> TerminationHealth -> ShowS)
-> (TerminationHealth -> String)
-> ([TerminationHealth] -> ShowS)
-> Show TerminationHealth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TerminationHealth] -> ShowS
$cshowList :: [TerminationHealth] -> ShowS
show :: TerminationHealth -> String
$cshow :: TerminationHealth -> String
showsPrec :: Int -> TerminationHealth -> ShowS
$cshowsPrec :: Int -> TerminationHealth -> ShowS
Prelude.Show, (forall x. TerminationHealth -> Rep TerminationHealth x)
-> (forall x. Rep TerminationHealth x -> TerminationHealth)
-> Generic TerminationHealth
forall x. Rep TerminationHealth x -> TerminationHealth
forall x. TerminationHealth -> Rep TerminationHealth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TerminationHealth x -> TerminationHealth
$cfrom :: forall x. TerminationHealth -> Rep TerminationHealth x
Prelude.Generic)

-- |
-- Create a value of 'TerminationHealth' 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:
--
-- 'source', 'terminationHealth_source' - The source IP address.
--
-- 'timestamp', 'terminationHealth_timestamp' - The timestamp, in ISO 8601 format.
newTerminationHealth ::
  TerminationHealth
newTerminationHealth :: TerminationHealth
newTerminationHealth =
  TerminationHealth' :: Maybe Text -> Maybe POSIX -> TerminationHealth
TerminationHealth'
    { $sel:source:TerminationHealth' :: Maybe Text
source = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:TerminationHealth' :: Maybe POSIX
timestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The source IP address.
terminationHealth_source :: Lens.Lens' TerminationHealth (Prelude.Maybe Prelude.Text)
terminationHealth_source :: (Maybe Text -> f (Maybe Text))
-> TerminationHealth -> f TerminationHealth
terminationHealth_source = (TerminationHealth -> Maybe Text)
-> (TerminationHealth -> Maybe Text -> TerminationHealth)
-> Lens
     TerminationHealth TerminationHealth (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminationHealth' {Maybe Text
source :: Maybe Text
$sel:source:TerminationHealth' :: TerminationHealth -> Maybe Text
source} -> Maybe Text
source) (\s :: TerminationHealth
s@TerminationHealth' {} Maybe Text
a -> TerminationHealth
s {$sel:source:TerminationHealth' :: Maybe Text
source = Maybe Text
a} :: TerminationHealth)

-- | The timestamp, in ISO 8601 format.
terminationHealth_timestamp :: Lens.Lens' TerminationHealth (Prelude.Maybe Prelude.UTCTime)
terminationHealth_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TerminationHealth -> f TerminationHealth
terminationHealth_timestamp = (TerminationHealth -> Maybe POSIX)
-> (TerminationHealth -> Maybe POSIX -> TerminationHealth)
-> Lens
     TerminationHealth TerminationHealth (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminationHealth' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:TerminationHealth' :: TerminationHealth -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: TerminationHealth
s@TerminationHealth' {} Maybe POSIX
a -> TerminationHealth
s {$sel:timestamp:TerminationHealth' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: TerminationHealth) ((Maybe POSIX -> f (Maybe POSIX))
 -> TerminationHealth -> f TerminationHealth)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TerminationHealth
-> f TerminationHealth
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON TerminationHealth where
  parseJSON :: Value -> Parser TerminationHealth
parseJSON =
    String
-> (Object -> Parser TerminationHealth)
-> Value
-> Parser TerminationHealth
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TerminationHealth"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> TerminationHealth
TerminationHealth'
            (Maybe Text -> Maybe POSIX -> TerminationHealth)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> TerminationHealth)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Source")
            Parser (Maybe POSIX -> TerminationHealth)
-> Parser (Maybe POSIX) -> Parser TerminationHealth
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timestamp")
      )

instance Prelude.Hashable TerminationHealth

instance Prelude.NFData TerminationHealth