{-# 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.IdentityStore.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)
--
-- Retrieves the group metadata and attributes from @GroupId@ in an
-- identity store.
module Amazonka.IdentityStore.DescribeGroup
  ( -- * Creating a Request
    DescribeGroup (..),
    newDescribeGroup,

    -- * Request Lenses
    describeGroup_identityStoreId,
    describeGroup_groupId,

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

    -- * Response Lenses
    describeGroupResponse_httpStatus,
    describeGroupResponse_groupId,
    describeGroupResponse_displayName,
  )
where

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

-- | /See:/ 'newDescribeGroup' smart constructor.
data DescribeGroup = DescribeGroup'
  { -- | The globally unique identifier for the identity store, such as
    -- @d-1234567890@. In this example, @d-@ is a fixed prefix, and
    -- @1234567890@ is a randomly generated string that contains number and
    -- lower case letters. This value is generated at the time that a new
    -- identity store is created.
    DescribeGroup -> Text
identityStoreId :: Prelude.Text,
    -- | The identifier for a group in the identity store.
    DescribeGroup -> Text
groupId :: 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:
--
-- 'identityStoreId', 'describeGroup_identityStoreId' - The globally unique identifier for the identity store, such as
-- @d-1234567890@. In this example, @d-@ is a fixed prefix, and
-- @1234567890@ is a randomly generated string that contains number and
-- lower case letters. This value is generated at the time that a new
-- identity store is created.
--
-- 'groupId', 'describeGroup_groupId' - The identifier for a group in the identity store.
newDescribeGroup ::
  -- | 'identityStoreId'
  Prelude.Text ->
  -- | 'groupId'
  Prelude.Text ->
  DescribeGroup
newDescribeGroup :: Text -> Text -> DescribeGroup
newDescribeGroup Text
pIdentityStoreId_ Text
pGroupId_ =
  DescribeGroup' :: Text -> Text -> DescribeGroup
DescribeGroup'
    { $sel:identityStoreId:DescribeGroup' :: Text
identityStoreId = Text
pIdentityStoreId_,
      $sel:groupId:DescribeGroup' :: Text
groupId = Text
pGroupId_
    }

-- | The globally unique identifier for the identity store, such as
-- @d-1234567890@. In this example, @d-@ is a fixed prefix, and
-- @1234567890@ is a randomly generated string that contains number and
-- lower case letters. This value is generated at the time that a new
-- identity store is created.
describeGroup_identityStoreId :: Lens.Lens' DescribeGroup Prelude.Text
describeGroup_identityStoreId :: (Text -> f Text) -> DescribeGroup -> f DescribeGroup
describeGroup_identityStoreId = (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
identityStoreId :: Text
$sel:identityStoreId:DescribeGroup' :: DescribeGroup -> Text
identityStoreId} -> Text
identityStoreId) (\s :: DescribeGroup
s@DescribeGroup' {} Text
a -> DescribeGroup
s {$sel:identityStoreId:DescribeGroup' :: Text
identityStoreId = Text
a} :: DescribeGroup)

-- | The identifier for a group in the identity store.
describeGroup_groupId :: Lens.Lens' DescribeGroup Prelude.Text
describeGroup_groupId :: (Text -> f Text) -> DescribeGroup -> f DescribeGroup
describeGroup_groupId = (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
groupId :: Text
$sel:groupId:DescribeGroup' :: DescribeGroup -> Text
groupId} -> Text
groupId) (\s :: DescribeGroup
s@DescribeGroup' {} Text
a -> DescribeGroup
s {$sel:groupId:DescribeGroup' :: Text
groupId = 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, ToJSON a) => Service -> a -> Request a
Request.postJSON 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 ->
          Int -> Text -> Text -> DescribeGroupResponse
DescribeGroupResponse'
            (Int -> Text -> Text -> DescribeGroupResponse)
-> Either String Int
-> Either String (Text -> Text -> DescribeGroupResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (Text -> Text -> DescribeGroupResponse)
-> Either String Text
-> Either String (Text -> DescribeGroupResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"GroupId")
            Either String (Text -> DescribeGroupResponse)
-> Either String Text -> Either String DescribeGroupResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"DisplayName")
      )

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
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSIdentityStore.DescribeGroup" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeGroup where
  toJSON :: DescribeGroup -> Value
toJSON DescribeGroup' {Text
groupId :: Text
identityStoreId :: Text
$sel:groupId:DescribeGroup' :: DescribeGroup -> Text
$sel:identityStoreId:DescribeGroup' :: DescribeGroup -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"IdentityStoreId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
identityStoreId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupId)
          ]
      )

instance Core.ToPath DescribeGroup where
  toPath :: DescribeGroup -> ByteString
toPath = ByteString -> DescribeGroup -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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 response's http status code.
    DescribeGroupResponse -> Int
httpStatus :: Prelude.Int,
    -- | The identifier for a group in the identity store.
    DescribeGroupResponse -> Text
groupId :: Prelude.Text,
    -- | Contains the group’s display name value. The length limit is 1,024
    -- characters. This value can consist of letters, accented characters,
    -- symbols, numbers, punctuation, tab, new line, carriage return, space,
    -- and nonbreaking space in this attribute. The characters @\<>;:%@ are
    -- excluded. This value is specified at the time that the group is created
    -- and stored as an attribute of the group object in the identity store.
    DescribeGroupResponse -> Text
displayName :: Prelude.Text
  }
  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:
--
-- 'httpStatus', 'describeGroupResponse_httpStatus' - The response's http status code.
--
-- 'groupId', 'describeGroupResponse_groupId' - The identifier for a group in the identity store.
--
-- 'displayName', 'describeGroupResponse_displayName' - Contains the group’s display name value. The length limit is 1,024
-- characters. This value can consist of letters, accented characters,
-- symbols, numbers, punctuation, tab, new line, carriage return, space,
-- and nonbreaking space in this attribute. The characters @\<>;:%@ are
-- excluded. This value is specified at the time that the group is created
-- and stored as an attribute of the group object in the identity store.
newDescribeGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'groupId'
  Prelude.Text ->
  -- | 'displayName'
  Prelude.Text ->
  DescribeGroupResponse
newDescribeGroupResponse :: Int -> Text -> Text -> DescribeGroupResponse
newDescribeGroupResponse
  Int
pHttpStatus_
  Text
pGroupId_
  Text
pDisplayName_ =
    DescribeGroupResponse' :: Int -> Text -> Text -> DescribeGroupResponse
DescribeGroupResponse'
      { $sel:httpStatus:DescribeGroupResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:groupId:DescribeGroupResponse' :: Text
groupId = Text
pGroupId_,
        $sel:displayName:DescribeGroupResponse' :: Text
displayName = Text
pDisplayName_
      }

-- | The response's http status code.
describeGroupResponse_httpStatus :: Lens.Lens' DescribeGroupResponse Prelude.Int
describeGroupResponse_httpStatus :: (Int -> f Int) -> DescribeGroupResponse -> f DescribeGroupResponse
describeGroupResponse_httpStatus = (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
httpStatus :: Int
$sel:httpStatus:DescribeGroupResponse' :: DescribeGroupResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeGroupResponse
s@DescribeGroupResponse' {} Int
a -> DescribeGroupResponse
s {$sel:httpStatus:DescribeGroupResponse' :: Int
httpStatus = Int
a} :: DescribeGroupResponse)

-- | The identifier for a group in the identity store.
describeGroupResponse_groupId :: Lens.Lens' DescribeGroupResponse Prelude.Text
describeGroupResponse_groupId :: (Text -> f Text)
-> DescribeGroupResponse -> f DescribeGroupResponse
describeGroupResponse_groupId = (DescribeGroupResponse -> Text)
-> (DescribeGroupResponse -> Text -> DescribeGroupResponse)
-> Lens DescribeGroupResponse DescribeGroupResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGroupResponse' {Text
groupId :: Text
$sel:groupId:DescribeGroupResponse' :: DescribeGroupResponse -> Text
groupId} -> Text
groupId) (\s :: DescribeGroupResponse
s@DescribeGroupResponse' {} Text
a -> DescribeGroupResponse
s {$sel:groupId:DescribeGroupResponse' :: Text
groupId = Text
a} :: DescribeGroupResponse)

-- | Contains the group’s display name value. The length limit is 1,024
-- characters. This value can consist of letters, accented characters,
-- symbols, numbers, punctuation, tab, new line, carriage return, space,
-- and nonbreaking space in this attribute. The characters @\<>;:%@ are
-- excluded. This value is specified at the time that the group is created
-- and stored as an attribute of the group object in the identity store.
describeGroupResponse_displayName :: Lens.Lens' DescribeGroupResponse Prelude.Text
describeGroupResponse_displayName :: (Text -> f Text)
-> DescribeGroupResponse -> f DescribeGroupResponse
describeGroupResponse_displayName = (DescribeGroupResponse -> Text)
-> (DescribeGroupResponse -> Text -> DescribeGroupResponse)
-> Lens DescribeGroupResponse DescribeGroupResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeGroupResponse' {Text
displayName :: Text
$sel:displayName:DescribeGroupResponse' :: DescribeGroupResponse -> Text
displayName} -> Text
displayName) (\s :: DescribeGroupResponse
s@DescribeGroupResponse' {} Text
a -> DescribeGroupResponse
s {$sel:displayName:DescribeGroupResponse' :: Text
displayName = Text
a} :: DescribeGroupResponse)

instance Prelude.NFData DescribeGroupResponse