{-# 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.Panorama.Types.Device
-- 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.Panorama.Types.Device where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Panorama.Types.DeviceStatus
import qualified Amazonka.Prelude as Prelude

-- | A device.
--
-- /See:/ 'newDevice' smart constructor.
data Device = Device'
  { -- | When the device was updated.
    Device -> Maybe POSIX
lastUpdatedTime :: Prelude.Maybe Core.POSIX,
    -- | The device\'s provisioning status.
    Device -> Maybe DeviceStatus
provisioningStatus :: Prelude.Maybe DeviceStatus,
    -- | When the device was created.
    Device -> Maybe POSIX
createdTime :: Prelude.Maybe Core.POSIX,
    -- | The device\'s name.
    Device -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The device\'s ID.
    Device -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
    -- | The device\'s lease expiration time.
    Device -> Maybe POSIX
leaseExpirationTime :: Prelude.Maybe Core.POSIX
  }
  deriving (Device -> Device -> Bool
(Device -> Device -> Bool)
-> (Device -> Device -> Bool) -> Eq Device
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Device -> Device -> Bool
$c/= :: Device -> Device -> Bool
== :: Device -> Device -> Bool
$c== :: Device -> Device -> Bool
Prelude.Eq, ReadPrec [Device]
ReadPrec Device
Int -> ReadS Device
ReadS [Device]
(Int -> ReadS Device)
-> ReadS [Device]
-> ReadPrec Device
-> ReadPrec [Device]
-> Read Device
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Device]
$creadListPrec :: ReadPrec [Device]
readPrec :: ReadPrec Device
$creadPrec :: ReadPrec Device
readList :: ReadS [Device]
$creadList :: ReadS [Device]
readsPrec :: Int -> ReadS Device
$creadsPrec :: Int -> ReadS Device
Prelude.Read, Int -> Device -> ShowS
[Device] -> ShowS
Device -> String
(Int -> Device -> ShowS)
-> (Device -> String) -> ([Device] -> ShowS) -> Show Device
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Device] -> ShowS
$cshowList :: [Device] -> ShowS
show :: Device -> String
$cshow :: Device -> String
showsPrec :: Int -> Device -> ShowS
$cshowsPrec :: Int -> Device -> ShowS
Prelude.Show, (forall x. Device -> Rep Device x)
-> (forall x. Rep Device x -> Device) -> Generic Device
forall x. Rep Device x -> Device
forall x. Device -> Rep Device x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Device x -> Device
$cfrom :: forall x. Device -> Rep Device x
Prelude.Generic)

-- |
-- Create a value of 'Device' 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:
--
-- 'lastUpdatedTime', 'device_lastUpdatedTime' - When the device was updated.
--
-- 'provisioningStatus', 'device_provisioningStatus' - The device\'s provisioning status.
--
-- 'createdTime', 'device_createdTime' - When the device was created.
--
-- 'name', 'device_name' - The device\'s name.
--
-- 'deviceId', 'device_deviceId' - The device\'s ID.
--
-- 'leaseExpirationTime', 'device_leaseExpirationTime' - The device\'s lease expiration time.
newDevice ::
  Device
newDevice :: Device
newDevice =
  Device' :: Maybe POSIX
-> Maybe DeviceStatus
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Device
Device'
    { $sel:lastUpdatedTime:Device' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:provisioningStatus:Device' :: Maybe DeviceStatus
provisioningStatus = Maybe DeviceStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:createdTime:Device' :: Maybe POSIX
createdTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Device' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceId:Device' :: Maybe Text
deviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:leaseExpirationTime:Device' :: Maybe POSIX
leaseExpirationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | When the device was updated.
device_lastUpdatedTime :: Lens.Lens' Device (Prelude.Maybe Prelude.UTCTime)
device_lastUpdatedTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Device -> f Device
device_lastUpdatedTime = (Device -> Maybe POSIX)
-> (Device -> Maybe POSIX -> Device)
-> Lens Device Device (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe POSIX
lastUpdatedTime :: Maybe POSIX
$sel:lastUpdatedTime:Device' :: Device -> Maybe POSIX
lastUpdatedTime} -> Maybe POSIX
lastUpdatedTime) (\s :: Device
s@Device' {} Maybe POSIX
a -> Device
s {$sel:lastUpdatedTime:Device' :: Maybe POSIX
lastUpdatedTime = Maybe POSIX
a} :: Device) ((Maybe POSIX -> f (Maybe POSIX)) -> Device -> f Device)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Device
-> f Device
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

-- | The device\'s provisioning status.
device_provisioningStatus :: Lens.Lens' Device (Prelude.Maybe DeviceStatus)
device_provisioningStatus :: (Maybe DeviceStatus -> f (Maybe DeviceStatus))
-> Device -> f Device
device_provisioningStatus = (Device -> Maybe DeviceStatus)
-> (Device -> Maybe DeviceStatus -> Device)
-> Lens Device Device (Maybe DeviceStatus) (Maybe DeviceStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe DeviceStatus
provisioningStatus :: Maybe DeviceStatus
$sel:provisioningStatus:Device' :: Device -> Maybe DeviceStatus
provisioningStatus} -> Maybe DeviceStatus
provisioningStatus) (\s :: Device
s@Device' {} Maybe DeviceStatus
a -> Device
s {$sel:provisioningStatus:Device' :: Maybe DeviceStatus
provisioningStatus = Maybe DeviceStatus
a} :: Device)

-- | When the device was created.
device_createdTime :: Lens.Lens' Device (Prelude.Maybe Prelude.UTCTime)
device_createdTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Device -> f Device
device_createdTime = (Device -> Maybe POSIX)
-> (Device -> Maybe POSIX -> Device)
-> Lens Device Device (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe POSIX
createdTime :: Maybe POSIX
$sel:createdTime:Device' :: Device -> Maybe POSIX
createdTime} -> Maybe POSIX
createdTime) (\s :: Device
s@Device' {} Maybe POSIX
a -> Device
s {$sel:createdTime:Device' :: Maybe POSIX
createdTime = Maybe POSIX
a} :: Device) ((Maybe POSIX -> f (Maybe POSIX)) -> Device -> f Device)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Device
-> f Device
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

-- | The device\'s name.
device_name :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_name :: (Maybe Text -> f (Maybe Text)) -> Device -> f Device
device_name = (Device -> Maybe Text)
-> (Device -> Maybe Text -> Device)
-> Lens Device Device (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Text
name :: Maybe Text
$sel:name:Device' :: Device -> Maybe Text
name} -> Maybe Text
name) (\s :: Device
s@Device' {} Maybe Text
a -> Device
s {$sel:name:Device' :: Maybe Text
name = Maybe Text
a} :: Device)

-- | The device\'s ID.
device_deviceId :: Lens.Lens' Device (Prelude.Maybe Prelude.Text)
device_deviceId :: (Maybe Text -> f (Maybe Text)) -> Device -> f Device
device_deviceId = (Device -> Maybe Text)
-> (Device -> Maybe Text -> Device)
-> Lens Device Device (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:Device' :: Device -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: Device
s@Device' {} Maybe Text
a -> Device
s {$sel:deviceId:Device' :: Maybe Text
deviceId = Maybe Text
a} :: Device)

-- | The device\'s lease expiration time.
device_leaseExpirationTime :: Lens.Lens' Device (Prelude.Maybe Prelude.UTCTime)
device_leaseExpirationTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Device -> f Device
device_leaseExpirationTime = (Device -> Maybe POSIX)
-> (Device -> Maybe POSIX -> Device)
-> Lens Device Device (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe POSIX
leaseExpirationTime :: Maybe POSIX
$sel:leaseExpirationTime:Device' :: Device -> Maybe POSIX
leaseExpirationTime} -> Maybe POSIX
leaseExpirationTime) (\s :: Device
s@Device' {} Maybe POSIX
a -> Device
s {$sel:leaseExpirationTime:Device' :: Maybe POSIX
leaseExpirationTime = Maybe POSIX
a} :: Device) ((Maybe POSIX -> f (Maybe POSIX)) -> Device -> f Device)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Device
-> f Device
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 Device where
  parseJSON :: Value -> Parser Device
parseJSON =
    String -> (Object -> Parser Device) -> Value -> Parser Device
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Device"
      ( \Object
x ->
          Maybe POSIX
-> Maybe DeviceStatus
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe POSIX
-> Device
Device'
            (Maybe POSIX
 -> Maybe DeviceStatus
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe POSIX
 -> Device)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe DeviceStatus
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe POSIX
      -> Device)
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
"LastUpdatedTime")
            Parser
  (Maybe DeviceStatus
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe POSIX
   -> Device)
-> Parser (Maybe DeviceStatus)
-> Parser
     (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe POSIX -> Device)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeviceStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProvisioningStatus")
            Parser
  (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe POSIX -> Device)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> Device)
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
"CreatedTime")
            Parser (Maybe Text -> Maybe Text -> Maybe POSIX -> Device)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe POSIX -> Device)
forall (f :: * -> *) a b. Applicative f => 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
"Name")
            Parser (Maybe Text -> Maybe POSIX -> Device)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> Device)
forall (f :: * -> *) a b. Applicative f => 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
"DeviceId")
            Parser (Maybe POSIX -> Device)
-> Parser (Maybe POSIX) -> Parser Device
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
"LeaseExpirationTime")
      )

instance Prelude.Hashable Device

instance Prelude.NFData Device