{-# 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.KinesisAnalyticsV2.Types.PropertyGroup
-- 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.KinesisAnalyticsV2.Types.PropertyGroup where

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

-- | Property key-value pairs passed into an application.
--
-- /See:/ 'newPropertyGroup' smart constructor.
data PropertyGroup = PropertyGroup'
  { -- | Describes the key of an application execution property key-value pair.
    PropertyGroup -> Text
propertyGroupId :: Prelude.Text,
    -- | Describes the value of an application execution property key-value pair.
    PropertyGroup -> HashMap Text Text
propertyMap :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (PropertyGroup -> PropertyGroup -> Bool
(PropertyGroup -> PropertyGroup -> Bool)
-> (PropertyGroup -> PropertyGroup -> Bool) -> Eq PropertyGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyGroup -> PropertyGroup -> Bool
$c/= :: PropertyGroup -> PropertyGroup -> Bool
== :: PropertyGroup -> PropertyGroup -> Bool
$c== :: PropertyGroup -> PropertyGroup -> Bool
Prelude.Eq, ReadPrec [PropertyGroup]
ReadPrec PropertyGroup
Int -> ReadS PropertyGroup
ReadS [PropertyGroup]
(Int -> ReadS PropertyGroup)
-> ReadS [PropertyGroup]
-> ReadPrec PropertyGroup
-> ReadPrec [PropertyGroup]
-> Read PropertyGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyGroup]
$creadListPrec :: ReadPrec [PropertyGroup]
readPrec :: ReadPrec PropertyGroup
$creadPrec :: ReadPrec PropertyGroup
readList :: ReadS [PropertyGroup]
$creadList :: ReadS [PropertyGroup]
readsPrec :: Int -> ReadS PropertyGroup
$creadsPrec :: Int -> ReadS PropertyGroup
Prelude.Read, Int -> PropertyGroup -> ShowS
[PropertyGroup] -> ShowS
PropertyGroup -> String
(Int -> PropertyGroup -> ShowS)
-> (PropertyGroup -> String)
-> ([PropertyGroup] -> ShowS)
-> Show PropertyGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyGroup] -> ShowS
$cshowList :: [PropertyGroup] -> ShowS
show :: PropertyGroup -> String
$cshow :: PropertyGroup -> String
showsPrec :: Int -> PropertyGroup -> ShowS
$cshowsPrec :: Int -> PropertyGroup -> ShowS
Prelude.Show, (forall x. PropertyGroup -> Rep PropertyGroup x)
-> (forall x. Rep PropertyGroup x -> PropertyGroup)
-> Generic PropertyGroup
forall x. Rep PropertyGroup x -> PropertyGroup
forall x. PropertyGroup -> Rep PropertyGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyGroup x -> PropertyGroup
$cfrom :: forall x. PropertyGroup -> Rep PropertyGroup x
Prelude.Generic)

-- |
-- Create a value of 'PropertyGroup' 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:
--
-- 'propertyGroupId', 'propertyGroup_propertyGroupId' - Describes the key of an application execution property key-value pair.
--
-- 'propertyMap', 'propertyGroup_propertyMap' - Describes the value of an application execution property key-value pair.
newPropertyGroup ::
  -- | 'propertyGroupId'
  Prelude.Text ->
  PropertyGroup
newPropertyGroup :: Text -> PropertyGroup
newPropertyGroup Text
pPropertyGroupId_ =
  PropertyGroup' :: Text -> HashMap Text Text -> PropertyGroup
PropertyGroup'
    { $sel:propertyGroupId:PropertyGroup' :: Text
propertyGroupId = Text
pPropertyGroupId_,
      $sel:propertyMap:PropertyGroup' :: HashMap Text Text
propertyMap = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | Describes the key of an application execution property key-value pair.
propertyGroup_propertyGroupId :: Lens.Lens' PropertyGroup Prelude.Text
propertyGroup_propertyGroupId :: (Text -> f Text) -> PropertyGroup -> f PropertyGroup
propertyGroup_propertyGroupId = (PropertyGroup -> Text)
-> (PropertyGroup -> Text -> PropertyGroup)
-> Lens PropertyGroup PropertyGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyGroup' {Text
propertyGroupId :: Text
$sel:propertyGroupId:PropertyGroup' :: PropertyGroup -> Text
propertyGroupId} -> Text
propertyGroupId) (\s :: PropertyGroup
s@PropertyGroup' {} Text
a -> PropertyGroup
s {$sel:propertyGroupId:PropertyGroup' :: Text
propertyGroupId = Text
a} :: PropertyGroup)

-- | Describes the value of an application execution property key-value pair.
propertyGroup_propertyMap :: Lens.Lens' PropertyGroup (Prelude.HashMap Prelude.Text Prelude.Text)
propertyGroup_propertyMap :: (HashMap Text Text -> f (HashMap Text Text))
-> PropertyGroup -> f PropertyGroup
propertyGroup_propertyMap = (PropertyGroup -> HashMap Text Text)
-> (PropertyGroup -> HashMap Text Text -> PropertyGroup)
-> Lens
     PropertyGroup PropertyGroup (HashMap Text Text) (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyGroup' {HashMap Text Text
propertyMap :: HashMap Text Text
$sel:propertyMap:PropertyGroup' :: PropertyGroup -> HashMap Text Text
propertyMap} -> HashMap Text Text
propertyMap) (\s :: PropertyGroup
s@PropertyGroup' {} HashMap Text Text
a -> PropertyGroup
s {$sel:propertyMap:PropertyGroup' :: HashMap Text Text
propertyMap = HashMap Text Text
a} :: PropertyGroup) ((HashMap Text Text -> f (HashMap Text Text))
 -> PropertyGroup -> f PropertyGroup)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> PropertyGroup
-> f PropertyGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable PropertyGroup

instance Prelude.NFData PropertyGroup

instance Core.ToJSON PropertyGroup where
  toJSON :: PropertyGroup -> Value
toJSON PropertyGroup' {Text
HashMap Text Text
propertyMap :: HashMap Text Text
propertyGroupId :: Text
$sel:propertyMap:PropertyGroup' :: PropertyGroup -> HashMap Text Text
$sel:propertyGroupId:PropertyGroup' :: PropertyGroup -> 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
"PropertyGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
propertyGroupId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PropertyMap" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
propertyMap)
          ]
      )