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

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

-- | A mapping of a query attached to a resource group that determines the
-- AWS resources that are members of the group.
--
-- /See:/ 'newGroupQuery' smart constructor.
data GroupQuery = GroupQuery'
  { -- | The name of the resource group that is associated with the specified
    -- resource query.
    GroupQuery -> Text
groupName :: Prelude.Text,
    -- | The resource query that determines which AWS resources are members of
    -- the associated resource group.
    GroupQuery -> ResourceQuery
resourceQuery :: ResourceQuery
  }
  deriving (GroupQuery -> GroupQuery -> Bool
(GroupQuery -> GroupQuery -> Bool)
-> (GroupQuery -> GroupQuery -> Bool) -> Eq GroupQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GroupQuery -> GroupQuery -> Bool
$c/= :: GroupQuery -> GroupQuery -> Bool
== :: GroupQuery -> GroupQuery -> Bool
$c== :: GroupQuery -> GroupQuery -> Bool
Prelude.Eq, ReadPrec [GroupQuery]
ReadPrec GroupQuery
Int -> ReadS GroupQuery
ReadS [GroupQuery]
(Int -> ReadS GroupQuery)
-> ReadS [GroupQuery]
-> ReadPrec GroupQuery
-> ReadPrec [GroupQuery]
-> Read GroupQuery
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GroupQuery]
$creadListPrec :: ReadPrec [GroupQuery]
readPrec :: ReadPrec GroupQuery
$creadPrec :: ReadPrec GroupQuery
readList :: ReadS [GroupQuery]
$creadList :: ReadS [GroupQuery]
readsPrec :: Int -> ReadS GroupQuery
$creadsPrec :: Int -> ReadS GroupQuery
Prelude.Read, Int -> GroupQuery -> ShowS
[GroupQuery] -> ShowS
GroupQuery -> String
(Int -> GroupQuery -> ShowS)
-> (GroupQuery -> String)
-> ([GroupQuery] -> ShowS)
-> Show GroupQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GroupQuery] -> ShowS
$cshowList :: [GroupQuery] -> ShowS
show :: GroupQuery -> String
$cshow :: GroupQuery -> String
showsPrec :: Int -> GroupQuery -> ShowS
$cshowsPrec :: Int -> GroupQuery -> ShowS
Prelude.Show, (forall x. GroupQuery -> Rep GroupQuery x)
-> (forall x. Rep GroupQuery x -> GroupQuery) -> Generic GroupQuery
forall x. Rep GroupQuery x -> GroupQuery
forall x. GroupQuery -> Rep GroupQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GroupQuery x -> GroupQuery
$cfrom :: forall x. GroupQuery -> Rep GroupQuery x
Prelude.Generic)

-- |
-- Create a value of 'GroupQuery' 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:
--
-- 'groupName', 'groupQuery_groupName' - The name of the resource group that is associated with the specified
-- resource query.
--
-- 'resourceQuery', 'groupQuery_resourceQuery' - The resource query that determines which AWS resources are members of
-- the associated resource group.
newGroupQuery ::
  -- | 'groupName'
  Prelude.Text ->
  -- | 'resourceQuery'
  ResourceQuery ->
  GroupQuery
newGroupQuery :: Text -> ResourceQuery -> GroupQuery
newGroupQuery Text
pGroupName_ ResourceQuery
pResourceQuery_ =
  GroupQuery' :: Text -> ResourceQuery -> GroupQuery
GroupQuery'
    { $sel:groupName:GroupQuery' :: Text
groupName = Text
pGroupName_,
      $sel:resourceQuery:GroupQuery' :: ResourceQuery
resourceQuery = ResourceQuery
pResourceQuery_
    }

-- | The name of the resource group that is associated with the specified
-- resource query.
groupQuery_groupName :: Lens.Lens' GroupQuery Prelude.Text
groupQuery_groupName :: (Text -> f Text) -> GroupQuery -> f GroupQuery
groupQuery_groupName = (GroupQuery -> Text)
-> (GroupQuery -> Text -> GroupQuery)
-> Lens GroupQuery GroupQuery Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupQuery' {Text
groupName :: Text
$sel:groupName:GroupQuery' :: GroupQuery -> Text
groupName} -> Text
groupName) (\s :: GroupQuery
s@GroupQuery' {} Text
a -> GroupQuery
s {$sel:groupName:GroupQuery' :: Text
groupName = Text
a} :: GroupQuery)

-- | The resource query that determines which AWS resources are members of
-- the associated resource group.
groupQuery_resourceQuery :: Lens.Lens' GroupQuery ResourceQuery
groupQuery_resourceQuery :: (ResourceQuery -> f ResourceQuery) -> GroupQuery -> f GroupQuery
groupQuery_resourceQuery = (GroupQuery -> ResourceQuery)
-> (GroupQuery -> ResourceQuery -> GroupQuery)
-> Lens GroupQuery GroupQuery ResourceQuery ResourceQuery
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GroupQuery' {ResourceQuery
resourceQuery :: ResourceQuery
$sel:resourceQuery:GroupQuery' :: GroupQuery -> ResourceQuery
resourceQuery} -> ResourceQuery
resourceQuery) (\s :: GroupQuery
s@GroupQuery' {} ResourceQuery
a -> GroupQuery
s {$sel:resourceQuery:GroupQuery' :: ResourceQuery
resourceQuery = ResourceQuery
a} :: GroupQuery)

instance Core.FromJSON GroupQuery where
  parseJSON :: Value -> Parser GroupQuery
parseJSON =
    String
-> (Object -> Parser GroupQuery) -> Value -> Parser GroupQuery
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GroupQuery"
      ( \Object
x ->
          Text -> ResourceQuery -> GroupQuery
GroupQuery'
            (Text -> ResourceQuery -> GroupQuery)
-> Parser Text -> Parser (ResourceQuery -> GroupQuery)
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
"GroupName")
            Parser (ResourceQuery -> GroupQuery)
-> Parser ResourceQuery -> Parser GroupQuery
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ResourceQuery
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ResourceQuery")
      )

instance Prelude.Hashable GroupQuery

instance Prelude.NFData GroupQuery