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

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

-- | A resource group that contains AWS resources. You can assign resources
-- to the group by associating either of the following elements with the
-- group:
--
-- -   ResourceQuery - Use a resource query to specify a set of tag keys
--     and values. All resources in the same AWS Region and AWS account
--     that have those keys with the same values are included in the group.
--     You can add a resource query when you create the group, or later by
--     using the PutGroupConfiguration operation.
--
-- -   GroupConfiguration - Use a service configuration to associate the
--     group with an AWS service. The configuration specifies which
--     resource types can be included in the group.
--
-- /See:/ 'newGroup' smart constructor.
data Group = Group'
  { -- | The description of the resource group.
    Group -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the resource group.
    Group -> Text
groupArn :: Prelude.Text,
    -- | The name of the resource group.
    Group -> Text
name :: Prelude.Text
  }
  deriving (Group -> Group -> Bool
(Group -> Group -> Bool) -> (Group -> Group -> Bool) -> Eq Group
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Group -> Group -> Bool
$c/= :: Group -> Group -> Bool
== :: Group -> Group -> Bool
$c== :: Group -> Group -> Bool
Prelude.Eq, ReadPrec [Group]
ReadPrec Group
Int -> ReadS Group
ReadS [Group]
(Int -> ReadS Group)
-> ReadS [Group]
-> ReadPrec Group
-> ReadPrec [Group]
-> Read Group
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Group]
$creadListPrec :: ReadPrec [Group]
readPrec :: ReadPrec Group
$creadPrec :: ReadPrec Group
readList :: ReadS [Group]
$creadList :: ReadS [Group]
readsPrec :: Int -> ReadS Group
$creadsPrec :: Int -> ReadS Group
Prelude.Read, Int -> Group -> ShowS
[Group] -> ShowS
Group -> String
(Int -> Group -> ShowS)
-> (Group -> String) -> ([Group] -> ShowS) -> Show Group
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Group] -> ShowS
$cshowList :: [Group] -> ShowS
show :: Group -> String
$cshow :: Group -> String
showsPrec :: Int -> Group -> ShowS
$cshowsPrec :: Int -> Group -> ShowS
Prelude.Show, (forall x. Group -> Rep Group x)
-> (forall x. Rep Group x -> Group) -> Generic Group
forall x. Rep Group x -> Group
forall x. Group -> Rep Group x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Group x -> Group
$cfrom :: forall x. Group -> Rep Group x
Prelude.Generic)

-- |
-- Create a value of 'Group' 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:
--
-- 'description', 'group_description' - The description of the resource group.
--
-- 'groupArn', 'group_groupArn' - The ARN of the resource group.
--
-- 'name', 'group_name' - The name of the resource group.
newGroup ::
  -- | 'groupArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  Group
newGroup :: Text -> Text -> Group
newGroup Text
pGroupArn_ Text
pName_ =
  Group' :: Maybe Text -> Text -> Text -> Group
Group'
    { $sel:description:Group' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupArn:Group' :: Text
groupArn = Text
pGroupArn_,
      $sel:name:Group' :: Text
name = Text
pName_
    }

-- | The description of the resource group.
group_description :: Lens.Lens' Group (Prelude.Maybe Prelude.Text)
group_description :: (Maybe Text -> f (Maybe Text)) -> Group -> f Group
group_description = (Group -> Maybe Text)
-> (Group -> Maybe Text -> Group)
-> Lens Group Group (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Group' {Maybe Text
description :: Maybe Text
$sel:description:Group' :: Group -> Maybe Text
description} -> Maybe Text
description) (\s :: Group
s@Group' {} Maybe Text
a -> Group
s {$sel:description:Group' :: Maybe Text
description = Maybe Text
a} :: Group)

-- | The ARN of the resource group.
group_groupArn :: Lens.Lens' Group Prelude.Text
group_groupArn :: (Text -> f Text) -> Group -> f Group
group_groupArn = (Group -> Text)
-> (Group -> Text -> Group) -> Lens Group Group Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Group' {Text
groupArn :: Text
$sel:groupArn:Group' :: Group -> Text
groupArn} -> Text
groupArn) (\s :: Group
s@Group' {} Text
a -> Group
s {$sel:groupArn:Group' :: Text
groupArn = Text
a} :: Group)

-- | The name of the resource group.
group_name :: Lens.Lens' Group Prelude.Text
group_name :: (Text -> f Text) -> Group -> f Group
group_name = (Group -> Text)
-> (Group -> Text -> Group) -> Lens Group Group Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Group' {Text
name :: Text
$sel:name:Group' :: Group -> Text
name} -> Text
name) (\s :: Group
s@Group' {} Text
a -> Group
s {$sel:name:Group' :: Text
name = Text
a} :: Group)

instance Core.FromJSON Group where
  parseJSON :: Value -> Parser Group
parseJSON =
    String -> (Object -> Parser Group) -> Value -> Parser Group
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Group"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> Group
Group'
            (Maybe Text -> Text -> Text -> Group)
-> Parser (Maybe Text) -> Parser (Text -> Text -> Group)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Description")
            Parser (Text -> Text -> Group)
-> Parser Text -> Parser (Text -> Group)
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
"GroupArn")
            Parser (Text -> Group) -> Parser Text -> Parser Group
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 Group

instance Prelude.NFData Group