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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GreengrassV2.Types.CoreDeviceStatus
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a Greengrass core device, which is an IoT
-- thing that runs the IoT Greengrass Core software.
--
-- /See:/ 'newCoreDevice' smart constructor.
data CoreDevice = CoreDevice'
  { -- | The name of the core device. This is also the name of the IoT thing.
    CoreDevice -> Maybe Text
coreDeviceThingName :: Prelude.Maybe Prelude.Text,
    -- | The time at which the core device\'s status last updated, expressed in
    -- ISO 8601 format.
    CoreDevice -> Maybe POSIX
lastStatusUpdateTimestamp :: Prelude.Maybe Data.POSIX,
    -- | The status of the core device. Core devices can have the following
    -- statuses:
    --
    -- -   @HEALTHY@ – The IoT Greengrass Core software and all components run
    --     on the core device without issue.
    --
    -- -   @UNHEALTHY@ – The IoT Greengrass Core software or a component is in
    --     a failed state on the core device.
    CoreDevice -> Maybe CoreDeviceStatus
status :: Prelude.Maybe CoreDeviceStatus
  }
  deriving (CoreDevice -> CoreDevice -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CoreDevice -> CoreDevice -> Bool
$c/= :: CoreDevice -> CoreDevice -> Bool
== :: CoreDevice -> CoreDevice -> Bool
$c== :: CoreDevice -> CoreDevice -> Bool
Prelude.Eq, ReadPrec [CoreDevice]
ReadPrec CoreDevice
Int -> ReadS CoreDevice
ReadS [CoreDevice]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CoreDevice]
$creadListPrec :: ReadPrec [CoreDevice]
readPrec :: ReadPrec CoreDevice
$creadPrec :: ReadPrec CoreDevice
readList :: ReadS [CoreDevice]
$creadList :: ReadS [CoreDevice]
readsPrec :: Int -> ReadS CoreDevice
$creadsPrec :: Int -> ReadS CoreDevice
Prelude.Read, Int -> CoreDevice -> ShowS
[CoreDevice] -> ShowS
CoreDevice -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CoreDevice] -> ShowS
$cshowList :: [CoreDevice] -> ShowS
show :: CoreDevice -> String
$cshow :: CoreDevice -> String
showsPrec :: Int -> CoreDevice -> ShowS
$cshowsPrec :: Int -> CoreDevice -> ShowS
Prelude.Show, forall x. Rep CoreDevice x -> CoreDevice
forall x. CoreDevice -> Rep CoreDevice x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CoreDevice x -> CoreDevice
$cfrom :: forall x. CoreDevice -> Rep CoreDevice x
Prelude.Generic)

-- |
-- Create a value of 'CoreDevice' 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:
--
-- 'coreDeviceThingName', 'coreDevice_coreDeviceThingName' - The name of the core device. This is also the name of the IoT thing.
--
-- 'lastStatusUpdateTimestamp', 'coreDevice_lastStatusUpdateTimestamp' - The time at which the core device\'s status last updated, expressed in
-- ISO 8601 format.
--
-- 'status', 'coreDevice_status' - The status of the core device. Core devices can have the following
-- statuses:
--
-- -   @HEALTHY@ – The IoT Greengrass Core software and all components run
--     on the core device without issue.
--
-- -   @UNHEALTHY@ – The IoT Greengrass Core software or a component is in
--     a failed state on the core device.
newCoreDevice ::
  CoreDevice
newCoreDevice :: CoreDevice
newCoreDevice =
  CoreDevice'
    { $sel:coreDeviceThingName:CoreDevice' :: Maybe Text
coreDeviceThingName = forall a. Maybe a
Prelude.Nothing,
      $sel:lastStatusUpdateTimestamp:CoreDevice' :: Maybe POSIX
lastStatusUpdateTimestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:status:CoreDevice' :: Maybe CoreDeviceStatus
status = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the core device. This is also the name of the IoT thing.
coreDevice_coreDeviceThingName :: Lens.Lens' CoreDevice (Prelude.Maybe Prelude.Text)
coreDevice_coreDeviceThingName :: Lens' CoreDevice (Maybe Text)
coreDevice_coreDeviceThingName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoreDevice' {Maybe Text
coreDeviceThingName :: Maybe Text
$sel:coreDeviceThingName:CoreDevice' :: CoreDevice -> Maybe Text
coreDeviceThingName} -> Maybe Text
coreDeviceThingName) (\s :: CoreDevice
s@CoreDevice' {} Maybe Text
a -> CoreDevice
s {$sel:coreDeviceThingName:CoreDevice' :: Maybe Text
coreDeviceThingName = Maybe Text
a} :: CoreDevice)

-- | The time at which the core device\'s status last updated, expressed in
-- ISO 8601 format.
coreDevice_lastStatusUpdateTimestamp :: Lens.Lens' CoreDevice (Prelude.Maybe Prelude.UTCTime)
coreDevice_lastStatusUpdateTimestamp :: Lens' CoreDevice (Maybe UTCTime)
coreDevice_lastStatusUpdateTimestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoreDevice' {Maybe POSIX
lastStatusUpdateTimestamp :: Maybe POSIX
$sel:lastStatusUpdateTimestamp:CoreDevice' :: CoreDevice -> Maybe POSIX
lastStatusUpdateTimestamp} -> Maybe POSIX
lastStatusUpdateTimestamp) (\s :: CoreDevice
s@CoreDevice' {} Maybe POSIX
a -> CoreDevice
s {$sel:lastStatusUpdateTimestamp:CoreDevice' :: Maybe POSIX
lastStatusUpdateTimestamp = Maybe POSIX
a} :: CoreDevice) 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 status of the core device. Core devices can have the following
-- statuses:
--
-- -   @HEALTHY@ – The IoT Greengrass Core software and all components run
--     on the core device without issue.
--
-- -   @UNHEALTHY@ – The IoT Greengrass Core software or a component is in
--     a failed state on the core device.
coreDevice_status :: Lens.Lens' CoreDevice (Prelude.Maybe CoreDeviceStatus)
coreDevice_status :: Lens' CoreDevice (Maybe CoreDeviceStatus)
coreDevice_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CoreDevice' {Maybe CoreDeviceStatus
status :: Maybe CoreDeviceStatus
$sel:status:CoreDevice' :: CoreDevice -> Maybe CoreDeviceStatus
status} -> Maybe CoreDeviceStatus
status) (\s :: CoreDevice
s@CoreDevice' {} Maybe CoreDeviceStatus
a -> CoreDevice
s {$sel:status:CoreDevice' :: Maybe CoreDeviceStatus
status = Maybe CoreDeviceStatus
a} :: CoreDevice)

instance Data.FromJSON CoreDevice where
  parseJSON :: Value -> Parser CoreDevice
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CoreDevice"
      ( \Object
x ->
          Maybe Text -> Maybe POSIX -> Maybe CoreDeviceStatus -> CoreDevice
CoreDevice'
            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
"coreDeviceThingName")
            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
"lastStatusUpdateTimestamp")
            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
"status")
      )

instance Prelude.Hashable CoreDevice where
  hashWithSalt :: Int -> CoreDevice -> Int
hashWithSalt Int
_salt CoreDevice' {Maybe Text
Maybe POSIX
Maybe CoreDeviceStatus
status :: Maybe CoreDeviceStatus
lastStatusUpdateTimestamp :: Maybe POSIX
coreDeviceThingName :: Maybe Text
$sel:status:CoreDevice' :: CoreDevice -> Maybe CoreDeviceStatus
$sel:lastStatusUpdateTimestamp:CoreDevice' :: CoreDevice -> Maybe POSIX
$sel:coreDeviceThingName:CoreDevice' :: CoreDevice -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
coreDeviceThingName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastStatusUpdateTimestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe CoreDeviceStatus
status

instance Prelude.NFData CoreDevice where
  rnf :: CoreDevice -> ()
rnf CoreDevice' {Maybe Text
Maybe POSIX
Maybe CoreDeviceStatus
status :: Maybe CoreDeviceStatus
lastStatusUpdateTimestamp :: Maybe POSIX
coreDeviceThingName :: Maybe Text
$sel:status:CoreDevice' :: CoreDevice -> Maybe CoreDeviceStatus
$sel:lastStatusUpdateTimestamp:CoreDevice' :: CoreDevice -> Maybe POSIX
$sel:coreDeviceThingName:CoreDevice' :: CoreDevice -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
coreDeviceThingName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastStatusUpdateTimestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe CoreDeviceStatus
status