{-# 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.SSOAdmin.DescribePermissionSet
-- 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)
--
-- Gets the details of the permission set.
module Amazonka.SSOAdmin.DescribePermissionSet
  ( -- * Creating a Request
    DescribePermissionSet (..),
    newDescribePermissionSet,

    -- * Request Lenses
    describePermissionSet_instanceArn,
    describePermissionSet_permissionSetArn,

    -- * Destructuring the Response
    DescribePermissionSetResponse (..),
    newDescribePermissionSetResponse,

    -- * Response Lenses
    describePermissionSetResponse_permissionSet,
    describePermissionSetResponse_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 qualified Amazonka.Response as Response
import Amazonka.SSOAdmin.Types

-- | /See:/ 'newDescribePermissionSet' smart constructor.
data DescribePermissionSet = DescribePermissionSet'
  { -- | The ARN of the SSO instance under which the operation will be executed.
    -- For more information about ARNs, see
    -- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>
    -- in the /Amazon Web Services General Reference/.
    DescribePermissionSet -> Text
instanceArn :: Prelude.Text,
    -- | The ARN of the permission set.
    DescribePermissionSet -> Text
permissionSetArn :: Prelude.Text
  }
  deriving (DescribePermissionSet -> DescribePermissionSet -> Bool
(DescribePermissionSet -> DescribePermissionSet -> Bool)
-> (DescribePermissionSet -> DescribePermissionSet -> Bool)
-> Eq DescribePermissionSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePermissionSet -> DescribePermissionSet -> Bool
$c/= :: DescribePermissionSet -> DescribePermissionSet -> Bool
== :: DescribePermissionSet -> DescribePermissionSet -> Bool
$c== :: DescribePermissionSet -> DescribePermissionSet -> Bool
Prelude.Eq, ReadPrec [DescribePermissionSet]
ReadPrec DescribePermissionSet
Int -> ReadS DescribePermissionSet
ReadS [DescribePermissionSet]
(Int -> ReadS DescribePermissionSet)
-> ReadS [DescribePermissionSet]
-> ReadPrec DescribePermissionSet
-> ReadPrec [DescribePermissionSet]
-> Read DescribePermissionSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePermissionSet]
$creadListPrec :: ReadPrec [DescribePermissionSet]
readPrec :: ReadPrec DescribePermissionSet
$creadPrec :: ReadPrec DescribePermissionSet
readList :: ReadS [DescribePermissionSet]
$creadList :: ReadS [DescribePermissionSet]
readsPrec :: Int -> ReadS DescribePermissionSet
$creadsPrec :: Int -> ReadS DescribePermissionSet
Prelude.Read, Int -> DescribePermissionSet -> ShowS
[DescribePermissionSet] -> ShowS
DescribePermissionSet -> String
(Int -> DescribePermissionSet -> ShowS)
-> (DescribePermissionSet -> String)
-> ([DescribePermissionSet] -> ShowS)
-> Show DescribePermissionSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePermissionSet] -> ShowS
$cshowList :: [DescribePermissionSet] -> ShowS
show :: DescribePermissionSet -> String
$cshow :: DescribePermissionSet -> String
showsPrec :: Int -> DescribePermissionSet -> ShowS
$cshowsPrec :: Int -> DescribePermissionSet -> ShowS
Prelude.Show, (forall x. DescribePermissionSet -> Rep DescribePermissionSet x)
-> (forall x. Rep DescribePermissionSet x -> DescribePermissionSet)
-> Generic DescribePermissionSet
forall x. Rep DescribePermissionSet x -> DescribePermissionSet
forall x. DescribePermissionSet -> Rep DescribePermissionSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribePermissionSet x -> DescribePermissionSet
$cfrom :: forall x. DescribePermissionSet -> Rep DescribePermissionSet x
Prelude.Generic)

-- |
-- Create a value of 'DescribePermissionSet' 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:
--
-- 'instanceArn', 'describePermissionSet_instanceArn' - The ARN of the SSO instance under which the operation will be executed.
-- For more information about ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>
-- in the /Amazon Web Services General Reference/.
--
-- 'permissionSetArn', 'describePermissionSet_permissionSetArn' - The ARN of the permission set.
newDescribePermissionSet ::
  -- | 'instanceArn'
  Prelude.Text ->
  -- | 'permissionSetArn'
  Prelude.Text ->
  DescribePermissionSet
newDescribePermissionSet :: Text -> Text -> DescribePermissionSet
newDescribePermissionSet
  Text
pInstanceArn_
  Text
pPermissionSetArn_ =
    DescribePermissionSet' :: Text -> Text -> DescribePermissionSet
DescribePermissionSet'
      { $sel:instanceArn:DescribePermissionSet' :: Text
instanceArn = Text
pInstanceArn_,
        $sel:permissionSetArn:DescribePermissionSet' :: Text
permissionSetArn = Text
pPermissionSetArn_
      }

-- | The ARN of the SSO instance under which the operation will be executed.
-- For more information about ARNs, see
-- </general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs) and Amazon Web Services Service Namespaces>
-- in the /Amazon Web Services General Reference/.
describePermissionSet_instanceArn :: Lens.Lens' DescribePermissionSet Prelude.Text
describePermissionSet_instanceArn :: (Text -> f Text)
-> DescribePermissionSet -> f DescribePermissionSet
describePermissionSet_instanceArn = (DescribePermissionSet -> Text)
-> (DescribePermissionSet -> Text -> DescribePermissionSet)
-> Lens DescribePermissionSet DescribePermissionSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePermissionSet' {Text
instanceArn :: Text
$sel:instanceArn:DescribePermissionSet' :: DescribePermissionSet -> Text
instanceArn} -> Text
instanceArn) (\s :: DescribePermissionSet
s@DescribePermissionSet' {} Text
a -> DescribePermissionSet
s {$sel:instanceArn:DescribePermissionSet' :: Text
instanceArn = Text
a} :: DescribePermissionSet)

-- | The ARN of the permission set.
describePermissionSet_permissionSetArn :: Lens.Lens' DescribePermissionSet Prelude.Text
describePermissionSet_permissionSetArn :: (Text -> f Text)
-> DescribePermissionSet -> f DescribePermissionSet
describePermissionSet_permissionSetArn = (DescribePermissionSet -> Text)
-> (DescribePermissionSet -> Text -> DescribePermissionSet)
-> Lens DescribePermissionSet DescribePermissionSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePermissionSet' {Text
permissionSetArn :: Text
$sel:permissionSetArn:DescribePermissionSet' :: DescribePermissionSet -> Text
permissionSetArn} -> Text
permissionSetArn) (\s :: DescribePermissionSet
s@DescribePermissionSet' {} Text
a -> DescribePermissionSet
s {$sel:permissionSetArn:DescribePermissionSet' :: Text
permissionSetArn = Text
a} :: DescribePermissionSet)

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

instance Prelude.NFData DescribePermissionSet

instance Core.ToHeaders DescribePermissionSet where
  toHeaders :: DescribePermissionSet -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribePermissionSet -> 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
"SWBExternalService.DescribePermissionSet" ::
                          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 DescribePermissionSet where
  toJSON :: DescribePermissionSet -> Value
toJSON DescribePermissionSet' {Text
permissionSetArn :: Text
instanceArn :: Text
$sel:permissionSetArn:DescribePermissionSet' :: DescribePermissionSet -> Text
$sel:instanceArn:DescribePermissionSet' :: DescribePermissionSet -> 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
"InstanceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"PermissionSetArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
permissionSetArn)
          ]
      )

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

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

-- | /See:/ 'newDescribePermissionSetResponse' smart constructor.
data DescribePermissionSetResponse = DescribePermissionSetResponse'
  { -- | Describes the level of access on an Amazon Web Services account.
    DescribePermissionSetResponse -> Maybe PermissionSet
permissionSet :: Prelude.Maybe PermissionSet,
    -- | The response's http status code.
    DescribePermissionSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribePermissionSetResponse
-> DescribePermissionSetResponse -> Bool
(DescribePermissionSetResponse
 -> DescribePermissionSetResponse -> Bool)
-> (DescribePermissionSetResponse
    -> DescribePermissionSetResponse -> Bool)
-> Eq DescribePermissionSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribePermissionSetResponse
-> DescribePermissionSetResponse -> Bool
$c/= :: DescribePermissionSetResponse
-> DescribePermissionSetResponse -> Bool
== :: DescribePermissionSetResponse
-> DescribePermissionSetResponse -> Bool
$c== :: DescribePermissionSetResponse
-> DescribePermissionSetResponse -> Bool
Prelude.Eq, ReadPrec [DescribePermissionSetResponse]
ReadPrec DescribePermissionSetResponse
Int -> ReadS DescribePermissionSetResponse
ReadS [DescribePermissionSetResponse]
(Int -> ReadS DescribePermissionSetResponse)
-> ReadS [DescribePermissionSetResponse]
-> ReadPrec DescribePermissionSetResponse
-> ReadPrec [DescribePermissionSetResponse]
-> Read DescribePermissionSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribePermissionSetResponse]
$creadListPrec :: ReadPrec [DescribePermissionSetResponse]
readPrec :: ReadPrec DescribePermissionSetResponse
$creadPrec :: ReadPrec DescribePermissionSetResponse
readList :: ReadS [DescribePermissionSetResponse]
$creadList :: ReadS [DescribePermissionSetResponse]
readsPrec :: Int -> ReadS DescribePermissionSetResponse
$creadsPrec :: Int -> ReadS DescribePermissionSetResponse
Prelude.Read, Int -> DescribePermissionSetResponse -> ShowS
[DescribePermissionSetResponse] -> ShowS
DescribePermissionSetResponse -> String
(Int -> DescribePermissionSetResponse -> ShowS)
-> (DescribePermissionSetResponse -> String)
-> ([DescribePermissionSetResponse] -> ShowS)
-> Show DescribePermissionSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribePermissionSetResponse] -> ShowS
$cshowList :: [DescribePermissionSetResponse] -> ShowS
show :: DescribePermissionSetResponse -> String
$cshow :: DescribePermissionSetResponse -> String
showsPrec :: Int -> DescribePermissionSetResponse -> ShowS
$cshowsPrec :: Int -> DescribePermissionSetResponse -> ShowS
Prelude.Show, (forall x.
 DescribePermissionSetResponse
 -> Rep DescribePermissionSetResponse x)
-> (forall x.
    Rep DescribePermissionSetResponse x
    -> DescribePermissionSetResponse)
-> Generic DescribePermissionSetResponse
forall x.
Rep DescribePermissionSetResponse x
-> DescribePermissionSetResponse
forall x.
DescribePermissionSetResponse
-> Rep DescribePermissionSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribePermissionSetResponse x
-> DescribePermissionSetResponse
$cfrom :: forall x.
DescribePermissionSetResponse
-> Rep DescribePermissionSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribePermissionSetResponse' 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:
--
-- 'permissionSet', 'describePermissionSetResponse_permissionSet' - Describes the level of access on an Amazon Web Services account.
--
-- 'httpStatus', 'describePermissionSetResponse_httpStatus' - The response's http status code.
newDescribePermissionSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribePermissionSetResponse
newDescribePermissionSetResponse :: Int -> DescribePermissionSetResponse
newDescribePermissionSetResponse Int
pHttpStatus_ =
  DescribePermissionSetResponse' :: Maybe PermissionSet -> Int -> DescribePermissionSetResponse
DescribePermissionSetResponse'
    { $sel:permissionSet:DescribePermissionSetResponse' :: Maybe PermissionSet
permissionSet =
        Maybe PermissionSet
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribePermissionSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Describes the level of access on an Amazon Web Services account.
describePermissionSetResponse_permissionSet :: Lens.Lens' DescribePermissionSetResponse (Prelude.Maybe PermissionSet)
describePermissionSetResponse_permissionSet :: (Maybe PermissionSet -> f (Maybe PermissionSet))
-> DescribePermissionSetResponse -> f DescribePermissionSetResponse
describePermissionSetResponse_permissionSet = (DescribePermissionSetResponse -> Maybe PermissionSet)
-> (DescribePermissionSetResponse
    -> Maybe PermissionSet -> DescribePermissionSetResponse)
-> Lens
     DescribePermissionSetResponse
     DescribePermissionSetResponse
     (Maybe PermissionSet)
     (Maybe PermissionSet)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribePermissionSetResponse' {Maybe PermissionSet
permissionSet :: Maybe PermissionSet
$sel:permissionSet:DescribePermissionSetResponse' :: DescribePermissionSetResponse -> Maybe PermissionSet
permissionSet} -> Maybe PermissionSet
permissionSet) (\s :: DescribePermissionSetResponse
s@DescribePermissionSetResponse' {} Maybe PermissionSet
a -> DescribePermissionSetResponse
s {$sel:permissionSet:DescribePermissionSetResponse' :: Maybe PermissionSet
permissionSet = Maybe PermissionSet
a} :: DescribePermissionSetResponse)

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

instance Prelude.NFData DescribePermissionSetResponse