{-# 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.SelectAttributesActivity
-- 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.SelectAttributesActivity 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

-- | Used to create a new message using only the specified attributes from
-- the original message.
--
-- /See:/ 'newSelectAttributesActivity' smart constructor.
data SelectAttributesActivity = SelectAttributesActivity'
  { -- | The next activity in the pipeline.
    SelectAttributesActivity -> Maybe Text
next :: Prelude.Maybe Prelude.Text,
    -- | The name of the @selectAttributes@ activity.
    SelectAttributesActivity -> Text
name :: Prelude.Text,
    -- | A list of the attributes to select from the message.
    SelectAttributesActivity -> NonEmpty Text
attributes :: Prelude.NonEmpty Prelude.Text
  }
  deriving (SelectAttributesActivity -> SelectAttributesActivity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SelectAttributesActivity -> SelectAttributesActivity -> Bool
$c/= :: SelectAttributesActivity -> SelectAttributesActivity -> Bool
== :: SelectAttributesActivity -> SelectAttributesActivity -> Bool
$c== :: SelectAttributesActivity -> SelectAttributesActivity -> Bool
Prelude.Eq, ReadPrec [SelectAttributesActivity]
ReadPrec SelectAttributesActivity
Int -> ReadS SelectAttributesActivity
ReadS [SelectAttributesActivity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SelectAttributesActivity]
$creadListPrec :: ReadPrec [SelectAttributesActivity]
readPrec :: ReadPrec SelectAttributesActivity
$creadPrec :: ReadPrec SelectAttributesActivity
readList :: ReadS [SelectAttributesActivity]
$creadList :: ReadS [SelectAttributesActivity]
readsPrec :: Int -> ReadS SelectAttributesActivity
$creadsPrec :: Int -> ReadS SelectAttributesActivity
Prelude.Read, Int -> SelectAttributesActivity -> ShowS
[SelectAttributesActivity] -> ShowS
SelectAttributesActivity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SelectAttributesActivity] -> ShowS
$cshowList :: [SelectAttributesActivity] -> ShowS
show :: SelectAttributesActivity -> String
$cshow :: SelectAttributesActivity -> String
showsPrec :: Int -> SelectAttributesActivity -> ShowS
$cshowsPrec :: Int -> SelectAttributesActivity -> ShowS
Prelude.Show, forall x.
Rep SelectAttributesActivity x -> SelectAttributesActivity
forall x.
SelectAttributesActivity -> Rep SelectAttributesActivity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SelectAttributesActivity x -> SelectAttributesActivity
$cfrom :: forall x.
SelectAttributesActivity -> Rep SelectAttributesActivity x
Prelude.Generic)

-- |
-- Create a value of 'SelectAttributesActivity' 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', 'selectAttributesActivity_next' - The next activity in the pipeline.
--
-- 'name', 'selectAttributesActivity_name' - The name of the @selectAttributes@ activity.
--
-- 'attributes', 'selectAttributesActivity_attributes' - A list of the attributes to select from the message.
newSelectAttributesActivity ::
  -- | 'name'
  Prelude.Text ->
  -- | 'attributes'
  Prelude.NonEmpty Prelude.Text ->
  SelectAttributesActivity
newSelectAttributesActivity :: Text -> NonEmpty Text -> SelectAttributesActivity
newSelectAttributesActivity Text
pName_ NonEmpty Text
pAttributes_ =
  SelectAttributesActivity'
    { $sel:next:SelectAttributesActivity' :: Maybe Text
next = forall a. Maybe a
Prelude.Nothing,
      $sel:name:SelectAttributesActivity' :: Text
name = Text
pName_,
      $sel:attributes:SelectAttributesActivity' :: NonEmpty Text
attributes = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pAttributes_
    }

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

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

-- | A list of the attributes to select from the message.
selectAttributesActivity_attributes :: Lens.Lens' SelectAttributesActivity (Prelude.NonEmpty Prelude.Text)
selectAttributesActivity_attributes :: Lens' SelectAttributesActivity (NonEmpty Text)
selectAttributesActivity_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SelectAttributesActivity' {NonEmpty Text
attributes :: NonEmpty Text
$sel:attributes:SelectAttributesActivity' :: SelectAttributesActivity -> NonEmpty Text
attributes} -> NonEmpty Text
attributes) (\s :: SelectAttributesActivity
s@SelectAttributesActivity' {} NonEmpty Text
a -> SelectAttributesActivity
s {$sel:attributes:SelectAttributesActivity' :: NonEmpty Text
attributes = NonEmpty Text
a} :: SelectAttributesActivity) 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 SelectAttributesActivity where
  parseJSON :: Value -> Parser SelectAttributesActivity
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SelectAttributesActivity"
      ( \Object
x ->
          Maybe Text -> Text -> NonEmpty Text -> SelectAttributesActivity
SelectAttributesActivity'
            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 a
Data..: Key
"attributes")
      )

instance Prelude.Hashable SelectAttributesActivity where
  hashWithSalt :: Int -> SelectAttributesActivity -> Int
hashWithSalt Int
_salt SelectAttributesActivity' {Maybe Text
NonEmpty Text
Text
attributes :: NonEmpty Text
name :: Text
next :: Maybe Text
$sel:attributes:SelectAttributesActivity' :: SelectAttributesActivity -> NonEmpty Text
$sel:name:SelectAttributesActivity' :: SelectAttributesActivity -> Text
$sel:next:SelectAttributesActivity' :: SelectAttributesActivity -> 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` NonEmpty Text
attributes

instance Prelude.NFData SelectAttributesActivity where
  rnf :: SelectAttributesActivity -> ()
rnf SelectAttributesActivity' {Maybe Text
NonEmpty Text
Text
attributes :: NonEmpty Text
name :: Text
next :: Maybe Text
$sel:attributes:SelectAttributesActivity' :: SelectAttributesActivity -> NonEmpty Text
$sel:name:SelectAttributesActivity' :: SelectAttributesActivity -> Text
$sel:next:SelectAttributesActivity' :: SelectAttributesActivity -> 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 NonEmpty Text
attributes

instance Data.ToJSON SelectAttributesActivity where
  toJSON :: SelectAttributesActivity -> Value
toJSON SelectAttributesActivity' {Maybe Text
NonEmpty Text
Text
attributes :: NonEmpty Text
name :: Text
next :: Maybe Text
$sel:attributes:SelectAttributesActivity' :: SelectAttributesActivity -> NonEmpty Text
$sel:name:SelectAttributesActivity' :: SelectAttributesActivity -> Text
$sel:next:SelectAttributesActivity' :: SelectAttributesActivity -> 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..= NonEmpty Text
attributes)
          ]
      )