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

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

-- | An activity that removes attributes from a message.
--
-- /See:/ 'newRemoveAttributesActivity' smart constructor.
data RemoveAttributesActivity = RemoveAttributesActivity'
  { -- | The next activity in the pipeline.
    RemoveAttributesActivity -> Maybe Text
next :: Prelude.Maybe Prelude.Text,
    -- | The name of the @removeAttributes@ activity.
    RemoveAttributesActivity -> Text
name :: Prelude.Text,
    -- | A list of 1-50 attributes to remove from the message.
    RemoveAttributesActivity -> NonEmpty Text
attributes :: Prelude.NonEmpty Prelude.Text
  }
  deriving (RemoveAttributesActivity -> RemoveAttributesActivity -> Bool
(RemoveAttributesActivity -> RemoveAttributesActivity -> Bool)
-> (RemoveAttributesActivity -> RemoveAttributesActivity -> Bool)
-> Eq RemoveAttributesActivity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveAttributesActivity -> RemoveAttributesActivity -> Bool
$c/= :: RemoveAttributesActivity -> RemoveAttributesActivity -> Bool
== :: RemoveAttributesActivity -> RemoveAttributesActivity -> Bool
$c== :: RemoveAttributesActivity -> RemoveAttributesActivity -> Bool
Prelude.Eq, ReadPrec [RemoveAttributesActivity]
ReadPrec RemoveAttributesActivity
Int -> ReadS RemoveAttributesActivity
ReadS [RemoveAttributesActivity]
(Int -> ReadS RemoveAttributesActivity)
-> ReadS [RemoveAttributesActivity]
-> ReadPrec RemoveAttributesActivity
-> ReadPrec [RemoveAttributesActivity]
-> Read RemoveAttributesActivity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveAttributesActivity]
$creadListPrec :: ReadPrec [RemoveAttributesActivity]
readPrec :: ReadPrec RemoveAttributesActivity
$creadPrec :: ReadPrec RemoveAttributesActivity
readList :: ReadS [RemoveAttributesActivity]
$creadList :: ReadS [RemoveAttributesActivity]
readsPrec :: Int -> ReadS RemoveAttributesActivity
$creadsPrec :: Int -> ReadS RemoveAttributesActivity
Prelude.Read, Int -> RemoveAttributesActivity -> ShowS
[RemoveAttributesActivity] -> ShowS
RemoveAttributesActivity -> String
(Int -> RemoveAttributesActivity -> ShowS)
-> (RemoveAttributesActivity -> String)
-> ([RemoveAttributesActivity] -> ShowS)
-> Show RemoveAttributesActivity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveAttributesActivity] -> ShowS
$cshowList :: [RemoveAttributesActivity] -> ShowS
show :: RemoveAttributesActivity -> String
$cshow :: RemoveAttributesActivity -> String
showsPrec :: Int -> RemoveAttributesActivity -> ShowS
$cshowsPrec :: Int -> RemoveAttributesActivity -> ShowS
Prelude.Show, (forall x.
 RemoveAttributesActivity -> Rep RemoveAttributesActivity x)
-> (forall x.
    Rep RemoveAttributesActivity x -> RemoveAttributesActivity)
-> Generic RemoveAttributesActivity
forall x.
Rep RemoveAttributesActivity x -> RemoveAttributesActivity
forall x.
RemoveAttributesActivity -> Rep RemoveAttributesActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveAttributesActivity x -> RemoveAttributesActivity
$cfrom :: forall x.
RemoveAttributesActivity -> Rep RemoveAttributesActivity x
Prelude.Generic)

-- |
-- Create a value of 'RemoveAttributesActivity' 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', 'removeAttributesActivity_next' - The next activity in the pipeline.
--
-- 'name', 'removeAttributesActivity_name' - The name of the @removeAttributes@ activity.
--
-- 'attributes', 'removeAttributesActivity_attributes' - A list of 1-50 attributes to remove from the message.
newRemoveAttributesActivity ::
  -- | 'name'
  Prelude.Text ->
  -- | 'attributes'
  Prelude.NonEmpty Prelude.Text ->
  RemoveAttributesActivity
newRemoveAttributesActivity :: Text -> NonEmpty Text -> RemoveAttributesActivity
newRemoveAttributesActivity Text
pName_ NonEmpty Text
pAttributes_ =
  RemoveAttributesActivity' :: Maybe Text -> Text -> NonEmpty Text -> RemoveAttributesActivity
RemoveAttributesActivity'
    { $sel:next:RemoveAttributesActivity' :: Maybe Text
next = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:RemoveAttributesActivity' :: Text
name = Text
pName_,
      $sel:attributes:RemoveAttributesActivity' :: NonEmpty Text
attributes = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pAttributes_
    }

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

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

-- | A list of 1-50 attributes to remove from the message.
removeAttributesActivity_attributes :: Lens.Lens' RemoveAttributesActivity (Prelude.NonEmpty Prelude.Text)
removeAttributesActivity_attributes :: (NonEmpty Text -> f (NonEmpty Text))
-> RemoveAttributesActivity -> f RemoveAttributesActivity
removeAttributesActivity_attributes = (RemoveAttributesActivity -> NonEmpty Text)
-> (RemoveAttributesActivity
    -> NonEmpty Text -> RemoveAttributesActivity)
-> Lens
     RemoveAttributesActivity
     RemoveAttributesActivity
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveAttributesActivity' {NonEmpty Text
attributes :: NonEmpty Text
$sel:attributes:RemoveAttributesActivity' :: RemoveAttributesActivity -> NonEmpty Text
attributes} -> NonEmpty Text
attributes) (\s :: RemoveAttributesActivity
s@RemoveAttributesActivity' {} NonEmpty Text
a -> RemoveAttributesActivity
s {$sel:attributes:RemoveAttributesActivity' :: NonEmpty Text
attributes = NonEmpty Text
a} :: RemoveAttributesActivity) ((NonEmpty Text -> f (NonEmpty Text))
 -> RemoveAttributesActivity -> f RemoveAttributesActivity)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> RemoveAttributesActivity
-> f RemoveAttributesActivity
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON RemoveAttributesActivity where
  parseJSON :: Value -> Parser RemoveAttributesActivity
parseJSON =
    String
-> (Object -> Parser RemoveAttributesActivity)
-> Value
-> Parser RemoveAttributesActivity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RemoveAttributesActivity"
      ( \Object
x ->
          Maybe Text -> Text -> NonEmpty Text -> RemoveAttributesActivity
RemoveAttributesActivity'
            (Maybe Text -> Text -> NonEmpty Text -> RemoveAttributesActivity)
-> Parser (Maybe Text)
-> Parser (Text -> NonEmpty Text -> RemoveAttributesActivity)
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 -> NonEmpty Text -> RemoveAttributesActivity)
-> Parser Text
-> Parser (NonEmpty Text -> RemoveAttributesActivity)
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 (NonEmpty Text -> RemoveAttributesActivity)
-> Parser (NonEmpty Text) -> Parser RemoveAttributesActivity
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty Text)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"attributes")
      )

instance Prelude.Hashable RemoveAttributesActivity

instance Prelude.NFData RemoveAttributesActivity

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