{-# 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.GreengrassV2.Types.AssociatedClientDevice
-- 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.GreengrassV2.Types.AssociatedClientDevice where

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

-- | Contains information about a client device that is associated to a core
-- device for cloud discovery.
--
-- /See:/ 'newAssociatedClientDevice' smart constructor.
data AssociatedClientDevice = AssociatedClientDevice'
  { -- | The time that the client device was associated, expressed in ISO 8601
    -- format.
    AssociatedClientDevice -> Maybe POSIX
associationTimestamp :: Prelude.Maybe Core.POSIX,
    -- | The name of the IoT thing that represents the associated client device.
    AssociatedClientDevice -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text
  }
  deriving (AssociatedClientDevice -> AssociatedClientDevice -> Bool
(AssociatedClientDevice -> AssociatedClientDevice -> Bool)
-> (AssociatedClientDevice -> AssociatedClientDevice -> Bool)
-> Eq AssociatedClientDevice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociatedClientDevice -> AssociatedClientDevice -> Bool
$c/= :: AssociatedClientDevice -> AssociatedClientDevice -> Bool
== :: AssociatedClientDevice -> AssociatedClientDevice -> Bool
$c== :: AssociatedClientDevice -> AssociatedClientDevice -> Bool
Prelude.Eq, ReadPrec [AssociatedClientDevice]
ReadPrec AssociatedClientDevice
Int -> ReadS AssociatedClientDevice
ReadS [AssociatedClientDevice]
(Int -> ReadS AssociatedClientDevice)
-> ReadS [AssociatedClientDevice]
-> ReadPrec AssociatedClientDevice
-> ReadPrec [AssociatedClientDevice]
-> Read AssociatedClientDevice
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociatedClientDevice]
$creadListPrec :: ReadPrec [AssociatedClientDevice]
readPrec :: ReadPrec AssociatedClientDevice
$creadPrec :: ReadPrec AssociatedClientDevice
readList :: ReadS [AssociatedClientDevice]
$creadList :: ReadS [AssociatedClientDevice]
readsPrec :: Int -> ReadS AssociatedClientDevice
$creadsPrec :: Int -> ReadS AssociatedClientDevice
Prelude.Read, Int -> AssociatedClientDevice -> ShowS
[AssociatedClientDevice] -> ShowS
AssociatedClientDevice -> String
(Int -> AssociatedClientDevice -> ShowS)
-> (AssociatedClientDevice -> String)
-> ([AssociatedClientDevice] -> ShowS)
-> Show AssociatedClientDevice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociatedClientDevice] -> ShowS
$cshowList :: [AssociatedClientDevice] -> ShowS
show :: AssociatedClientDevice -> String
$cshow :: AssociatedClientDevice -> String
showsPrec :: Int -> AssociatedClientDevice -> ShowS
$cshowsPrec :: Int -> AssociatedClientDevice -> ShowS
Prelude.Show, (forall x. AssociatedClientDevice -> Rep AssociatedClientDevice x)
-> (forall x.
    Rep AssociatedClientDevice x -> AssociatedClientDevice)
-> Generic AssociatedClientDevice
forall x. Rep AssociatedClientDevice x -> AssociatedClientDevice
forall x. AssociatedClientDevice -> Rep AssociatedClientDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociatedClientDevice x -> AssociatedClientDevice
$cfrom :: forall x. AssociatedClientDevice -> Rep AssociatedClientDevice x
Prelude.Generic)

-- |
-- Create a value of 'AssociatedClientDevice' 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:
--
-- 'associationTimestamp', 'associatedClientDevice_associationTimestamp' - The time that the client device was associated, expressed in ISO 8601
-- format.
--
-- 'thingName', 'associatedClientDevice_thingName' - The name of the IoT thing that represents the associated client device.
newAssociatedClientDevice ::
  AssociatedClientDevice
newAssociatedClientDevice :: AssociatedClientDevice
newAssociatedClientDevice =
  AssociatedClientDevice' :: Maybe POSIX -> Maybe Text -> AssociatedClientDevice
AssociatedClientDevice'
    { $sel:associationTimestamp:AssociatedClientDevice' :: Maybe POSIX
associationTimestamp =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:AssociatedClientDevice' :: Maybe Text
thingName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The time that the client device was associated, expressed in ISO 8601
-- format.
associatedClientDevice_associationTimestamp :: Lens.Lens' AssociatedClientDevice (Prelude.Maybe Prelude.UTCTime)
associatedClientDevice_associationTimestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AssociatedClientDevice -> f AssociatedClientDevice
associatedClientDevice_associationTimestamp = (AssociatedClientDevice -> Maybe POSIX)
-> (AssociatedClientDevice
    -> Maybe POSIX -> AssociatedClientDevice)
-> Lens
     AssociatedClientDevice
     AssociatedClientDevice
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatedClientDevice' {Maybe POSIX
associationTimestamp :: Maybe POSIX
$sel:associationTimestamp:AssociatedClientDevice' :: AssociatedClientDevice -> Maybe POSIX
associationTimestamp} -> Maybe POSIX
associationTimestamp) (\s :: AssociatedClientDevice
s@AssociatedClientDevice' {} Maybe POSIX
a -> AssociatedClientDevice
s {$sel:associationTimestamp:AssociatedClientDevice' :: Maybe POSIX
associationTimestamp = Maybe POSIX
a} :: AssociatedClientDevice) ((Maybe POSIX -> f (Maybe POSIX))
 -> AssociatedClientDevice -> f AssociatedClientDevice)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AssociatedClientDevice
-> f AssociatedClientDevice
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 name of the IoT thing that represents the associated client device.
associatedClientDevice_thingName :: Lens.Lens' AssociatedClientDevice (Prelude.Maybe Prelude.Text)
associatedClientDevice_thingName :: (Maybe Text -> f (Maybe Text))
-> AssociatedClientDevice -> f AssociatedClientDevice
associatedClientDevice_thingName = (AssociatedClientDevice -> Maybe Text)
-> (AssociatedClientDevice -> Maybe Text -> AssociatedClientDevice)
-> Lens
     AssociatedClientDevice
     AssociatedClientDevice
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociatedClientDevice' {Maybe Text
thingName :: Maybe Text
$sel:thingName:AssociatedClientDevice' :: AssociatedClientDevice -> Maybe Text
thingName} -> Maybe Text
thingName) (\s :: AssociatedClientDevice
s@AssociatedClientDevice' {} Maybe Text
a -> AssociatedClientDevice
s {$sel:thingName:AssociatedClientDevice' :: Maybe Text
thingName = Maybe Text
a} :: AssociatedClientDevice)

instance Core.FromJSON AssociatedClientDevice where
  parseJSON :: Value -> Parser AssociatedClientDevice
parseJSON =
    String
-> (Object -> Parser AssociatedClientDevice)
-> Value
-> Parser AssociatedClientDevice
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AssociatedClientDevice"
      ( \Object
x ->
          Maybe POSIX -> Maybe Text -> AssociatedClientDevice
AssociatedClientDevice'
            (Maybe POSIX -> Maybe Text -> AssociatedClientDevice)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> AssociatedClientDevice)
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
"associationTimestamp")
            Parser (Maybe Text -> AssociatedClientDevice)
-> Parser (Maybe Text) -> Parser AssociatedClientDevice
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
"thingName")
      )

instance Prelude.Hashable AssociatedClientDevice

instance Prelude.NFData AssociatedClientDevice