{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetGroupQuery
-- 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)
--
-- Retrieves the resource query associated with the specified resource
-- group. For more information about resource queries, see
-- <https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#gettingstarted-query-cli-tag Create a tag-based group in Resource Groups>.
--
-- __Minimum permissions__
--
-- To run this command, you must have the following permissions:
--
-- -   @resource-groups:GetGroupQuery@
module Amazonka.ResourceGroups.GetGroupQuery
  ( -- * Creating a Request
    GetGroupQuery (..),
    newGetGroupQuery,

    -- * Request Lenses
    getGroupQuery_group,
    getGroupQuery_groupName,

    -- * Destructuring the Response
    GetGroupQueryResponse (..),
    newGetGroupQueryResponse,

    -- * Response Lenses
    getGroupQueryResponse_groupQuery,
    getGroupQueryResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import Amazonka.ResourceGroups.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetGroupQuery' smart constructor.
data GetGroupQuery = GetGroupQuery'
  { -- | The name or the ARN of the resource group to query.
    GetGroupQuery -> Maybe Text
group' :: Prelude.Maybe Prelude.Text,
    -- | Don\'t use this parameter. Use @Group@ instead.
    GetGroupQuery -> Maybe Text
groupName :: Prelude.Maybe Prelude.Text
  }
  deriving (GetGroupQuery -> GetGroupQuery -> Bool
(GetGroupQuery -> GetGroupQuery -> Bool)
-> (GetGroupQuery -> GetGroupQuery -> Bool) -> Eq GetGroupQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetGroupQuery -> GetGroupQuery -> Bool
$c/= :: GetGroupQuery -> GetGroupQuery -> Bool
== :: GetGroupQuery -> GetGroupQuery -> Bool
$c== :: GetGroupQuery -> GetGroupQuery -> Bool
Prelude.Eq, ReadPrec [GetGroupQuery]
ReadPrec GetGroupQuery
Int -> ReadS GetGroupQuery
ReadS [GetGroupQuery]
(Int -> ReadS GetGroupQuery)
-> ReadS [GetGroupQuery]
-> ReadPrec GetGroupQuery
-> ReadPrec [GetGroupQuery]
-> Read GetGroupQuery
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetGroupQuery]
$creadListPrec :: ReadPrec [GetGroupQuery]
readPrec :: ReadPrec GetGroupQuery
$creadPrec :: ReadPrec GetGroupQuery
readList :: ReadS [GetGroupQuery]
$creadList :: ReadS [GetGroupQuery]
readsPrec :: Int -> ReadS GetGroupQuery
$creadsPrec :: Int -> ReadS GetGroupQuery
Prelude.Read, Int -> GetGroupQuery -> ShowS
[GetGroupQuery] -> ShowS
GetGroupQuery -> String
(Int -> GetGroupQuery -> ShowS)
-> (GetGroupQuery -> String)
-> ([GetGroupQuery] -> ShowS)
-> Show GetGroupQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetGroupQuery] -> ShowS
$cshowList :: [GetGroupQuery] -> ShowS
show :: GetGroupQuery -> String
$cshow :: GetGroupQuery -> String
showsPrec :: Int -> GetGroupQuery -> ShowS
$cshowsPrec :: Int -> GetGroupQuery -> ShowS
Prelude.Show, (forall x. GetGroupQuery -> Rep GetGroupQuery x)
-> (forall x. Rep GetGroupQuery x -> GetGroupQuery)
-> Generic GetGroupQuery
forall x. Rep GetGroupQuery x -> GetGroupQuery
forall x. GetGroupQuery -> Rep GetGroupQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetGroupQuery x -> GetGroupQuery
$cfrom :: forall x. GetGroupQuery -> Rep GetGroupQuery x
Prelude.Generic)

-- |
-- Create a value of 'GetGroupQuery' 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:
--
-- 'group'', 'getGroupQuery_group' - The name or the ARN of the resource group to query.
--
-- 'groupName', 'getGroupQuery_groupName' - Don\'t use this parameter. Use @Group@ instead.
newGetGroupQuery ::
  GetGroupQuery
newGetGroupQuery :: GetGroupQuery
newGetGroupQuery =
  GetGroupQuery' :: Maybe Text -> Maybe Text -> GetGroupQuery
GetGroupQuery'
    { $sel:group':GetGroupQuery' :: Maybe Text
group' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupName:GetGroupQuery' :: Maybe Text
groupName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name or the ARN of the resource group to query.
getGroupQuery_group :: Lens.Lens' GetGroupQuery (Prelude.Maybe Prelude.Text)
getGroupQuery_group :: (Maybe Text -> f (Maybe Text)) -> GetGroupQuery -> f GetGroupQuery
getGroupQuery_group = (GetGroupQuery -> Maybe Text)
-> (GetGroupQuery -> Maybe Text -> GetGroupQuery)
-> Lens GetGroupQuery GetGroupQuery (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGroupQuery' {Maybe Text
group' :: Maybe Text
$sel:group':GetGroupQuery' :: GetGroupQuery -> Maybe Text
group'} -> Maybe Text
group') (\s :: GetGroupQuery
s@GetGroupQuery' {} Maybe Text
a -> GetGroupQuery
s {$sel:group':GetGroupQuery' :: Maybe Text
group' = Maybe Text
a} :: GetGroupQuery)

-- | Don\'t use this parameter. Use @Group@ instead.
getGroupQuery_groupName :: Lens.Lens' GetGroupQuery (Prelude.Maybe Prelude.Text)
getGroupQuery_groupName :: (Maybe Text -> f (Maybe Text)) -> GetGroupQuery -> f GetGroupQuery
getGroupQuery_groupName = (GetGroupQuery -> Maybe Text)
-> (GetGroupQuery -> Maybe Text -> GetGroupQuery)
-> Lens GetGroupQuery GetGroupQuery (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGroupQuery' {Maybe Text
groupName :: Maybe Text
$sel:groupName:GetGroupQuery' :: GetGroupQuery -> Maybe Text
groupName} -> Maybe Text
groupName) (\s :: GetGroupQuery
s@GetGroupQuery' {} Maybe Text
a -> GetGroupQuery
s {$sel:groupName:GetGroupQuery' :: Maybe Text
groupName = Maybe Text
a} :: GetGroupQuery)

instance Core.AWSRequest GetGroupQuery where
  type
    AWSResponse GetGroupQuery =
      GetGroupQueryResponse
  request :: GetGroupQuery -> Request GetGroupQuery
request = Service -> GetGroupQuery -> Request GetGroupQuery
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetGroupQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGroupQuery)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetGroupQuery))
-> Logger
-> Service
-> Proxy GetGroupQuery
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetGroupQuery)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe GroupQuery -> Int -> GetGroupQueryResponse
GetGroupQueryResponse'
            (Maybe GroupQuery -> Int -> GetGroupQueryResponse)
-> Either String (Maybe GroupQuery)
-> Either String (Int -> GetGroupQueryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe GroupQuery)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GroupQuery")
            Either String (Int -> GetGroupQueryResponse)
-> Either String Int -> Either String GetGroupQueryResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetGroupQuery

instance Prelude.NFData GetGroupQuery

instance Core.ToHeaders GetGroupQuery where
  toHeaders :: GetGroupQuery -> ResponseHeaders
toHeaders = ResponseHeaders -> GetGroupQuery -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToPath GetGroupQuery where
  toPath :: GetGroupQuery -> ByteString
toPath = ByteString -> GetGroupQuery -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/get-group-query"

instance Core.ToQuery GetGroupQuery where
  toQuery :: GetGroupQuery -> QueryString
toQuery = QueryString -> GetGroupQuery -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetGroupQueryResponse' smart constructor.
data GetGroupQueryResponse = GetGroupQueryResponse'
  { -- | The resource query associated with the specified group. For more
    -- information about resource queries, see
    -- <https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#gettingstarted-query-cli-tag Create a tag-based group in Resource Groups>.
    GetGroupQueryResponse -> Maybe GroupQuery
groupQuery :: Prelude.Maybe GroupQuery,
    -- | The response's http status code.
    GetGroupQueryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetGroupQueryResponse -> GetGroupQueryResponse -> Bool
(GetGroupQueryResponse -> GetGroupQueryResponse -> Bool)
-> (GetGroupQueryResponse -> GetGroupQueryResponse -> Bool)
-> Eq GetGroupQueryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetGroupQueryResponse -> GetGroupQueryResponse -> Bool
$c/= :: GetGroupQueryResponse -> GetGroupQueryResponse -> Bool
== :: GetGroupQueryResponse -> GetGroupQueryResponse -> Bool
$c== :: GetGroupQueryResponse -> GetGroupQueryResponse -> Bool
Prelude.Eq, ReadPrec [GetGroupQueryResponse]
ReadPrec GetGroupQueryResponse
Int -> ReadS GetGroupQueryResponse
ReadS [GetGroupQueryResponse]
(Int -> ReadS GetGroupQueryResponse)
-> ReadS [GetGroupQueryResponse]
-> ReadPrec GetGroupQueryResponse
-> ReadPrec [GetGroupQueryResponse]
-> Read GetGroupQueryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetGroupQueryResponse]
$creadListPrec :: ReadPrec [GetGroupQueryResponse]
readPrec :: ReadPrec GetGroupQueryResponse
$creadPrec :: ReadPrec GetGroupQueryResponse
readList :: ReadS [GetGroupQueryResponse]
$creadList :: ReadS [GetGroupQueryResponse]
readsPrec :: Int -> ReadS GetGroupQueryResponse
$creadsPrec :: Int -> ReadS GetGroupQueryResponse
Prelude.Read, Int -> GetGroupQueryResponse -> ShowS
[GetGroupQueryResponse] -> ShowS
GetGroupQueryResponse -> String
(Int -> GetGroupQueryResponse -> ShowS)
-> (GetGroupQueryResponse -> String)
-> ([GetGroupQueryResponse] -> ShowS)
-> Show GetGroupQueryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetGroupQueryResponse] -> ShowS
$cshowList :: [GetGroupQueryResponse] -> ShowS
show :: GetGroupQueryResponse -> String
$cshow :: GetGroupQueryResponse -> String
showsPrec :: Int -> GetGroupQueryResponse -> ShowS
$cshowsPrec :: Int -> GetGroupQueryResponse -> ShowS
Prelude.Show, (forall x. GetGroupQueryResponse -> Rep GetGroupQueryResponse x)
-> (forall x. Rep GetGroupQueryResponse x -> GetGroupQueryResponse)
-> Generic GetGroupQueryResponse
forall x. Rep GetGroupQueryResponse x -> GetGroupQueryResponse
forall x. GetGroupQueryResponse -> Rep GetGroupQueryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetGroupQueryResponse x -> GetGroupQueryResponse
$cfrom :: forall x. GetGroupQueryResponse -> Rep GetGroupQueryResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetGroupQueryResponse' 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:
--
-- 'groupQuery', 'getGroupQueryResponse_groupQuery' - The resource query associated with the specified group. For more
-- information about resource queries, see
-- <https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#gettingstarted-query-cli-tag Create a tag-based group in Resource Groups>.
--
-- 'httpStatus', 'getGroupQueryResponse_httpStatus' - The response's http status code.
newGetGroupQueryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetGroupQueryResponse
newGetGroupQueryResponse :: Int -> GetGroupQueryResponse
newGetGroupQueryResponse Int
pHttpStatus_ =
  GetGroupQueryResponse' :: Maybe GroupQuery -> Int -> GetGroupQueryResponse
GetGroupQueryResponse'
    { $sel:groupQuery:GetGroupQueryResponse' :: Maybe GroupQuery
groupQuery =
        Maybe GroupQuery
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetGroupQueryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The resource query associated with the specified group. For more
-- information about resource queries, see
-- <https://docs.aws.amazon.com/ARG/latest/userguide/gettingstarted-query.html#gettingstarted-query-cli-tag Create a tag-based group in Resource Groups>.
getGroupQueryResponse_groupQuery :: Lens.Lens' GetGroupQueryResponse (Prelude.Maybe GroupQuery)
getGroupQueryResponse_groupQuery :: (Maybe GroupQuery -> f (Maybe GroupQuery))
-> GetGroupQueryResponse -> f GetGroupQueryResponse
getGroupQueryResponse_groupQuery = (GetGroupQueryResponse -> Maybe GroupQuery)
-> (GetGroupQueryResponse
    -> Maybe GroupQuery -> GetGroupQueryResponse)
-> Lens
     GetGroupQueryResponse
     GetGroupQueryResponse
     (Maybe GroupQuery)
     (Maybe GroupQuery)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGroupQueryResponse' {Maybe GroupQuery
groupQuery :: Maybe GroupQuery
$sel:groupQuery:GetGroupQueryResponse' :: GetGroupQueryResponse -> Maybe GroupQuery
groupQuery} -> Maybe GroupQuery
groupQuery) (\s :: GetGroupQueryResponse
s@GetGroupQueryResponse' {} Maybe GroupQuery
a -> GetGroupQueryResponse
s {$sel:groupQuery:GetGroupQueryResponse' :: Maybe GroupQuery
groupQuery = Maybe GroupQuery
a} :: GetGroupQueryResponse)

-- | The response's http status code.
getGroupQueryResponse_httpStatus :: Lens.Lens' GetGroupQueryResponse Prelude.Int
getGroupQueryResponse_httpStatus :: (Int -> f Int) -> GetGroupQueryResponse -> f GetGroupQueryResponse
getGroupQueryResponse_httpStatus = (GetGroupQueryResponse -> Int)
-> (GetGroupQueryResponse -> Int -> GetGroupQueryResponse)
-> Lens GetGroupQueryResponse GetGroupQueryResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGroupQueryResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetGroupQueryResponse' :: GetGroupQueryResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetGroupQueryResponse
s@GetGroupQueryResponse' {} Int
a -> GetGroupQueryResponse
s {$sel:httpStatus:GetGroupQueryResponse' :: Int
httpStatus = Int
a} :: GetGroupQueryResponse)

instance Prelude.NFData GetGroupQueryResponse