{-# 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.DataPipeline.Types.ParameterObject
-- 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.DataPipeline.Types.ParameterObject where

import qualified Amazonka.Core as Core
import Amazonka.DataPipeline.Types.ParameterAttribute
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a parameter object.
--
-- /See:/ 'newParameterObject' smart constructor.
data ParameterObject = ParameterObject'
  { -- | The ID of the parameter object.
    ParameterObject -> Text
id :: Prelude.Text,
    -- | The attributes of the parameter object.
    ParameterObject -> [ParameterAttribute]
attributes :: [ParameterAttribute]
  }
  deriving (ParameterObject -> ParameterObject -> Bool
(ParameterObject -> ParameterObject -> Bool)
-> (ParameterObject -> ParameterObject -> Bool)
-> Eq ParameterObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterObject -> ParameterObject -> Bool
$c/= :: ParameterObject -> ParameterObject -> Bool
== :: ParameterObject -> ParameterObject -> Bool
$c== :: ParameterObject -> ParameterObject -> Bool
Prelude.Eq, ReadPrec [ParameterObject]
ReadPrec ParameterObject
Int -> ReadS ParameterObject
ReadS [ParameterObject]
(Int -> ReadS ParameterObject)
-> ReadS [ParameterObject]
-> ReadPrec ParameterObject
-> ReadPrec [ParameterObject]
-> Read ParameterObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ParameterObject]
$creadListPrec :: ReadPrec [ParameterObject]
readPrec :: ReadPrec ParameterObject
$creadPrec :: ReadPrec ParameterObject
readList :: ReadS [ParameterObject]
$creadList :: ReadS [ParameterObject]
readsPrec :: Int -> ReadS ParameterObject
$creadsPrec :: Int -> ReadS ParameterObject
Prelude.Read, Int -> ParameterObject -> ShowS
[ParameterObject] -> ShowS
ParameterObject -> String
(Int -> ParameterObject -> ShowS)
-> (ParameterObject -> String)
-> ([ParameterObject] -> ShowS)
-> Show ParameterObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ParameterObject] -> ShowS
$cshowList :: [ParameterObject] -> ShowS
show :: ParameterObject -> String
$cshow :: ParameterObject -> String
showsPrec :: Int -> ParameterObject -> ShowS
$cshowsPrec :: Int -> ParameterObject -> ShowS
Prelude.Show, (forall x. ParameterObject -> Rep ParameterObject x)
-> (forall x. Rep ParameterObject x -> ParameterObject)
-> Generic ParameterObject
forall x. Rep ParameterObject x -> ParameterObject
forall x. ParameterObject -> Rep ParameterObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ParameterObject x -> ParameterObject
$cfrom :: forall x. ParameterObject -> Rep ParameterObject x
Prelude.Generic)

-- |
-- Create a value of 'ParameterObject' 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:
--
-- 'id', 'parameterObject_id' - The ID of the parameter object.
--
-- 'attributes', 'parameterObject_attributes' - The attributes of the parameter object.
newParameterObject ::
  -- | 'id'
  Prelude.Text ->
  ParameterObject
newParameterObject :: Text -> ParameterObject
newParameterObject Text
pId_ =
  ParameterObject' :: Text -> [ParameterAttribute] -> ParameterObject
ParameterObject'
    { $sel:id:ParameterObject' :: Text
id = Text
pId_,
      $sel:attributes:ParameterObject' :: [ParameterAttribute]
attributes = [ParameterAttribute]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The ID of the parameter object.
parameterObject_id :: Lens.Lens' ParameterObject Prelude.Text
parameterObject_id :: (Text -> f Text) -> ParameterObject -> f ParameterObject
parameterObject_id = (ParameterObject -> Text)
-> (ParameterObject -> Text -> ParameterObject)
-> Lens ParameterObject ParameterObject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterObject' {Text
id :: Text
$sel:id:ParameterObject' :: ParameterObject -> Text
id} -> Text
id) (\s :: ParameterObject
s@ParameterObject' {} Text
a -> ParameterObject
s {$sel:id:ParameterObject' :: Text
id = Text
a} :: ParameterObject)

-- | The attributes of the parameter object.
parameterObject_attributes :: Lens.Lens' ParameterObject [ParameterAttribute]
parameterObject_attributes :: ([ParameterAttribute] -> f [ParameterAttribute])
-> ParameterObject -> f ParameterObject
parameterObject_attributes = (ParameterObject -> [ParameterAttribute])
-> (ParameterObject -> [ParameterAttribute] -> ParameterObject)
-> Lens
     ParameterObject
     ParameterObject
     [ParameterAttribute]
     [ParameterAttribute]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ParameterObject' {[ParameterAttribute]
attributes :: [ParameterAttribute]
$sel:attributes:ParameterObject' :: ParameterObject -> [ParameterAttribute]
attributes} -> [ParameterAttribute]
attributes) (\s :: ParameterObject
s@ParameterObject' {} [ParameterAttribute]
a -> ParameterObject
s {$sel:attributes:ParameterObject' :: [ParameterAttribute]
attributes = [ParameterAttribute]
a} :: ParameterObject) (([ParameterAttribute] -> f [ParameterAttribute])
 -> ParameterObject -> f ParameterObject)
-> (([ParameterAttribute] -> f [ParameterAttribute])
    -> [ParameterAttribute] -> f [ParameterAttribute])
-> ([ParameterAttribute] -> f [ParameterAttribute])
-> ParameterObject
-> f ParameterObject
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ParameterAttribute] -> f [ParameterAttribute])
-> [ParameterAttribute] -> f [ParameterAttribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON ParameterObject where
  parseJSON :: Value -> Parser ParameterObject
parseJSON =
    String
-> (Object -> Parser ParameterObject)
-> Value
-> Parser ParameterObject
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ParameterObject"
      ( \Object
x ->
          Text -> [ParameterAttribute] -> ParameterObject
ParameterObject'
            (Text -> [ParameterAttribute] -> ParameterObject)
-> Parser Text -> Parser ([ParameterAttribute] -> ParameterObject)
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
"id")
            Parser ([ParameterAttribute] -> ParameterObject)
-> Parser [ParameterAttribute] -> Parser ParameterObject
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [ParameterAttribute])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes" Parser (Maybe [ParameterAttribute])
-> [ParameterAttribute] -> Parser [ParameterAttribute]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [ParameterAttribute]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ParameterObject

instance Prelude.NFData ParameterObject

instance Core.ToJSON ParameterObject where
  toJSON :: ParameterObject -> Value
toJSON ParameterObject' {[ParameterAttribute]
Text
attributes :: [ParameterAttribute]
id :: Text
$sel:attributes:ParameterObject' :: ParameterObject -> [ParameterAttribute]
$sel:id:ParameterObject' :: ParameterObject -> 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
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"attributes" Text -> [ParameterAttribute] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ParameterAttribute]
attributes)
          ]
      )