{-# 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.ResourceGroups.Types.GroupConfigurationParameter
-- 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.ResourceGroups.Types.GroupConfigurationParameter where

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

-- | A parameter for a group configuration item. For details about group
-- service configuration syntax, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html Service configurations for resource groups>.
--
-- /See:/ 'newGroupConfigurationParameter' smart constructor.
data GroupConfigurationParameter = GroupConfigurationParameter'
  { -- | The value or values to be used for the specified parameter. For the list
    -- of values you can use with each parameter, see
    -- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
    GroupConfigurationParameter -> Maybe [Text]
values :: Prelude.Maybe [Prelude.Text],
    -- | The name of the group configuration parameter. For the list of
    -- parameters that you can use with each configuration item type, see
    -- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
    GroupConfigurationParameter -> Text
name :: Prelude.Text
  }
  deriving (GroupConfigurationParameter -> GroupConfigurationParameter -> Bool
(GroupConfigurationParameter
 -> GroupConfigurationParameter -> Bool)
-> (GroupConfigurationParameter
    -> GroupConfigurationParameter -> Bool)
-> Eq GroupConfigurationParameter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupConfigurationParameter -> GroupConfigurationParameter -> Bool
$c/= :: GroupConfigurationParameter -> GroupConfigurationParameter -> Bool
== :: GroupConfigurationParameter -> GroupConfigurationParameter -> Bool
$c== :: GroupConfigurationParameter -> GroupConfigurationParameter -> Bool
Prelude.Eq, ReadPrec [GroupConfigurationParameter]
ReadPrec GroupConfigurationParameter
Int -> ReadS GroupConfigurationParameter
ReadS [GroupConfigurationParameter]
(Int -> ReadS GroupConfigurationParameter)
-> ReadS [GroupConfigurationParameter]
-> ReadPrec GroupConfigurationParameter
-> ReadPrec [GroupConfigurationParameter]
-> Read GroupConfigurationParameter
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupConfigurationParameter]
$creadListPrec :: ReadPrec [GroupConfigurationParameter]
readPrec :: ReadPrec GroupConfigurationParameter
$creadPrec :: ReadPrec GroupConfigurationParameter
readList :: ReadS [GroupConfigurationParameter]
$creadList :: ReadS [GroupConfigurationParameter]
readsPrec :: Int -> ReadS GroupConfigurationParameter
$creadsPrec :: Int -> ReadS GroupConfigurationParameter
Prelude.Read, Int -> GroupConfigurationParameter -> ShowS
[GroupConfigurationParameter] -> ShowS
GroupConfigurationParameter -> String
(Int -> GroupConfigurationParameter -> ShowS)
-> (GroupConfigurationParameter -> String)
-> ([GroupConfigurationParameter] -> ShowS)
-> Show GroupConfigurationParameter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupConfigurationParameter] -> ShowS
$cshowList :: [GroupConfigurationParameter] -> ShowS
show :: GroupConfigurationParameter -> String
$cshow :: GroupConfigurationParameter -> String
showsPrec :: Int -> GroupConfigurationParameter -> ShowS
$cshowsPrec :: Int -> GroupConfigurationParameter -> ShowS
Prelude.Show, (forall x.
 GroupConfigurationParameter -> Rep GroupConfigurationParameter x)
-> (forall x.
    Rep GroupConfigurationParameter x -> GroupConfigurationParameter)
-> Generic GroupConfigurationParameter
forall x.
Rep GroupConfigurationParameter x -> GroupConfigurationParameter
forall x.
GroupConfigurationParameter -> Rep GroupConfigurationParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GroupConfigurationParameter x -> GroupConfigurationParameter
$cfrom :: forall x.
GroupConfigurationParameter -> Rep GroupConfigurationParameter x
Prelude.Generic)

-- |
-- Create a value of 'GroupConfigurationParameter' 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:
--
-- 'values', 'groupConfigurationParameter_values' - The value or values to be used for the specified parameter. For the list
-- of values you can use with each parameter, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
--
-- 'name', 'groupConfigurationParameter_name' - The name of the group configuration parameter. For the list of
-- parameters that you can use with each configuration item type, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
newGroupConfigurationParameter ::
  -- | 'name'
  Prelude.Text ->
  GroupConfigurationParameter
newGroupConfigurationParameter :: Text -> GroupConfigurationParameter
newGroupConfigurationParameter Text
pName_ =
  GroupConfigurationParameter' :: Maybe [Text] -> Text -> GroupConfigurationParameter
GroupConfigurationParameter'
    { $sel:values:GroupConfigurationParameter' :: Maybe [Text]
values =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:GroupConfigurationParameter' :: Text
name = Text
pName_
    }

-- | The value or values to be used for the specified parameter. For the list
-- of values you can use with each parameter, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
groupConfigurationParameter_values :: Lens.Lens' GroupConfigurationParameter (Prelude.Maybe [Prelude.Text])
groupConfigurationParameter_values :: (Maybe [Text] -> f (Maybe [Text]))
-> GroupConfigurationParameter -> f GroupConfigurationParameter
groupConfigurationParameter_values = (GroupConfigurationParameter -> Maybe [Text])
-> (GroupConfigurationParameter
    -> Maybe [Text] -> GroupConfigurationParameter)
-> Lens
     GroupConfigurationParameter
     GroupConfigurationParameter
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfigurationParameter' {Maybe [Text]
values :: Maybe [Text]
$sel:values:GroupConfigurationParameter' :: GroupConfigurationParameter -> Maybe [Text]
values} -> Maybe [Text]
values) (\s :: GroupConfigurationParameter
s@GroupConfigurationParameter' {} Maybe [Text]
a -> GroupConfigurationParameter
s {$sel:values:GroupConfigurationParameter' :: Maybe [Text]
values = Maybe [Text]
a} :: GroupConfigurationParameter) ((Maybe [Text] -> f (Maybe [Text]))
 -> GroupConfigurationParameter -> f GroupConfigurationParameter)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GroupConfigurationParameter
-> f GroupConfigurationParameter
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the group configuration parameter. For the list of
-- parameters that you can use with each configuration item type, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
groupConfigurationParameter_name :: Lens.Lens' GroupConfigurationParameter Prelude.Text
groupConfigurationParameter_name :: (Text -> f Text)
-> GroupConfigurationParameter -> f GroupConfigurationParameter
groupConfigurationParameter_name = (GroupConfigurationParameter -> Text)
-> (GroupConfigurationParameter
    -> Text -> GroupConfigurationParameter)
-> Lens
     GroupConfigurationParameter GroupConfigurationParameter Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfigurationParameter' {Text
name :: Text
$sel:name:GroupConfigurationParameter' :: GroupConfigurationParameter -> Text
name} -> Text
name) (\s :: GroupConfigurationParameter
s@GroupConfigurationParameter' {} Text
a -> GroupConfigurationParameter
s {$sel:name:GroupConfigurationParameter' :: Text
name = Text
a} :: GroupConfigurationParameter)

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

instance Prelude.Hashable GroupConfigurationParameter

instance Prelude.NFData GroupConfigurationParameter

instance Core.ToJSON GroupConfigurationParameter where
  toJSON :: GroupConfigurationParameter -> Value
toJSON GroupConfigurationParameter' {Maybe [Text]
Text
name :: Text
values :: Maybe [Text]
$sel:name:GroupConfigurationParameter' :: GroupConfigurationParameter -> Text
$sel:values:GroupConfigurationParameter' :: GroupConfigurationParameter -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Values" 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]
values,
            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)
          ]
      )