{-# 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.QuickSight.DescribeGroup
-- 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)
--
-- Returns an Amazon QuickSight group\'s description and Amazon Resource
-- Name (ARN).
module Amazonka.QuickSight.DescribeGroup
  ( -- * Creating a Request
    DescribeGroup (..),
    newDescribeGroup,

    -- * Request Lenses
    describeGroup_groupName,
    describeGroup_awsAccountId,
    describeGroup_namespace,

    -- * Destructuring the Response
    DescribeGroupResponse (..),
    newDescribeGroupResponse,

    -- * Response Lenses
    describeGroupResponse_requestId,
    describeGroupResponse_group,
    describeGroupResponse_status,
  )
where

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

-- | /See:/ 'newDescribeGroup' smart constructor.
data DescribeGroup = DescribeGroup'
  { -- | The name of the group that you want to describe.
    DescribeGroup -> Text
groupName :: Prelude.Text,
    -- | The ID for the Amazon Web Services account that the group is in.
    -- Currently, you use the ID for the Amazon Web Services account that
    -- contains your Amazon QuickSight account.
    DescribeGroup -> Text
awsAccountId :: Prelude.Text,
    -- | The namespace. Currently, you should set this to @default@.
    DescribeGroup -> Text
namespace :: Prelude.Text
  }
  deriving (DescribeGroup -> DescribeGroup -> Bool
(DescribeGroup -> DescribeGroup -> Bool)
-> (DescribeGroup -> DescribeGroup -> Bool) -> Eq DescribeGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGroup -> DescribeGroup -> Bool
$c/= :: DescribeGroup -> DescribeGroup -> Bool
== :: DescribeGroup -> DescribeGroup -> Bool
$c== :: DescribeGroup -> DescribeGroup -> Bool
Prelude.Eq, ReadPrec [DescribeGroup]
ReadPrec DescribeGroup
Int -> ReadS DescribeGroup
ReadS [DescribeGroup]
(Int -> ReadS DescribeGroup)
-> ReadS [DescribeGroup]
-> ReadPrec DescribeGroup
-> ReadPrec [DescribeGroup]
-> Read DescribeGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGroup]
$creadListPrec :: ReadPrec [DescribeGroup]
readPrec :: ReadPrec DescribeGroup
$creadPrec :: ReadPrec DescribeGroup
readList :: ReadS [DescribeGroup]
$creadList :: ReadS [DescribeGroup]
readsPrec :: Int -> ReadS DescribeGroup
$creadsPrec :: Int -> ReadS DescribeGroup
Prelude.Read, Int -> DescribeGroup -> ShowS
[DescribeGroup] -> ShowS
DescribeGroup -> String
(Int -> DescribeGroup -> ShowS)
-> (DescribeGroup -> String)
-> ([DescribeGroup] -> ShowS)
-> Show DescribeGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGroup] -> ShowS
$cshowList :: [DescribeGroup] -> ShowS
show :: DescribeGroup -> String
$cshow :: DescribeGroup -> String
showsPrec :: Int -> DescribeGroup -> ShowS
$cshowsPrec :: Int -> DescribeGroup -> ShowS
Prelude.Show, (forall x. DescribeGroup -> Rep DescribeGroup x)
-> (forall x. Rep DescribeGroup x -> DescribeGroup)
-> Generic DescribeGroup
forall x. Rep DescribeGroup x -> DescribeGroup
forall x. DescribeGroup -> Rep DescribeGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeGroup x -> DescribeGroup
$cfrom :: forall x. DescribeGroup -> Rep DescribeGroup x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGroup' 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', 'describeGroup_groupName' - The name of the group that you want to describe.
--
-- 'awsAccountId', 'describeGroup_awsAccountId' - The ID for the Amazon Web Services account that the group is in.
-- Currently, you use the ID for the Amazon Web Services account that
-- contains your Amazon QuickSight account.
--
-- 'namespace', 'describeGroup_namespace' - The namespace. Currently, you should set this to @default@.
newDescribeGroup ::
  -- | 'groupName'
  Prelude.Text ->
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'namespace'
  Prelude.Text ->
  DescribeGroup
newDescribeGroup :: Text -> Text -> Text -> DescribeGroup
newDescribeGroup
  Text
pGroupName_
  Text
pAwsAccountId_
  Text
pNamespace_ =
    DescribeGroup' :: Text -> Text -> Text -> DescribeGroup
DescribeGroup'
      { $sel:groupName:DescribeGroup' :: Text
groupName = Text
pGroupName_,
        $sel:awsAccountId:DescribeGroup' :: Text
awsAccountId = Text
pAwsAccountId_,
        $sel:namespace:DescribeGroup' :: Text
namespace = Text
pNamespace_
      }

-- | The name of the group that you want to describe.
describeGroup_groupName :: Lens.Lens' DescribeGroup Prelude.Text
describeGroup_groupName :: (Text -> f Text) -> DescribeGroup -> f DescribeGroup
describeGroup_groupName = (DescribeGroup -> Text)
-> (DescribeGroup -> Text -> DescribeGroup)
-> Lens DescribeGroup DescribeGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGroup' {Text
groupName :: Text
$sel:groupName:DescribeGroup' :: DescribeGroup -> Text
groupName} -> Text
groupName) (\s :: DescribeGroup
s@DescribeGroup' {} Text
a -> DescribeGroup
s {$sel:groupName:DescribeGroup' :: Text
groupName = Text
a} :: DescribeGroup)

-- | The ID for the Amazon Web Services account that the group is in.
-- Currently, you use the ID for the Amazon Web Services account that
-- contains your Amazon QuickSight account.
describeGroup_awsAccountId :: Lens.Lens' DescribeGroup Prelude.Text
describeGroup_awsAccountId :: (Text -> f Text) -> DescribeGroup -> f DescribeGroup
describeGroup_awsAccountId = (DescribeGroup -> Text)
-> (DescribeGroup -> Text -> DescribeGroup)
-> Lens DescribeGroup DescribeGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGroup' {Text
awsAccountId :: Text
$sel:awsAccountId:DescribeGroup' :: DescribeGroup -> Text
awsAccountId} -> Text
awsAccountId) (\s :: DescribeGroup
s@DescribeGroup' {} Text
a -> DescribeGroup
s {$sel:awsAccountId:DescribeGroup' :: Text
awsAccountId = Text
a} :: DescribeGroup)

-- | The namespace. Currently, you should set this to @default@.
describeGroup_namespace :: Lens.Lens' DescribeGroup Prelude.Text
describeGroup_namespace :: (Text -> f Text) -> DescribeGroup -> f DescribeGroup
describeGroup_namespace = (DescribeGroup -> Text)
-> (DescribeGroup -> Text -> DescribeGroup)
-> Lens DescribeGroup DescribeGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGroup' {Text
namespace :: Text
$sel:namespace:DescribeGroup' :: DescribeGroup -> Text
namespace} -> Text
namespace) (\s :: DescribeGroup
s@DescribeGroup' {} Text
a -> DescribeGroup
s {$sel:namespace:DescribeGroup' :: Text
namespace = Text
a} :: DescribeGroup)

instance Core.AWSRequest DescribeGroup where
  type
    AWSResponse DescribeGroup =
      DescribeGroupResponse
  request :: DescribeGroup -> Request DescribeGroup
request = Service -> DescribeGroup -> Request DescribeGroup
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeGroup)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeGroup))
-> Logger
-> Service
-> Proxy DescribeGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeGroup)))
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 Text -> Maybe Group -> Int -> DescribeGroupResponse
DescribeGroupResponse'
            (Maybe Text -> Maybe Group -> Int -> DescribeGroupResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Group -> Int -> DescribeGroupResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RequestId")
            Either String (Maybe Group -> Int -> DescribeGroupResponse)
-> Either String (Maybe Group)
-> Either String (Int -> DescribeGroupResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Group)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Group")
            Either String (Int -> DescribeGroupResponse)
-> Either String Int -> Either String DescribeGroupResponse
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 DescribeGroup

instance Prelude.NFData DescribeGroup

instance Core.ToHeaders DescribeGroup where
  toHeaders :: DescribeGroup -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath DescribeGroup where
  toPath :: DescribeGroup -> ByteString
toPath DescribeGroup' {Text
namespace :: Text
awsAccountId :: Text
groupName :: Text
$sel:namespace:DescribeGroup' :: DescribeGroup -> Text
$sel:awsAccountId:DescribeGroup' :: DescribeGroup -> Text
$sel:groupName:DescribeGroup' :: DescribeGroup -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
awsAccountId,
        ByteString
"/namespaces/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
namespace,
        ByteString
"/groups/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
groupName
      ]

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

-- | /See:/ 'newDescribeGroupResponse' smart constructor.
data DescribeGroupResponse = DescribeGroupResponse'
  { -- | The Amazon Web Services request ID for this operation.
    DescribeGroupResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The name of the group.
    DescribeGroupResponse -> Maybe Group
group' :: Prelude.Maybe Group,
    -- | The HTTP status of the request.
    DescribeGroupResponse -> Int
status :: Prelude.Int
  }
  deriving (DescribeGroupResponse -> DescribeGroupResponse -> Bool
(DescribeGroupResponse -> DescribeGroupResponse -> Bool)
-> (DescribeGroupResponse -> DescribeGroupResponse -> Bool)
-> Eq DescribeGroupResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeGroupResponse -> DescribeGroupResponse -> Bool
$c/= :: DescribeGroupResponse -> DescribeGroupResponse -> Bool
== :: DescribeGroupResponse -> DescribeGroupResponse -> Bool
$c== :: DescribeGroupResponse -> DescribeGroupResponse -> Bool
Prelude.Eq, ReadPrec [DescribeGroupResponse]
ReadPrec DescribeGroupResponse
Int -> ReadS DescribeGroupResponse
ReadS [DescribeGroupResponse]
(Int -> ReadS DescribeGroupResponse)
-> ReadS [DescribeGroupResponse]
-> ReadPrec DescribeGroupResponse
-> ReadPrec [DescribeGroupResponse]
-> Read DescribeGroupResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeGroupResponse]
$creadListPrec :: ReadPrec [DescribeGroupResponse]
readPrec :: ReadPrec DescribeGroupResponse
$creadPrec :: ReadPrec DescribeGroupResponse
readList :: ReadS [DescribeGroupResponse]
$creadList :: ReadS [DescribeGroupResponse]
readsPrec :: Int -> ReadS DescribeGroupResponse
$creadsPrec :: Int -> ReadS DescribeGroupResponse
Prelude.Read, Int -> DescribeGroupResponse -> ShowS
[DescribeGroupResponse] -> ShowS
DescribeGroupResponse -> String
(Int -> DescribeGroupResponse -> ShowS)
-> (DescribeGroupResponse -> String)
-> ([DescribeGroupResponse] -> ShowS)
-> Show DescribeGroupResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeGroupResponse] -> ShowS
$cshowList :: [DescribeGroupResponse] -> ShowS
show :: DescribeGroupResponse -> String
$cshow :: DescribeGroupResponse -> String
showsPrec :: Int -> DescribeGroupResponse -> ShowS
$cshowsPrec :: Int -> DescribeGroupResponse -> ShowS
Prelude.Show, (forall x. DescribeGroupResponse -> Rep DescribeGroupResponse x)
-> (forall x. Rep DescribeGroupResponse x -> DescribeGroupResponse)
-> Generic DescribeGroupResponse
forall x. Rep DescribeGroupResponse x -> DescribeGroupResponse
forall x. DescribeGroupResponse -> Rep DescribeGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeGroupResponse x -> DescribeGroupResponse
$cfrom :: forall x. DescribeGroupResponse -> Rep DescribeGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeGroupResponse' 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:
--
-- 'requestId', 'describeGroupResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'group'', 'describeGroupResponse_group' - The name of the group.
--
-- 'status', 'describeGroupResponse_status' - The HTTP status of the request.
newDescribeGroupResponse ::
  -- | 'status'
  Prelude.Int ->
  DescribeGroupResponse
newDescribeGroupResponse :: Int -> DescribeGroupResponse
newDescribeGroupResponse Int
pStatus_ =
  DescribeGroupResponse' :: Maybe Text -> Maybe Group -> Int -> DescribeGroupResponse
DescribeGroupResponse'
    { $sel:requestId:DescribeGroupResponse' :: Maybe Text
requestId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:group':DescribeGroupResponse' :: Maybe Group
group' = Maybe Group
forall a. Maybe a
Prelude.Nothing,
      $sel:status:DescribeGroupResponse' :: Int
status = Int
pStatus_
    }

-- | The Amazon Web Services request ID for this operation.
describeGroupResponse_requestId :: Lens.Lens' DescribeGroupResponse (Prelude.Maybe Prelude.Text)
describeGroupResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> DescribeGroupResponse -> f DescribeGroupResponse
describeGroupResponse_requestId = (DescribeGroupResponse -> Maybe Text)
-> (DescribeGroupResponse -> Maybe Text -> DescribeGroupResponse)
-> Lens
     DescribeGroupResponse
     DescribeGroupResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGroupResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:DescribeGroupResponse' :: DescribeGroupResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: DescribeGroupResponse
s@DescribeGroupResponse' {} Maybe Text
a -> DescribeGroupResponse
s {$sel:requestId:DescribeGroupResponse' :: Maybe Text
requestId = Maybe Text
a} :: DescribeGroupResponse)

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

-- | The HTTP status of the request.
describeGroupResponse_status :: Lens.Lens' DescribeGroupResponse Prelude.Int
describeGroupResponse_status :: (Int -> f Int) -> DescribeGroupResponse -> f DescribeGroupResponse
describeGroupResponse_status = (DescribeGroupResponse -> Int)
-> (DescribeGroupResponse -> Int -> DescribeGroupResponse)
-> Lens DescribeGroupResponse DescribeGroupResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGroupResponse' {Int
status :: Int
$sel:status:DescribeGroupResponse' :: DescribeGroupResponse -> Int
status} -> Int
status) (\s :: DescribeGroupResponse
s@DescribeGroupResponse' {} Int
a -> DescribeGroupResponse
s {$sel:status:DescribeGroupResponse' :: Int
status = Int
a} :: DescribeGroupResponse)

instance Prelude.NFData DescribeGroupResponse