{-# 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.IoTAnalytics.Types.DeviceShadowEnrichActivity
-- 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.IoTAnalytics.Types.DeviceShadowEnrichActivity where

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

-- | An activity that adds information from the IoT Device Shadow service to
-- a message.
--
-- /See:/ 'newDeviceShadowEnrichActivity' smart constructor.
data DeviceShadowEnrichActivity = DeviceShadowEnrichActivity'
  { -- | The next activity in the pipeline.
    DeviceShadowEnrichActivity -> Maybe Text
next :: Prelude.Maybe Prelude.Text,
    -- | The name of the @deviceShadowEnrich@ activity.
    DeviceShadowEnrichActivity -> Text
name :: Prelude.Text,
    -- | The name of the attribute that is added to the message.
    DeviceShadowEnrichActivity -> Text
attribute :: Prelude.Text,
    -- | The name of the IoT device whose shadow information is added to the
    -- message.
    DeviceShadowEnrichActivity -> Text
thingName :: Prelude.Text,
    -- | The ARN of the role that allows access to the device\'s shadow.
    DeviceShadowEnrichActivity -> Text
roleArn :: Prelude.Text
  }
  deriving (DeviceShadowEnrichActivity -> DeviceShadowEnrichActivity -> Bool
(DeviceShadowEnrichActivity -> DeviceShadowEnrichActivity -> Bool)
-> (DeviceShadowEnrichActivity
    -> DeviceShadowEnrichActivity -> Bool)
-> Eq DeviceShadowEnrichActivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceShadowEnrichActivity -> DeviceShadowEnrichActivity -> Bool
$c/= :: DeviceShadowEnrichActivity -> DeviceShadowEnrichActivity -> Bool
== :: DeviceShadowEnrichActivity -> DeviceShadowEnrichActivity -> Bool
$c== :: DeviceShadowEnrichActivity -> DeviceShadowEnrichActivity -> Bool
Prelude.Eq, ReadPrec [DeviceShadowEnrichActivity]
ReadPrec DeviceShadowEnrichActivity
Int -> ReadS DeviceShadowEnrichActivity
ReadS [DeviceShadowEnrichActivity]
(Int -> ReadS DeviceShadowEnrichActivity)
-> ReadS [DeviceShadowEnrichActivity]
-> ReadPrec DeviceShadowEnrichActivity
-> ReadPrec [DeviceShadowEnrichActivity]
-> Read DeviceShadowEnrichActivity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeviceShadowEnrichActivity]
$creadListPrec :: ReadPrec [DeviceShadowEnrichActivity]
readPrec :: ReadPrec DeviceShadowEnrichActivity
$creadPrec :: ReadPrec DeviceShadowEnrichActivity
readList :: ReadS [DeviceShadowEnrichActivity]
$creadList :: ReadS [DeviceShadowEnrichActivity]
readsPrec :: Int -> ReadS DeviceShadowEnrichActivity
$creadsPrec :: Int -> ReadS DeviceShadowEnrichActivity
Prelude.Read, Int -> DeviceShadowEnrichActivity -> ShowS
[DeviceShadowEnrichActivity] -> ShowS
DeviceShadowEnrichActivity -> String
(Int -> DeviceShadowEnrichActivity -> ShowS)
-> (DeviceShadowEnrichActivity -> String)
-> ([DeviceShadowEnrichActivity] -> ShowS)
-> Show DeviceShadowEnrichActivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceShadowEnrichActivity] -> ShowS
$cshowList :: [DeviceShadowEnrichActivity] -> ShowS
show :: DeviceShadowEnrichActivity -> String
$cshow :: DeviceShadowEnrichActivity -> String
showsPrec :: Int -> DeviceShadowEnrichActivity -> ShowS
$cshowsPrec :: Int -> DeviceShadowEnrichActivity -> ShowS
Prelude.Show, (forall x.
 DeviceShadowEnrichActivity -> Rep DeviceShadowEnrichActivity x)
-> (forall x.
    Rep DeviceShadowEnrichActivity x -> DeviceShadowEnrichActivity)
-> Generic DeviceShadowEnrichActivity
forall x.
Rep DeviceShadowEnrichActivity x -> DeviceShadowEnrichActivity
forall x.
DeviceShadowEnrichActivity -> Rep DeviceShadowEnrichActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeviceShadowEnrichActivity x -> DeviceShadowEnrichActivity
$cfrom :: forall x.
DeviceShadowEnrichActivity -> Rep DeviceShadowEnrichActivity x
Prelude.Generic)

-- |
-- Create a value of 'DeviceShadowEnrichActivity' 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:
--
-- 'next', 'deviceShadowEnrichActivity_next' - The next activity in the pipeline.
--
-- 'name', 'deviceShadowEnrichActivity_name' - The name of the @deviceShadowEnrich@ activity.
--
-- 'attribute', 'deviceShadowEnrichActivity_attribute' - The name of the attribute that is added to the message.
--
-- 'thingName', 'deviceShadowEnrichActivity_thingName' - The name of the IoT device whose shadow information is added to the
-- message.
--
-- 'roleArn', 'deviceShadowEnrichActivity_roleArn' - The ARN of the role that allows access to the device\'s shadow.
newDeviceShadowEnrichActivity ::
  -- | 'name'
  Prelude.Text ->
  -- | 'attribute'
  Prelude.Text ->
  -- | 'thingName'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  DeviceShadowEnrichActivity
newDeviceShadowEnrichActivity :: Text -> Text -> Text -> Text -> DeviceShadowEnrichActivity
newDeviceShadowEnrichActivity
  Text
pName_
  Text
pAttribute_
  Text
pThingName_
  Text
pRoleArn_ =
    DeviceShadowEnrichActivity' :: Maybe Text
-> Text -> Text -> Text -> Text -> DeviceShadowEnrichActivity
DeviceShadowEnrichActivity'
      { $sel:next:DeviceShadowEnrichActivity' :: Maybe Text
next = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:DeviceShadowEnrichActivity' :: Text
name = Text
pName_,
        $sel:attribute:DeviceShadowEnrichActivity' :: Text
attribute = Text
pAttribute_,
        $sel:thingName:DeviceShadowEnrichActivity' :: Text
thingName = Text
pThingName_,
        $sel:roleArn:DeviceShadowEnrichActivity' :: Text
roleArn = Text
pRoleArn_
      }

-- | The next activity in the pipeline.
deviceShadowEnrichActivity_next :: Lens.Lens' DeviceShadowEnrichActivity (Prelude.Maybe Prelude.Text)
deviceShadowEnrichActivity_next :: (Maybe Text -> f (Maybe Text))
-> DeviceShadowEnrichActivity -> f DeviceShadowEnrichActivity
deviceShadowEnrichActivity_next = (DeviceShadowEnrichActivity -> Maybe Text)
-> (DeviceShadowEnrichActivity
    -> Maybe Text -> DeviceShadowEnrichActivity)
-> Lens
     DeviceShadowEnrichActivity
     DeviceShadowEnrichActivity
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceShadowEnrichActivity' {Maybe Text
next :: Maybe Text
$sel:next:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Maybe Text
next} -> Maybe Text
next) (\s :: DeviceShadowEnrichActivity
s@DeviceShadowEnrichActivity' {} Maybe Text
a -> DeviceShadowEnrichActivity
s {$sel:next:DeviceShadowEnrichActivity' :: Maybe Text
next = Maybe Text
a} :: DeviceShadowEnrichActivity)

-- | The name of the @deviceShadowEnrich@ activity.
deviceShadowEnrichActivity_name :: Lens.Lens' DeviceShadowEnrichActivity Prelude.Text
deviceShadowEnrichActivity_name :: (Text -> f Text)
-> DeviceShadowEnrichActivity -> f DeviceShadowEnrichActivity
deviceShadowEnrichActivity_name = (DeviceShadowEnrichActivity -> Text)
-> (DeviceShadowEnrichActivity
    -> Text -> DeviceShadowEnrichActivity)
-> Lens
     DeviceShadowEnrichActivity DeviceShadowEnrichActivity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceShadowEnrichActivity' {Text
name :: Text
$sel:name:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
name} -> Text
name) (\s :: DeviceShadowEnrichActivity
s@DeviceShadowEnrichActivity' {} Text
a -> DeviceShadowEnrichActivity
s {$sel:name:DeviceShadowEnrichActivity' :: Text
name = Text
a} :: DeviceShadowEnrichActivity)

-- | The name of the attribute that is added to the message.
deviceShadowEnrichActivity_attribute :: Lens.Lens' DeviceShadowEnrichActivity Prelude.Text
deviceShadowEnrichActivity_attribute :: (Text -> f Text)
-> DeviceShadowEnrichActivity -> f DeviceShadowEnrichActivity
deviceShadowEnrichActivity_attribute = (DeviceShadowEnrichActivity -> Text)
-> (DeviceShadowEnrichActivity
    -> Text -> DeviceShadowEnrichActivity)
-> Lens
     DeviceShadowEnrichActivity DeviceShadowEnrichActivity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceShadowEnrichActivity' {Text
attribute :: Text
$sel:attribute:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
attribute} -> Text
attribute) (\s :: DeviceShadowEnrichActivity
s@DeviceShadowEnrichActivity' {} Text
a -> DeviceShadowEnrichActivity
s {$sel:attribute:DeviceShadowEnrichActivity' :: Text
attribute = Text
a} :: DeviceShadowEnrichActivity)

-- | The name of the IoT device whose shadow information is added to the
-- message.
deviceShadowEnrichActivity_thingName :: Lens.Lens' DeviceShadowEnrichActivity Prelude.Text
deviceShadowEnrichActivity_thingName :: (Text -> f Text)
-> DeviceShadowEnrichActivity -> f DeviceShadowEnrichActivity
deviceShadowEnrichActivity_thingName = (DeviceShadowEnrichActivity -> Text)
-> (DeviceShadowEnrichActivity
    -> Text -> DeviceShadowEnrichActivity)
-> Lens
     DeviceShadowEnrichActivity DeviceShadowEnrichActivity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceShadowEnrichActivity' {Text
thingName :: Text
$sel:thingName:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
thingName} -> Text
thingName) (\s :: DeviceShadowEnrichActivity
s@DeviceShadowEnrichActivity' {} Text
a -> DeviceShadowEnrichActivity
s {$sel:thingName:DeviceShadowEnrichActivity' :: Text
thingName = Text
a} :: DeviceShadowEnrichActivity)

-- | The ARN of the role that allows access to the device\'s shadow.
deviceShadowEnrichActivity_roleArn :: Lens.Lens' DeviceShadowEnrichActivity Prelude.Text
deviceShadowEnrichActivity_roleArn :: (Text -> f Text)
-> DeviceShadowEnrichActivity -> f DeviceShadowEnrichActivity
deviceShadowEnrichActivity_roleArn = (DeviceShadowEnrichActivity -> Text)
-> (DeviceShadowEnrichActivity
    -> Text -> DeviceShadowEnrichActivity)
-> Lens
     DeviceShadowEnrichActivity DeviceShadowEnrichActivity Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceShadowEnrichActivity' {Text
roleArn :: Text
$sel:roleArn:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
roleArn} -> Text
roleArn) (\s :: DeviceShadowEnrichActivity
s@DeviceShadowEnrichActivity' {} Text
a -> DeviceShadowEnrichActivity
s {$sel:roleArn:DeviceShadowEnrichActivity' :: Text
roleArn = Text
a} :: DeviceShadowEnrichActivity)

instance Core.FromJSON DeviceShadowEnrichActivity where
  parseJSON :: Value -> Parser DeviceShadowEnrichActivity
parseJSON =
    String
-> (Object -> Parser DeviceShadowEnrichActivity)
-> Value
-> Parser DeviceShadowEnrichActivity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeviceShadowEnrichActivity"
      ( \Object
x ->
          Maybe Text
-> Text -> Text -> Text -> Text -> DeviceShadowEnrichActivity
DeviceShadowEnrichActivity'
            (Maybe Text
 -> Text -> Text -> Text -> Text -> DeviceShadowEnrichActivity)
-> Parser (Maybe Text)
-> Parser
     (Text -> Text -> Text -> Text -> DeviceShadowEnrichActivity)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"next")
            Parser (Text -> Text -> Text -> Text -> DeviceShadowEnrichActivity)
-> Parser Text
-> Parser (Text -> Text -> Text -> DeviceShadowEnrichActivity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
            Parser (Text -> Text -> Text -> DeviceShadowEnrichActivity)
-> Parser Text
-> Parser (Text -> Text -> DeviceShadowEnrichActivity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"attribute")
            Parser (Text -> Text -> DeviceShadowEnrichActivity)
-> Parser Text -> Parser (Text -> DeviceShadowEnrichActivity)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"thingName")
            Parser (Text -> DeviceShadowEnrichActivity)
-> Parser Text -> Parser DeviceShadowEnrichActivity
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"roleArn")
      )

instance Prelude.Hashable DeviceShadowEnrichActivity

instance Prelude.NFData DeviceShadowEnrichActivity

instance Core.ToJSON DeviceShadowEnrichActivity where
  toJSON :: DeviceShadowEnrichActivity -> Value
toJSON DeviceShadowEnrichActivity' {Maybe Text
Text
roleArn :: Text
thingName :: Text
attribute :: Text
name :: Text
next :: Maybe Text
$sel:roleArn:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
$sel:thingName:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
$sel:attribute:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
$sel:name:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Text
$sel:next:DeviceShadowEnrichActivity' :: DeviceShadowEnrichActivity -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"next" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
next,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"attribute" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
attribute),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"thingName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
thingName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
          ]
      )