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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.Types.Greengrass
import Amazonka.IoTSiteWise.Types.GreengrassV2
import qualified Amazonka.Lens as Lens
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
(GatewayPlatform -> GatewayPlatform -> Bool)
-> (GatewayPlatform -> GatewayPlatform -> Bool)
-> Eq GatewayPlatform
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]
(Int -> ReadS GatewayPlatform)
-> ReadS [GatewayPlatform]
-> ReadPrec GatewayPlatform
-> ReadPrec [GatewayPlatform]
-> Read 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
(Int -> GatewayPlatform -> ShowS)
-> (GatewayPlatform -> String)
-> ([GatewayPlatform] -> ShowS)
-> Show GatewayPlatform
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. GatewayPlatform -> Rep GatewayPlatform x)
-> (forall x. Rep GatewayPlatform x -> GatewayPlatform)
-> Generic GatewayPlatform
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' :: Maybe Greengrass -> Maybe GreengrassV2 -> GatewayPlatform
GatewayPlatform'
    { $sel:greengrass:GatewayPlatform' :: Maybe Greengrass
greengrass = Maybe Greengrass
forall a. Maybe a
Prelude.Nothing,
      $sel:greengrassV2:GatewayPlatform' :: Maybe GreengrassV2
greengrassV2 = Maybe GreengrassV2
forall a. Maybe a
Prelude.Nothing
    }

-- | A gateway that runs on IoT Greengrass.
gatewayPlatform_greengrass :: Lens.Lens' GatewayPlatform (Prelude.Maybe Greengrass)
gatewayPlatform_greengrass :: (Maybe Greengrass -> f (Maybe Greengrass))
-> GatewayPlatform -> f GatewayPlatform
gatewayPlatform_greengrass = (GatewayPlatform -> Maybe Greengrass)
-> (GatewayPlatform -> Maybe Greengrass -> GatewayPlatform)
-> Lens
     GatewayPlatform
     GatewayPlatform
     (Maybe Greengrass)
     (Maybe 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 :: (Maybe GreengrassV2 -> f (Maybe GreengrassV2))
-> GatewayPlatform -> f GatewayPlatform
gatewayPlatform_greengrassV2 = (GatewayPlatform -> Maybe GreengrassV2)
-> (GatewayPlatform -> Maybe GreengrassV2 -> GatewayPlatform)
-> Lens
     GatewayPlatform
     GatewayPlatform
     (Maybe GreengrassV2)
     (Maybe 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 Core.FromJSON GatewayPlatform where
  parseJSON :: Value -> Parser GatewayPlatform
parseJSON =
    String
-> (Object -> Parser GatewayPlatform)
-> Value
-> Parser GatewayPlatform
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GatewayPlatform"
      ( \Object
x ->
          Maybe Greengrass -> Maybe GreengrassV2 -> GatewayPlatform
GatewayPlatform'
            (Maybe Greengrass -> Maybe GreengrassV2 -> GatewayPlatform)
-> Parser (Maybe Greengrass)
-> Parser (Maybe GreengrassV2 -> GatewayPlatform)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Greengrass)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"greengrass")
            Parser (Maybe GreengrassV2 -> GatewayPlatform)
-> Parser (Maybe GreengrassV2) -> Parser GatewayPlatform
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GreengrassV2)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"greengrassV2")
      )

instance Prelude.Hashable GatewayPlatform

instance Prelude.NFData GatewayPlatform

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"greengrass" Text -> Greengrass -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Greengrass -> Pair) -> Maybe Greengrass -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Greengrass
greengrass,
            (Text
"greengrassV2" Text -> GreengrassV2 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (GreengrassV2 -> Pair) -> Maybe GreengrassV2 -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GreengrassV2
greengrassV2
          ]
      )