{-# 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.NetworkManager.Types.ConnectionHealth
-- 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.NetworkManager.Types.ConnectionHealth where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkManager.Types.ConnectionStatus
import Amazonka.NetworkManager.Types.ConnectionType
import qualified Amazonka.Prelude as Prelude

-- | Describes connection health.
--
-- /See:/ 'newConnectionHealth' smart constructor.
data ConnectionHealth = ConnectionHealth'
  { -- | The connection status.
    ConnectionHealth -> Maybe ConnectionStatus
status :: Prelude.Maybe ConnectionStatus,
    -- | The time the status was last updated.
    ConnectionHealth -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX,
    -- | The connection type.
    ConnectionHealth -> Maybe ConnectionType
type' :: Prelude.Maybe ConnectionType
  }
  deriving (ConnectionHealth -> ConnectionHealth -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectionHealth -> ConnectionHealth -> Bool
$c/= :: ConnectionHealth -> ConnectionHealth -> Bool
== :: ConnectionHealth -> ConnectionHealth -> Bool
$c== :: ConnectionHealth -> ConnectionHealth -> Bool
Prelude.Eq, ReadPrec [ConnectionHealth]
ReadPrec ConnectionHealth
Int -> ReadS ConnectionHealth
ReadS [ConnectionHealth]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectionHealth]
$creadListPrec :: ReadPrec [ConnectionHealth]
readPrec :: ReadPrec ConnectionHealth
$creadPrec :: ReadPrec ConnectionHealth
readList :: ReadS [ConnectionHealth]
$creadList :: ReadS [ConnectionHealth]
readsPrec :: Int -> ReadS ConnectionHealth
$creadsPrec :: Int -> ReadS ConnectionHealth
Prelude.Read, Int -> ConnectionHealth -> ShowS
[ConnectionHealth] -> ShowS
ConnectionHealth -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectionHealth] -> ShowS
$cshowList :: [ConnectionHealth] -> ShowS
show :: ConnectionHealth -> String
$cshow :: ConnectionHealth -> String
showsPrec :: Int -> ConnectionHealth -> ShowS
$cshowsPrec :: Int -> ConnectionHealth -> ShowS
Prelude.Show, forall x. Rep ConnectionHealth x -> ConnectionHealth
forall x. ConnectionHealth -> Rep ConnectionHealth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectionHealth x -> ConnectionHealth
$cfrom :: forall x. ConnectionHealth -> Rep ConnectionHealth x
Prelude.Generic)

-- |
-- Create a value of 'ConnectionHealth' 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:
--
-- 'status', 'connectionHealth_status' - The connection status.
--
-- 'timestamp', 'connectionHealth_timestamp' - The time the status was last updated.
--
-- 'type'', 'connectionHealth_type' - The connection type.
newConnectionHealth ::
  ConnectionHealth
newConnectionHealth :: ConnectionHealth
newConnectionHealth =
  ConnectionHealth'
    { $sel:status:ConnectionHealth' :: Maybe ConnectionStatus
status = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:ConnectionHealth' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:type':ConnectionHealth' :: Maybe ConnectionType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The connection status.
connectionHealth_status :: Lens.Lens' ConnectionHealth (Prelude.Maybe ConnectionStatus)
connectionHealth_status :: Lens' ConnectionHealth (Maybe ConnectionStatus)
connectionHealth_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionHealth' {Maybe ConnectionStatus
status :: Maybe ConnectionStatus
$sel:status:ConnectionHealth' :: ConnectionHealth -> Maybe ConnectionStatus
status} -> Maybe ConnectionStatus
status) (\s :: ConnectionHealth
s@ConnectionHealth' {} Maybe ConnectionStatus
a -> ConnectionHealth
s {$sel:status:ConnectionHealth' :: Maybe ConnectionStatus
status = Maybe ConnectionStatus
a} :: ConnectionHealth)

-- | The time the status was last updated.
connectionHealth_timestamp :: Lens.Lens' ConnectionHealth (Prelude.Maybe Prelude.UTCTime)
connectionHealth_timestamp :: Lens' ConnectionHealth (Maybe UTCTime)
connectionHealth_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionHealth' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:ConnectionHealth' :: ConnectionHealth -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: ConnectionHealth
s@ConnectionHealth' {} Maybe POSIX
a -> ConnectionHealth
s {$sel:timestamp:ConnectionHealth' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: ConnectionHealth) 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 connection type.
connectionHealth_type :: Lens.Lens' ConnectionHealth (Prelude.Maybe ConnectionType)
connectionHealth_type :: Lens' ConnectionHealth (Maybe ConnectionType)
connectionHealth_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectionHealth' {Maybe ConnectionType
type' :: Maybe ConnectionType
$sel:type':ConnectionHealth' :: ConnectionHealth -> Maybe ConnectionType
type'} -> Maybe ConnectionType
type') (\s :: ConnectionHealth
s@ConnectionHealth' {} Maybe ConnectionType
a -> ConnectionHealth
s {$sel:type':ConnectionHealth' :: Maybe ConnectionType
type' = Maybe ConnectionType
a} :: ConnectionHealth)

instance Data.FromJSON ConnectionHealth where
  parseJSON :: Value -> Parser ConnectionHealth
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConnectionHealth"
      ( \Object
x ->
          Maybe ConnectionStatus
-> Maybe POSIX -> Maybe ConnectionType -> ConnectionHealth
ConnectionHealth'
            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
"Status")
            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")
            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
"Type")
      )

instance Prelude.Hashable ConnectionHealth where
  hashWithSalt :: Int -> ConnectionHealth -> Int
hashWithSalt Int
_salt ConnectionHealth' {Maybe POSIX
Maybe ConnectionStatus
Maybe ConnectionType
type' :: Maybe ConnectionType
timestamp :: Maybe POSIX
status :: Maybe ConnectionStatus
$sel:type':ConnectionHealth' :: ConnectionHealth -> Maybe ConnectionType
$sel:timestamp:ConnectionHealth' :: ConnectionHealth -> Maybe POSIX
$sel:status:ConnectionHealth' :: ConnectionHealth -> Maybe ConnectionStatus
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConnectionStatus
status
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConnectionType
type'

instance Prelude.NFData ConnectionHealth where
  rnf :: ConnectionHealth -> ()
rnf ConnectionHealth' {Maybe POSIX
Maybe ConnectionStatus
Maybe ConnectionType
type' :: Maybe ConnectionType
timestamp :: Maybe POSIX
status :: Maybe ConnectionStatus
$sel:type':ConnectionHealth' :: ConnectionHealth -> Maybe ConnectionType
$sel:timestamp:ConnectionHealth' :: ConnectionHealth -> Maybe POSIX
$sel:status:ConnectionHealth' :: ConnectionHealth -> Maybe ConnectionStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ConnectionStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
timestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ConnectionType
type'