{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ResourceGroups.Types.GroupConfigurationParameter 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

-- | 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
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]
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
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.
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'
    { $sel:values:GroupConfigurationParameter' :: Maybe [Text]
values =
        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 :: Lens' GroupConfigurationParameter (Maybe [Text])
groupConfigurationParameter_values = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' GroupConfigurationParameter Text
groupConfigurationParameter_name = 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 Data.FromJSON GroupConfigurationParameter where
  parseJSON :: Value -> Parser GroupConfigurationParameter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GroupConfigurationParameter"
      ( \Object
x ->
          Maybe [Text] -> Text -> GroupConfigurationParameter
GroupConfigurationParameter'
            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
"Values" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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")
      )

instance Prelude.Hashable GroupConfigurationParameter where
  hashWithSalt :: Int -> GroupConfigurationParameter -> Int
hashWithSalt Int
_salt GroupConfigurationParameter' {Maybe [Text]
Text
name :: Text
values :: Maybe [Text]
$sel:name:GroupConfigurationParameter' :: GroupConfigurationParameter -> Text
$sel:values:GroupConfigurationParameter' :: GroupConfigurationParameter -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
values
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData GroupConfigurationParameter where
  rnf :: GroupConfigurationParameter -> ()
rnf GroupConfigurationParameter' {Maybe [Text]
Text
name :: Text
values :: Maybe [Text]
$sel:name:GroupConfigurationParameter' :: GroupConfigurationParameter -> Text
$sel:values:GroupConfigurationParameter' :: GroupConfigurationParameter -> Maybe [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
values seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Values" 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]
values,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )