{-# 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.AlexaBusiness.Types.DeviceStatusInfo
-- 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.AlexaBusiness.Types.DeviceStatusInfo where

import Amazonka.AlexaBusiness.Types.ConnectionStatus
import Amazonka.AlexaBusiness.Types.DeviceStatusDetail
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Detailed information about a device\'s status.
--
-- /See:/ 'newDeviceStatusInfo' smart constructor.
data DeviceStatusInfo = DeviceStatusInfo'
  { -- | The time (in epoch) when the device connection status changed.
    DeviceStatusInfo -> Maybe POSIX
connectionStatusUpdatedTime :: Prelude.Maybe Core.POSIX,
    -- | One or more device status detail descriptions.
    DeviceStatusInfo -> Maybe [DeviceStatusDetail]
deviceStatusDetails :: Prelude.Maybe [DeviceStatusDetail],
    -- | The latest available information about the connection status of a
    -- device.
    DeviceStatusInfo -> Maybe ConnectionStatus
connectionStatus :: Prelude.Maybe ConnectionStatus
  }
  deriving (DeviceStatusInfo -> DeviceStatusInfo -> Bool
(DeviceStatusInfo -> DeviceStatusInfo -> Bool)
-> (DeviceStatusInfo -> DeviceStatusInfo -> Bool)
-> Eq DeviceStatusInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceStatusInfo -> DeviceStatusInfo -> Bool
$c/= :: DeviceStatusInfo -> DeviceStatusInfo -> Bool
== :: DeviceStatusInfo -> DeviceStatusInfo -> Bool
$c== :: DeviceStatusInfo -> DeviceStatusInfo -> Bool
Prelude.Eq, ReadPrec [DeviceStatusInfo]
ReadPrec DeviceStatusInfo
Int -> ReadS DeviceStatusInfo
ReadS [DeviceStatusInfo]
(Int -> ReadS DeviceStatusInfo)
-> ReadS [DeviceStatusInfo]
-> ReadPrec DeviceStatusInfo
-> ReadPrec [DeviceStatusInfo]
-> Read DeviceStatusInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeviceStatusInfo]
$creadListPrec :: ReadPrec [DeviceStatusInfo]
readPrec :: ReadPrec DeviceStatusInfo
$creadPrec :: ReadPrec DeviceStatusInfo
readList :: ReadS [DeviceStatusInfo]
$creadList :: ReadS [DeviceStatusInfo]
readsPrec :: Int -> ReadS DeviceStatusInfo
$creadsPrec :: Int -> ReadS DeviceStatusInfo
Prelude.Read, Int -> DeviceStatusInfo -> ShowS
[DeviceStatusInfo] -> ShowS
DeviceStatusInfo -> String
(Int -> DeviceStatusInfo -> ShowS)
-> (DeviceStatusInfo -> String)
-> ([DeviceStatusInfo] -> ShowS)
-> Show DeviceStatusInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceStatusInfo] -> ShowS
$cshowList :: [DeviceStatusInfo] -> ShowS
show :: DeviceStatusInfo -> String
$cshow :: DeviceStatusInfo -> String
showsPrec :: Int -> DeviceStatusInfo -> ShowS
$cshowsPrec :: Int -> DeviceStatusInfo -> ShowS
Prelude.Show, (forall x. DeviceStatusInfo -> Rep DeviceStatusInfo x)
-> (forall x. Rep DeviceStatusInfo x -> DeviceStatusInfo)
-> Generic DeviceStatusInfo
forall x. Rep DeviceStatusInfo x -> DeviceStatusInfo
forall x. DeviceStatusInfo -> Rep DeviceStatusInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeviceStatusInfo x -> DeviceStatusInfo
$cfrom :: forall x. DeviceStatusInfo -> Rep DeviceStatusInfo x
Prelude.Generic)

-- |
-- Create a value of 'DeviceStatusInfo' 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:
--
-- 'connectionStatusUpdatedTime', 'deviceStatusInfo_connectionStatusUpdatedTime' - The time (in epoch) when the device connection status changed.
--
-- 'deviceStatusDetails', 'deviceStatusInfo_deviceStatusDetails' - One or more device status detail descriptions.
--
-- 'connectionStatus', 'deviceStatusInfo_connectionStatus' - The latest available information about the connection status of a
-- device.
newDeviceStatusInfo ::
  DeviceStatusInfo
newDeviceStatusInfo :: DeviceStatusInfo
newDeviceStatusInfo =
  DeviceStatusInfo' :: Maybe POSIX
-> Maybe [DeviceStatusDetail]
-> Maybe ConnectionStatus
-> DeviceStatusInfo
DeviceStatusInfo'
    { $sel:connectionStatusUpdatedTime:DeviceStatusInfo' :: Maybe POSIX
connectionStatusUpdatedTime =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceStatusDetails:DeviceStatusInfo' :: Maybe [DeviceStatusDetail]
deviceStatusDetails = Maybe [DeviceStatusDetail]
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionStatus:DeviceStatusInfo' :: Maybe ConnectionStatus
connectionStatus = Maybe ConnectionStatus
forall a. Maybe a
Prelude.Nothing
    }

-- | The time (in epoch) when the device connection status changed.
deviceStatusInfo_connectionStatusUpdatedTime :: Lens.Lens' DeviceStatusInfo (Prelude.Maybe Prelude.UTCTime)
deviceStatusInfo_connectionStatusUpdatedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DeviceStatusInfo -> f DeviceStatusInfo
deviceStatusInfo_connectionStatusUpdatedTime = (DeviceStatusInfo -> Maybe POSIX)
-> (DeviceStatusInfo -> Maybe POSIX -> DeviceStatusInfo)
-> Lens
     DeviceStatusInfo DeviceStatusInfo (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceStatusInfo' {Maybe POSIX
connectionStatusUpdatedTime :: Maybe POSIX
$sel:connectionStatusUpdatedTime:DeviceStatusInfo' :: DeviceStatusInfo -> Maybe POSIX
connectionStatusUpdatedTime} -> Maybe POSIX
connectionStatusUpdatedTime) (\s :: DeviceStatusInfo
s@DeviceStatusInfo' {} Maybe POSIX
a -> DeviceStatusInfo
s {$sel:connectionStatusUpdatedTime:DeviceStatusInfo' :: Maybe POSIX
connectionStatusUpdatedTime = Maybe POSIX
a} :: DeviceStatusInfo) ((Maybe POSIX -> f (Maybe POSIX))
 -> DeviceStatusInfo -> f DeviceStatusInfo)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DeviceStatusInfo
-> f DeviceStatusInfo
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

-- | One or more device status detail descriptions.
deviceStatusInfo_deviceStatusDetails :: Lens.Lens' DeviceStatusInfo (Prelude.Maybe [DeviceStatusDetail])
deviceStatusInfo_deviceStatusDetails :: (Maybe [DeviceStatusDetail] -> f (Maybe [DeviceStatusDetail]))
-> DeviceStatusInfo -> f DeviceStatusInfo
deviceStatusInfo_deviceStatusDetails = (DeviceStatusInfo -> Maybe [DeviceStatusDetail])
-> (DeviceStatusInfo
    -> Maybe [DeviceStatusDetail] -> DeviceStatusInfo)
-> Lens
     DeviceStatusInfo
     DeviceStatusInfo
     (Maybe [DeviceStatusDetail])
     (Maybe [DeviceStatusDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceStatusInfo' {Maybe [DeviceStatusDetail]
deviceStatusDetails :: Maybe [DeviceStatusDetail]
$sel:deviceStatusDetails:DeviceStatusInfo' :: DeviceStatusInfo -> Maybe [DeviceStatusDetail]
deviceStatusDetails} -> Maybe [DeviceStatusDetail]
deviceStatusDetails) (\s :: DeviceStatusInfo
s@DeviceStatusInfo' {} Maybe [DeviceStatusDetail]
a -> DeviceStatusInfo
s {$sel:deviceStatusDetails:DeviceStatusInfo' :: Maybe [DeviceStatusDetail]
deviceStatusDetails = Maybe [DeviceStatusDetail]
a} :: DeviceStatusInfo) ((Maybe [DeviceStatusDetail] -> f (Maybe [DeviceStatusDetail]))
 -> DeviceStatusInfo -> f DeviceStatusInfo)
-> ((Maybe [DeviceStatusDetail] -> f (Maybe [DeviceStatusDetail]))
    -> Maybe [DeviceStatusDetail] -> f (Maybe [DeviceStatusDetail]))
-> (Maybe [DeviceStatusDetail] -> f (Maybe [DeviceStatusDetail]))
-> DeviceStatusInfo
-> f DeviceStatusInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DeviceStatusDetail]
  [DeviceStatusDetail]
  [DeviceStatusDetail]
  [DeviceStatusDetail]
-> Iso
     (Maybe [DeviceStatusDetail])
     (Maybe [DeviceStatusDetail])
     (Maybe [DeviceStatusDetail])
     (Maybe [DeviceStatusDetail])
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
  [DeviceStatusDetail]
  [DeviceStatusDetail]
  [DeviceStatusDetail]
  [DeviceStatusDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The latest available information about the connection status of a
-- device.
deviceStatusInfo_connectionStatus :: Lens.Lens' DeviceStatusInfo (Prelude.Maybe ConnectionStatus)
deviceStatusInfo_connectionStatus :: (Maybe ConnectionStatus -> f (Maybe ConnectionStatus))
-> DeviceStatusInfo -> f DeviceStatusInfo
deviceStatusInfo_connectionStatus = (DeviceStatusInfo -> Maybe ConnectionStatus)
-> (DeviceStatusInfo -> Maybe ConnectionStatus -> DeviceStatusInfo)
-> Lens
     DeviceStatusInfo
     DeviceStatusInfo
     (Maybe ConnectionStatus)
     (Maybe ConnectionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceStatusInfo' {Maybe ConnectionStatus
connectionStatus :: Maybe ConnectionStatus
$sel:connectionStatus:DeviceStatusInfo' :: DeviceStatusInfo -> Maybe ConnectionStatus
connectionStatus} -> Maybe ConnectionStatus
connectionStatus) (\s :: DeviceStatusInfo
s@DeviceStatusInfo' {} Maybe ConnectionStatus
a -> DeviceStatusInfo
s {$sel:connectionStatus:DeviceStatusInfo' :: Maybe ConnectionStatus
connectionStatus = Maybe ConnectionStatus
a} :: DeviceStatusInfo)

instance Core.FromJSON DeviceStatusInfo where
  parseJSON :: Value -> Parser DeviceStatusInfo
parseJSON =
    String
-> (Object -> Parser DeviceStatusInfo)
-> Value
-> Parser DeviceStatusInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeviceStatusInfo"
      ( \Object
x ->
          Maybe POSIX
-> Maybe [DeviceStatusDetail]
-> Maybe ConnectionStatus
-> DeviceStatusInfo
DeviceStatusInfo'
            (Maybe POSIX
 -> Maybe [DeviceStatusDetail]
 -> Maybe ConnectionStatus
 -> DeviceStatusInfo)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe [DeviceStatusDetail]
      -> Maybe ConnectionStatus -> DeviceStatusInfo)
forall (f :: * -> *) a b. Functor 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
"ConnectionStatusUpdatedTime")
            Parser
  (Maybe [DeviceStatusDetail]
   -> Maybe ConnectionStatus -> DeviceStatusInfo)
-> Parser (Maybe [DeviceStatusDetail])
-> Parser (Maybe ConnectionStatus -> DeviceStatusInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [DeviceStatusDetail]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeviceStatusDetails"
                            Parser (Maybe (Maybe [DeviceStatusDetail]))
-> Maybe [DeviceStatusDetail]
-> Parser (Maybe [DeviceStatusDetail])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DeviceStatusDetail]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe ConnectionStatus -> DeviceStatusInfo)
-> Parser (Maybe ConnectionStatus) -> Parser DeviceStatusInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConnectionStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionStatus")
      )

instance Prelude.Hashable DeviceStatusInfo

instance Prelude.NFData DeviceStatusInfo