{-# 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.GroupConfigurationItem
-- 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.GroupConfigurationItem where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.ResourceGroups.Types.GroupConfigurationParameter

-- | An item in a group configuration. A group service configuration can have
-- one or more items. 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:/ 'newGroupConfigurationItem' smart constructor.
data GroupConfigurationItem = GroupConfigurationItem'
  { -- | A collection of parameters for this group configuration item. 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>.
    GroupConfigurationItem -> Maybe [GroupConfigurationParameter]
parameters :: Prelude.Maybe [GroupConfigurationParameter],
    -- | Specifies the type of group configuration item. Each item must have a
    -- unique value for @type@. For the list of types that you can specify for
    -- a configuration item, see
    -- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
    GroupConfigurationItem -> Text
type' :: Prelude.Text
  }
  deriving (GroupConfigurationItem -> GroupConfigurationItem -> Bool
(GroupConfigurationItem -> GroupConfigurationItem -> Bool)
-> (GroupConfigurationItem -> GroupConfigurationItem -> Bool)
-> Eq GroupConfigurationItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupConfigurationItem -> GroupConfigurationItem -> Bool
$c/= :: GroupConfigurationItem -> GroupConfigurationItem -> Bool
== :: GroupConfigurationItem -> GroupConfigurationItem -> Bool
$c== :: GroupConfigurationItem -> GroupConfigurationItem -> Bool
Prelude.Eq, ReadPrec [GroupConfigurationItem]
ReadPrec GroupConfigurationItem
Int -> ReadS GroupConfigurationItem
ReadS [GroupConfigurationItem]
(Int -> ReadS GroupConfigurationItem)
-> ReadS [GroupConfigurationItem]
-> ReadPrec GroupConfigurationItem
-> ReadPrec [GroupConfigurationItem]
-> Read GroupConfigurationItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupConfigurationItem]
$creadListPrec :: ReadPrec [GroupConfigurationItem]
readPrec :: ReadPrec GroupConfigurationItem
$creadPrec :: ReadPrec GroupConfigurationItem
readList :: ReadS [GroupConfigurationItem]
$creadList :: ReadS [GroupConfigurationItem]
readsPrec :: Int -> ReadS GroupConfigurationItem
$creadsPrec :: Int -> ReadS GroupConfigurationItem
Prelude.Read, Int -> GroupConfigurationItem -> ShowS
[GroupConfigurationItem] -> ShowS
GroupConfigurationItem -> String
(Int -> GroupConfigurationItem -> ShowS)
-> (GroupConfigurationItem -> String)
-> ([GroupConfigurationItem] -> ShowS)
-> Show GroupConfigurationItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupConfigurationItem] -> ShowS
$cshowList :: [GroupConfigurationItem] -> ShowS
show :: GroupConfigurationItem -> String
$cshow :: GroupConfigurationItem -> String
showsPrec :: Int -> GroupConfigurationItem -> ShowS
$cshowsPrec :: Int -> GroupConfigurationItem -> ShowS
Prelude.Show, (forall x. GroupConfigurationItem -> Rep GroupConfigurationItem x)
-> (forall x.
    Rep GroupConfigurationItem x -> GroupConfigurationItem)
-> Generic GroupConfigurationItem
forall x. Rep GroupConfigurationItem x -> GroupConfigurationItem
forall x. GroupConfigurationItem -> Rep GroupConfigurationItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupConfigurationItem x -> GroupConfigurationItem
$cfrom :: forall x. GroupConfigurationItem -> Rep GroupConfigurationItem x
Prelude.Generic)

-- |
-- Create a value of 'GroupConfigurationItem' 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:
--
-- 'parameters', 'groupConfigurationItem_parameters' - A collection of parameters for this group configuration item. 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>.
--
-- 'type'', 'groupConfigurationItem_type' - Specifies the type of group configuration item. Each item must have a
-- unique value for @type@. For the list of types that you can specify for
-- a configuration item, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
newGroupConfigurationItem ::
  -- | 'type''
  Prelude.Text ->
  GroupConfigurationItem
newGroupConfigurationItem :: Text -> GroupConfigurationItem
newGroupConfigurationItem Text
pType_ =
  GroupConfigurationItem' :: Maybe [GroupConfigurationParameter]
-> Text -> GroupConfigurationItem
GroupConfigurationItem'
    { $sel:parameters:GroupConfigurationItem' :: Maybe [GroupConfigurationParameter]
parameters =
        Maybe [GroupConfigurationParameter]
forall a. Maybe a
Prelude.Nothing,
      $sel:type':GroupConfigurationItem' :: Text
type' = Text
pType_
    }

-- | A collection of parameters for this group configuration item. 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>.
groupConfigurationItem_parameters :: Lens.Lens' GroupConfigurationItem (Prelude.Maybe [GroupConfigurationParameter])
groupConfigurationItem_parameters :: (Maybe [GroupConfigurationParameter]
 -> f (Maybe [GroupConfigurationParameter]))
-> GroupConfigurationItem -> f GroupConfigurationItem
groupConfigurationItem_parameters = (GroupConfigurationItem -> Maybe [GroupConfigurationParameter])
-> (GroupConfigurationItem
    -> Maybe [GroupConfigurationParameter] -> GroupConfigurationItem)
-> Lens
     GroupConfigurationItem
     GroupConfigurationItem
     (Maybe [GroupConfigurationParameter])
     (Maybe [GroupConfigurationParameter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfigurationItem' {Maybe [GroupConfigurationParameter]
parameters :: Maybe [GroupConfigurationParameter]
$sel:parameters:GroupConfigurationItem' :: GroupConfigurationItem -> Maybe [GroupConfigurationParameter]
parameters} -> Maybe [GroupConfigurationParameter]
parameters) (\s :: GroupConfigurationItem
s@GroupConfigurationItem' {} Maybe [GroupConfigurationParameter]
a -> GroupConfigurationItem
s {$sel:parameters:GroupConfigurationItem' :: Maybe [GroupConfigurationParameter]
parameters = Maybe [GroupConfigurationParameter]
a} :: GroupConfigurationItem) ((Maybe [GroupConfigurationParameter]
  -> f (Maybe [GroupConfigurationParameter]))
 -> GroupConfigurationItem -> f GroupConfigurationItem)
-> ((Maybe [GroupConfigurationParameter]
     -> f (Maybe [GroupConfigurationParameter]))
    -> Maybe [GroupConfigurationParameter]
    -> f (Maybe [GroupConfigurationParameter]))
-> (Maybe [GroupConfigurationParameter]
    -> f (Maybe [GroupConfigurationParameter]))
-> GroupConfigurationItem
-> f GroupConfigurationItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GroupConfigurationParameter]
  [GroupConfigurationParameter]
  [GroupConfigurationParameter]
  [GroupConfigurationParameter]
-> Iso
     (Maybe [GroupConfigurationParameter])
     (Maybe [GroupConfigurationParameter])
     (Maybe [GroupConfigurationParameter])
     (Maybe [GroupConfigurationParameter])
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
  [GroupConfigurationParameter]
  [GroupConfigurationParameter]
  [GroupConfigurationParameter]
  [GroupConfigurationParameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the type of group configuration item. Each item must have a
-- unique value for @type@. For the list of types that you can specify for
-- a configuration item, see
-- <https://docs.aws.amazon.com/ARG/latest/APIReference/about-slg.html#about-slg-types Supported resource types and parameters>.
groupConfigurationItem_type :: Lens.Lens' GroupConfigurationItem Prelude.Text
groupConfigurationItem_type :: (Text -> f Text)
-> GroupConfigurationItem -> f GroupConfigurationItem
groupConfigurationItem_type = (GroupConfigurationItem -> Text)
-> (GroupConfigurationItem -> Text -> GroupConfigurationItem)
-> Lens GroupConfigurationItem GroupConfigurationItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupConfigurationItem' {Text
type' :: Text
$sel:type':GroupConfigurationItem' :: GroupConfigurationItem -> Text
type'} -> Text
type') (\s :: GroupConfigurationItem
s@GroupConfigurationItem' {} Text
a -> GroupConfigurationItem
s {$sel:type':GroupConfigurationItem' :: Text
type' = Text
a} :: GroupConfigurationItem)

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

instance Prelude.Hashable GroupConfigurationItem

instance Prelude.NFData GroupConfigurationItem

instance Core.ToJSON GroupConfigurationItem where
  toJSON :: GroupConfigurationItem -> Value
toJSON GroupConfigurationItem' {Maybe [GroupConfigurationParameter]
Text
type' :: Text
parameters :: Maybe [GroupConfigurationParameter]
$sel:type':GroupConfigurationItem' :: GroupConfigurationItem -> Text
$sel:parameters:GroupConfigurationItem' :: GroupConfigurationItem -> Maybe [GroupConfigurationParameter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Parameters" Text -> [GroupConfigurationParameter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([GroupConfigurationParameter] -> Pair)
-> Maybe [GroupConfigurationParameter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [GroupConfigurationParameter]
parameters,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
type')
          ]
      )