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

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

-- | Contains details for a gateway that runs on IoT Greengrass V2. To create
-- a gateway that runs on IoT Greengrass V2, you must deploy the IoT
-- SiteWise Edge component to your gateway device. Your
-- <https://docs.aws.amazon.com/greengrass/v2/developerguide/device-service-role.html Greengrass device role>
-- must use the @AWSIoTSiteWiseEdgeAccess@ policy. For more information,
-- see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/sw-gateways.html Using IoT SiteWise at the edge>
-- in the /IoT SiteWise User Guide/.
--
-- /See:/ 'newGreengrassV2' smart constructor.
data GreengrassV2 = GreengrassV2'
  { -- | The name of the IoT thing for your IoT Greengrass V2 core device.
    GreengrassV2 -> Text
coreDeviceThingName :: Prelude.Text
  }
  deriving (GreengrassV2 -> GreengrassV2 -> Bool
(GreengrassV2 -> GreengrassV2 -> Bool)
-> (GreengrassV2 -> GreengrassV2 -> Bool) -> Eq GreengrassV2
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GreengrassV2 -> GreengrassV2 -> Bool
$c/= :: GreengrassV2 -> GreengrassV2 -> Bool
== :: GreengrassV2 -> GreengrassV2 -> Bool
$c== :: GreengrassV2 -> GreengrassV2 -> Bool
Prelude.Eq, ReadPrec [GreengrassV2]
ReadPrec GreengrassV2
Int -> ReadS GreengrassV2
ReadS [GreengrassV2]
(Int -> ReadS GreengrassV2)
-> ReadS [GreengrassV2]
-> ReadPrec GreengrassV2
-> ReadPrec [GreengrassV2]
-> Read GreengrassV2
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GreengrassV2]
$creadListPrec :: ReadPrec [GreengrassV2]
readPrec :: ReadPrec GreengrassV2
$creadPrec :: ReadPrec GreengrassV2
readList :: ReadS [GreengrassV2]
$creadList :: ReadS [GreengrassV2]
readsPrec :: Int -> ReadS GreengrassV2
$creadsPrec :: Int -> ReadS GreengrassV2
Prelude.Read, Int -> GreengrassV2 -> ShowS
[GreengrassV2] -> ShowS
GreengrassV2 -> String
(Int -> GreengrassV2 -> ShowS)
-> (GreengrassV2 -> String)
-> ([GreengrassV2] -> ShowS)
-> Show GreengrassV2
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GreengrassV2] -> ShowS
$cshowList :: [GreengrassV2] -> ShowS
show :: GreengrassV2 -> String
$cshow :: GreengrassV2 -> String
showsPrec :: Int -> GreengrassV2 -> ShowS
$cshowsPrec :: Int -> GreengrassV2 -> ShowS
Prelude.Show, (forall x. GreengrassV2 -> Rep GreengrassV2 x)
-> (forall x. Rep GreengrassV2 x -> GreengrassV2)
-> Generic GreengrassV2
forall x. Rep GreengrassV2 x -> GreengrassV2
forall x. GreengrassV2 -> Rep GreengrassV2 x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GreengrassV2 x -> GreengrassV2
$cfrom :: forall x. GreengrassV2 -> Rep GreengrassV2 x
Prelude.Generic)

-- |
-- Create a value of 'GreengrassV2' 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', 'greengrassV2_coreDeviceThingName' - The name of the IoT thing for your IoT Greengrass V2 core device.
newGreengrassV2 ::
  -- | 'coreDeviceThingName'
  Prelude.Text ->
  GreengrassV2
newGreengrassV2 :: Text -> GreengrassV2
newGreengrassV2 Text
pCoreDeviceThingName_ =
  GreengrassV2' :: Text -> GreengrassV2
GreengrassV2'
    { $sel:coreDeviceThingName:GreengrassV2' :: Text
coreDeviceThingName =
        Text
pCoreDeviceThingName_
    }

-- | The name of the IoT thing for your IoT Greengrass V2 core device.
greengrassV2_coreDeviceThingName :: Lens.Lens' GreengrassV2 Prelude.Text
greengrassV2_coreDeviceThingName :: (Text -> f Text) -> GreengrassV2 -> f GreengrassV2
greengrassV2_coreDeviceThingName = (GreengrassV2 -> Text)
-> (GreengrassV2 -> Text -> GreengrassV2)
-> Lens GreengrassV2 GreengrassV2 Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GreengrassV2' {Text
coreDeviceThingName :: Text
$sel:coreDeviceThingName:GreengrassV2' :: GreengrassV2 -> Text
coreDeviceThingName} -> Text
coreDeviceThingName) (\s :: GreengrassV2
s@GreengrassV2' {} Text
a -> GreengrassV2
s {$sel:coreDeviceThingName:GreengrassV2' :: Text
coreDeviceThingName = Text
a} :: GreengrassV2)

instance Core.FromJSON GreengrassV2 where
  parseJSON :: Value -> Parser GreengrassV2
parseJSON =
    String
-> (Object -> Parser GreengrassV2) -> Value -> Parser GreengrassV2
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GreengrassV2"
      ( \Object
x ->
          Text -> GreengrassV2
GreengrassV2'
            (Text -> GreengrassV2) -> Parser Text -> Parser GreengrassV2
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"coreDeviceThingName")
      )

instance Prelude.Hashable GreengrassV2

instance Prelude.NFData GreengrassV2

instance Core.ToJSON GreengrassV2 where
  toJSON :: GreengrassV2 -> Value
toJSON GreengrassV2' {Text
coreDeviceThingName :: Text
$sel:coreDeviceThingName:GreengrassV2' :: GreengrassV2 -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"coreDeviceThingName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
coreDeviceThingName)
          ]
      )