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

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

-- | An activity that adds other attributes based on existing attributes in
-- the message.
--
-- /See:/ 'newAddAttributesActivity' smart constructor.
data AddAttributesActivity = AddAttributesActivity'
  { -- | The next activity in the pipeline.
    AddAttributesActivity -> Maybe Text
next :: Prelude.Maybe Prelude.Text,
    -- | The name of the addAttributes activity.
    AddAttributesActivity -> Text
name :: Prelude.Text,
    -- | A list of 1-50 @AttributeNameMapping@ objects that map an existing
    -- attribute to a new attribute.
    --
    -- The existing attributes remain in the message, so if you want to remove
    -- the originals, use @RemoveAttributeActivity@.
    AddAttributesActivity -> HashMap Text Text
attributes :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (AddAttributesActivity -> AddAttributesActivity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddAttributesActivity -> AddAttributesActivity -> Bool
$c/= :: AddAttributesActivity -> AddAttributesActivity -> Bool
== :: AddAttributesActivity -> AddAttributesActivity -> Bool
$c== :: AddAttributesActivity -> AddAttributesActivity -> Bool
Prelude.Eq, ReadPrec [AddAttributesActivity]
ReadPrec AddAttributesActivity
Int -> ReadS AddAttributesActivity
ReadS [AddAttributesActivity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddAttributesActivity]
$creadListPrec :: ReadPrec [AddAttributesActivity]
readPrec :: ReadPrec AddAttributesActivity
$creadPrec :: ReadPrec AddAttributesActivity
readList :: ReadS [AddAttributesActivity]
$creadList :: ReadS [AddAttributesActivity]
readsPrec :: Int -> ReadS AddAttributesActivity
$creadsPrec :: Int -> ReadS AddAttributesActivity
Prelude.Read, Int -> AddAttributesActivity -> ShowS
[AddAttributesActivity] -> ShowS
AddAttributesActivity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddAttributesActivity] -> ShowS
$cshowList :: [AddAttributesActivity] -> ShowS
show :: AddAttributesActivity -> String
$cshow :: AddAttributesActivity -> String
showsPrec :: Int -> AddAttributesActivity -> ShowS
$cshowsPrec :: Int -> AddAttributesActivity -> ShowS
Prelude.Show, forall x. Rep AddAttributesActivity x -> AddAttributesActivity
forall x. AddAttributesActivity -> Rep AddAttributesActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AddAttributesActivity x -> AddAttributesActivity
$cfrom :: forall x. AddAttributesActivity -> Rep AddAttributesActivity x
Prelude.Generic)

-- |
-- Create a value of 'AddAttributesActivity' 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', 'addAttributesActivity_next' - The next activity in the pipeline.
--
-- 'name', 'addAttributesActivity_name' - The name of the addAttributes activity.
--
-- 'attributes', 'addAttributesActivity_attributes' - A list of 1-50 @AttributeNameMapping@ objects that map an existing
-- attribute to a new attribute.
--
-- The existing attributes remain in the message, so if you want to remove
-- the originals, use @RemoveAttributeActivity@.
newAddAttributesActivity ::
  -- | 'name'
  Prelude.Text ->
  AddAttributesActivity
newAddAttributesActivity :: Text -> AddAttributesActivity
newAddAttributesActivity Text
pName_ =
  AddAttributesActivity'
    { $sel:next:AddAttributesActivity' :: Maybe Text
next = forall a. Maybe a
Prelude.Nothing,
      $sel:name:AddAttributesActivity' :: Text
name = Text
pName_,
      $sel:attributes:AddAttributesActivity' :: HashMap Text Text
attributes = forall a. Monoid a => a
Prelude.mempty
    }

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

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

-- | A list of 1-50 @AttributeNameMapping@ objects that map an existing
-- attribute to a new attribute.
--
-- The existing attributes remain in the message, so if you want to remove
-- the originals, use @RemoveAttributeActivity@.
addAttributesActivity_attributes :: Lens.Lens' AddAttributesActivity (Prelude.HashMap Prelude.Text Prelude.Text)
addAttributesActivity_attributes :: Lens' AddAttributesActivity (HashMap Text Text)
addAttributesActivity_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddAttributesActivity' {HashMap Text Text
attributes :: HashMap Text Text
$sel:attributes:AddAttributesActivity' :: AddAttributesActivity -> HashMap Text Text
attributes} -> HashMap Text Text
attributes) (\s :: AddAttributesActivity
s@AddAttributesActivity' {} HashMap Text Text
a -> AddAttributesActivity
s {$sel:attributes:AddAttributesActivity' :: HashMap Text Text
attributes = HashMap Text Text
a} :: AddAttributesActivity) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AddAttributesActivity where
  parseJSON :: Value -> Parser AddAttributesActivity
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AddAttributesActivity"
      ( \Object
x ->
          Maybe Text -> Text -> HashMap Text Text -> AddAttributesActivity
AddAttributesActivity'
            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
"next")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
            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
"attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable AddAttributesActivity where
  hashWithSalt :: Int -> AddAttributesActivity -> Int
hashWithSalt Int
_salt AddAttributesActivity' {Maybe Text
Text
HashMap Text Text
attributes :: HashMap Text Text
name :: Text
next :: Maybe Text
$sel:attributes:AddAttributesActivity' :: AddAttributesActivity -> HashMap Text Text
$sel:name:AddAttributesActivity' :: AddAttributesActivity -> Text
$sel:next:AddAttributesActivity' :: AddAttributesActivity -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
next
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Text
attributes

instance Prelude.NFData AddAttributesActivity where
  rnf :: AddAttributesActivity -> ()
rnf AddAttributesActivity' {Maybe Text
Text
HashMap Text Text
attributes :: HashMap Text Text
name :: Text
next :: Maybe Text
$sel:attributes:AddAttributesActivity' :: AddAttributesActivity -> HashMap Text Text
$sel:name:AddAttributesActivity' :: AddAttributesActivity -> Text
$sel:next:AddAttributesActivity' :: AddAttributesActivity -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
next
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
attributes

instance Data.ToJSON AddAttributesActivity where
  toJSON :: AddAttributesActivity -> Value
toJSON AddAttributesActivity' {Maybe Text
Text
HashMap Text Text
attributes :: HashMap Text Text
name :: Text
next :: Maybe Text
$sel:attributes:AddAttributesActivity' :: AddAttributesActivity -> HashMap Text Text
$sel:name:AddAttributesActivity' :: AddAttributesActivity -> Text
$sel:next:AddAttributesActivity' :: AddAttributesActivity -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"next" 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 Text
next,
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap Text Text
attributes)
          ]
      )