{-# 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.Greengrass
-- 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.Greengrass 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. To create a
-- gateway that runs on IoT Greengrass, you must add the IoT SiteWise
-- connector to a Greengrass group and deploy it. Your Greengrass group
-- must also have permissions to upload data to IoT SiteWise. For more
-- information, see
-- <https://docs.aws.amazon.com/iot-sitewise/latest/userguide/gateway-connector.html Ingesting data using a gateway>
-- in the /IoT SiteWise User Guide/.
--
-- /See:/ 'newGreengrass' smart constructor.
data Greengrass = Greengrass'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the Greengrass group. For more information about how to find a
    -- group\'s ARN, see
    -- <https://docs.aws.amazon.com/greengrass/latest/apireference/listgroups-get.html ListGroups>
    -- and
    -- <https://docs.aws.amazon.com/greengrass/latest/apireference/getgroup-get.html GetGroup>
    -- in the /IoT Greengrass API Reference/.
    Greengrass -> Text
groupArn :: Prelude.Text
  }
  deriving (Greengrass -> Greengrass -> Bool
(Greengrass -> Greengrass -> Bool)
-> (Greengrass -> Greengrass -> Bool) -> Eq Greengrass
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Greengrass -> Greengrass -> Bool
$c/= :: Greengrass -> Greengrass -> Bool
== :: Greengrass -> Greengrass -> Bool
$c== :: Greengrass -> Greengrass -> Bool
Prelude.Eq, ReadPrec [Greengrass]
ReadPrec Greengrass
Int -> ReadS Greengrass
ReadS [Greengrass]
(Int -> ReadS Greengrass)
-> ReadS [Greengrass]
-> ReadPrec Greengrass
-> ReadPrec [Greengrass]
-> Read Greengrass
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Greengrass]
$creadListPrec :: ReadPrec [Greengrass]
readPrec :: ReadPrec Greengrass
$creadPrec :: ReadPrec Greengrass
readList :: ReadS [Greengrass]
$creadList :: ReadS [Greengrass]
readsPrec :: Int -> ReadS Greengrass
$creadsPrec :: Int -> ReadS Greengrass
Prelude.Read, Int -> Greengrass -> ShowS
[Greengrass] -> ShowS
Greengrass -> String
(Int -> Greengrass -> ShowS)
-> (Greengrass -> String)
-> ([Greengrass] -> ShowS)
-> Show Greengrass
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Greengrass] -> ShowS
$cshowList :: [Greengrass] -> ShowS
show :: Greengrass -> String
$cshow :: Greengrass -> String
showsPrec :: Int -> Greengrass -> ShowS
$cshowsPrec :: Int -> Greengrass -> ShowS
Prelude.Show, (forall x. Greengrass -> Rep Greengrass x)
-> (forall x. Rep Greengrass x -> Greengrass) -> Generic Greengrass
forall x. Rep Greengrass x -> Greengrass
forall x. Greengrass -> Rep Greengrass x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Greengrass x -> Greengrass
$cfrom :: forall x. Greengrass -> Rep Greengrass x
Prelude.Generic)

-- |
-- Create a value of 'Greengrass' 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:
--
-- 'groupArn', 'greengrass_groupArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Greengrass group. For more information about how to find a
-- group\'s ARN, see
-- <https://docs.aws.amazon.com/greengrass/latest/apireference/listgroups-get.html ListGroups>
-- and
-- <https://docs.aws.amazon.com/greengrass/latest/apireference/getgroup-get.html GetGroup>
-- in the /IoT Greengrass API Reference/.
newGreengrass ::
  -- | 'groupArn'
  Prelude.Text ->
  Greengrass
newGreengrass :: Text -> Greengrass
newGreengrass Text
pGroupArn_ =
  Greengrass' :: Text -> Greengrass
Greengrass' {$sel:groupArn:Greengrass' :: Text
groupArn = Text
pGroupArn_}

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Greengrass group. For more information about how to find a
-- group\'s ARN, see
-- <https://docs.aws.amazon.com/greengrass/latest/apireference/listgroups-get.html ListGroups>
-- and
-- <https://docs.aws.amazon.com/greengrass/latest/apireference/getgroup-get.html GetGroup>
-- in the /IoT Greengrass API Reference/.
greengrass_groupArn :: Lens.Lens' Greengrass Prelude.Text
greengrass_groupArn :: (Text -> f Text) -> Greengrass -> f Greengrass
greengrass_groupArn = (Greengrass -> Text)
-> (Greengrass -> Text -> Greengrass)
-> Lens Greengrass Greengrass Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Greengrass' {Text
groupArn :: Text
$sel:groupArn:Greengrass' :: Greengrass -> Text
groupArn} -> Text
groupArn) (\s :: Greengrass
s@Greengrass' {} Text
a -> Greengrass
s {$sel:groupArn:Greengrass' :: Text
groupArn = Text
a} :: Greengrass)

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

instance Prelude.Hashable Greengrass

instance Prelude.NFData Greengrass

instance Core.ToJSON Greengrass where
  toJSON :: Greengrass -> Value
toJSON Greengrass' {Text
groupArn :: Text
$sel:groupArn:Greengrass' :: Greengrass -> 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
"groupArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupArn)]
      )