{-# 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.IoTSiteWise.Types.GatewayPlatform
-- 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.IoTSiteWise.Types.GatewayPlatform where

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

-- | Contains a gateway\'s platform information.
--
-- /See:/ 'newGatewayPlatform' smart constructor.
data GatewayPlatform = GatewayPlatform'
  { -- | A gateway that runs on IoT Greengrass.
    GatewayPlatform -> Maybe Greengrass
greengrass :: Prelude.Maybe Greengrass,
    -- | A gateway that runs on IoT Greengrass V2.
    GatewayPlatform -> Maybe GreengrassV2
greengrassV2 :: Prelude.Maybe GreengrassV2
  }
  deriving (GatewayPlatform -> GatewayPlatform -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GatewayPlatform -> GatewayPlatform -> Bool
$c/= :: GatewayPlatform -> GatewayPlatform -> Bool
== :: GatewayPlatform -> GatewayPlatform -> Bool
$c== :: GatewayPlatform -> GatewayPlatform -> Bool
Prelude.Eq, ReadPrec [GatewayPlatform]
ReadPrec GatewayPlatform
Int -> ReadS GatewayPlatform
ReadS [GatewayPlatform]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GatewayPlatform]
$creadListPrec :: ReadPrec [GatewayPlatform]
readPrec :: ReadPrec GatewayPlatform
$creadPrec :: ReadPrec GatewayPlatform
readList :: ReadS [GatewayPlatform]
$creadList :: ReadS [GatewayPlatform]
readsPrec :: Int -> ReadS GatewayPlatform
$creadsPrec :: Int -> ReadS GatewayPlatform
Prelude.Read, Int -> GatewayPlatform -> ShowS
[GatewayPlatform] -> ShowS
GatewayPlatform -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GatewayPlatform] -> ShowS
$cshowList :: [GatewayPlatform] -> ShowS
show :: GatewayPlatform -> String
$cshow :: GatewayPlatform -> String
showsPrec :: Int -> GatewayPlatform -> ShowS
$cshowsPrec :: Int -> GatewayPlatform -> ShowS
Prelude.Show, forall x. Rep GatewayPlatform x -> GatewayPlatform
forall x. GatewayPlatform -> Rep GatewayPlatform x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GatewayPlatform x -> GatewayPlatform
$cfrom :: forall x. GatewayPlatform -> Rep GatewayPlatform x
Prelude.Generic)

-- |
-- Create a value of 'GatewayPlatform' 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:
--
-- 'greengrass', 'gatewayPlatform_greengrass' - A gateway that runs on IoT Greengrass.
--
-- 'greengrassV2', 'gatewayPlatform_greengrassV2' - A gateway that runs on IoT Greengrass V2.
newGatewayPlatform ::
  GatewayPlatform
newGatewayPlatform :: GatewayPlatform
newGatewayPlatform =
  GatewayPlatform'
    { $sel:greengrass:GatewayPlatform' :: Maybe Greengrass
greengrass = forall a. Maybe a
Prelude.Nothing,
      $sel:greengrassV2:GatewayPlatform' :: Maybe GreengrassV2
greengrassV2 = forall a. Maybe a
Prelude.Nothing
    }

-- | A gateway that runs on IoT Greengrass.
gatewayPlatform_greengrass :: Lens.Lens' GatewayPlatform (Prelude.Maybe Greengrass)
gatewayPlatform_greengrass :: Lens' GatewayPlatform (Maybe Greengrass)
gatewayPlatform_greengrass = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatewayPlatform' {Maybe Greengrass
greengrass :: Maybe Greengrass
$sel:greengrass:GatewayPlatform' :: GatewayPlatform -> Maybe Greengrass
greengrass} -> Maybe Greengrass
greengrass) (\s :: GatewayPlatform
s@GatewayPlatform' {} Maybe Greengrass
a -> GatewayPlatform
s {$sel:greengrass:GatewayPlatform' :: Maybe Greengrass
greengrass = Maybe Greengrass
a} :: GatewayPlatform)

-- | A gateway that runs on IoT Greengrass V2.
gatewayPlatform_greengrassV2 :: Lens.Lens' GatewayPlatform (Prelude.Maybe GreengrassV2)
gatewayPlatform_greengrassV2 :: Lens' GatewayPlatform (Maybe GreengrassV2)
gatewayPlatform_greengrassV2 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatewayPlatform' {Maybe GreengrassV2
greengrassV2 :: Maybe GreengrassV2
$sel:greengrassV2:GatewayPlatform' :: GatewayPlatform -> Maybe GreengrassV2
greengrassV2} -> Maybe GreengrassV2
greengrassV2) (\s :: GatewayPlatform
s@GatewayPlatform' {} Maybe GreengrassV2
a -> GatewayPlatform
s {$sel:greengrassV2:GatewayPlatform' :: Maybe GreengrassV2
greengrassV2 = Maybe GreengrassV2
a} :: GatewayPlatform)

instance Data.FromJSON GatewayPlatform where
  parseJSON :: Value -> Parser GatewayPlatform
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GatewayPlatform"
      ( \Object
x ->
          Maybe Greengrass -> Maybe GreengrassV2 -> GatewayPlatform
GatewayPlatform'
            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
"greengrass")
            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
"greengrassV2")
      )

instance Prelude.Hashable GatewayPlatform where
  hashWithSalt :: Int -> GatewayPlatform -> Int
hashWithSalt Int
_salt GatewayPlatform' {Maybe Greengrass
Maybe GreengrassV2
greengrassV2 :: Maybe GreengrassV2
greengrass :: Maybe Greengrass
$sel:greengrassV2:GatewayPlatform' :: GatewayPlatform -> Maybe GreengrassV2
$sel:greengrass:GatewayPlatform' :: GatewayPlatform -> Maybe Greengrass
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Greengrass
greengrass
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GreengrassV2
greengrassV2

instance Prelude.NFData GatewayPlatform where
  rnf :: GatewayPlatform -> ()
rnf GatewayPlatform' {Maybe Greengrass
Maybe GreengrassV2
greengrassV2 :: Maybe GreengrassV2
greengrass :: Maybe Greengrass
$sel:greengrassV2:GatewayPlatform' :: GatewayPlatform -> Maybe GreengrassV2
$sel:greengrass:GatewayPlatform' :: GatewayPlatform -> Maybe Greengrass
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Greengrass
greengrass
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GreengrassV2
greengrassV2

instance Data.ToJSON GatewayPlatform where
  toJSON :: GatewayPlatform -> Value
toJSON GatewayPlatform' {Maybe Greengrass
Maybe GreengrassV2
greengrassV2 :: Maybe GreengrassV2
greengrass :: Maybe Greengrass
$sel:greengrassV2:GatewayPlatform' :: GatewayPlatform -> Maybe GreengrassV2
$sel:greengrass:GatewayPlatform' :: GatewayPlatform -> Maybe Greengrass
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"greengrass" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Greengrass
greengrass,
            (Key
"greengrassV2" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GreengrassV2
greengrassV2
          ]
      )