{-# 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.IAM.Types.ListPoliciesGrantingServiceAccessEntry
-- 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.IAM.Types.ListPoliciesGrantingServiceAccessEntry where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types.PolicyGrantingServiceAccess
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the permissions policies that are attached to the
-- specified identity (user, group, or role).
--
-- This data type is used as a response element in the
-- ListPoliciesGrantingServiceAccess operation.
--
-- /See:/ 'newListPoliciesGrantingServiceAccessEntry' smart constructor.
data ListPoliciesGrantingServiceAccessEntry = ListPoliciesGrantingServiceAccessEntry'
  { -- | The namespace of the service that was accessed.
    --
    -- To learn the service namespace of a service, see
    -- <https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html Actions, resources, and condition keys for Amazon Web Services services>
    -- in the /Service Authorization Reference/. Choose the name of the service
    -- to view details for that service. In the first paragraph, find the
    -- service prefix. For example, @(service prefix: a4b)@. For more
    -- information about service namespaces, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces Amazon Web Services service namespaces>
    -- in the /Amazon Web Services General Reference/.
    ListPoliciesGrantingServiceAccessEntry -> Maybe Text
serviceNamespace :: Prelude.Maybe Prelude.Text,
    -- | The @PoliciesGrantingServiceAccess@ object that contains details about
    -- the policy.
    ListPoliciesGrantingServiceAccessEntry
-> Maybe [PolicyGrantingServiceAccess]
policies :: Prelude.Maybe [PolicyGrantingServiceAccess]
  }
  deriving (ListPoliciesGrantingServiceAccessEntry
-> ListPoliciesGrantingServiceAccessEntry -> Bool
(ListPoliciesGrantingServiceAccessEntry
 -> ListPoliciesGrantingServiceAccessEntry -> Bool)
-> (ListPoliciesGrantingServiceAccessEntry
    -> ListPoliciesGrantingServiceAccessEntry -> Bool)
-> Eq ListPoliciesGrantingServiceAccessEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPoliciesGrantingServiceAccessEntry
-> ListPoliciesGrantingServiceAccessEntry -> Bool
$c/= :: ListPoliciesGrantingServiceAccessEntry
-> ListPoliciesGrantingServiceAccessEntry -> Bool
== :: ListPoliciesGrantingServiceAccessEntry
-> ListPoliciesGrantingServiceAccessEntry -> Bool
$c== :: ListPoliciesGrantingServiceAccessEntry
-> ListPoliciesGrantingServiceAccessEntry -> Bool
Prelude.Eq, ReadPrec [ListPoliciesGrantingServiceAccessEntry]
ReadPrec ListPoliciesGrantingServiceAccessEntry
Int -> ReadS ListPoliciesGrantingServiceAccessEntry
ReadS [ListPoliciesGrantingServiceAccessEntry]
(Int -> ReadS ListPoliciesGrantingServiceAccessEntry)
-> ReadS [ListPoliciesGrantingServiceAccessEntry]
-> ReadPrec ListPoliciesGrantingServiceAccessEntry
-> ReadPrec [ListPoliciesGrantingServiceAccessEntry]
-> Read ListPoliciesGrantingServiceAccessEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPoliciesGrantingServiceAccessEntry]
$creadListPrec :: ReadPrec [ListPoliciesGrantingServiceAccessEntry]
readPrec :: ReadPrec ListPoliciesGrantingServiceAccessEntry
$creadPrec :: ReadPrec ListPoliciesGrantingServiceAccessEntry
readList :: ReadS [ListPoliciesGrantingServiceAccessEntry]
$creadList :: ReadS [ListPoliciesGrantingServiceAccessEntry]
readsPrec :: Int -> ReadS ListPoliciesGrantingServiceAccessEntry
$creadsPrec :: Int -> ReadS ListPoliciesGrantingServiceAccessEntry
Prelude.Read, Int -> ListPoliciesGrantingServiceAccessEntry -> ShowS
[ListPoliciesGrantingServiceAccessEntry] -> ShowS
ListPoliciesGrantingServiceAccessEntry -> String
(Int -> ListPoliciesGrantingServiceAccessEntry -> ShowS)
-> (ListPoliciesGrantingServiceAccessEntry -> String)
-> ([ListPoliciesGrantingServiceAccessEntry] -> ShowS)
-> Show ListPoliciesGrantingServiceAccessEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPoliciesGrantingServiceAccessEntry] -> ShowS
$cshowList :: [ListPoliciesGrantingServiceAccessEntry] -> ShowS
show :: ListPoliciesGrantingServiceAccessEntry -> String
$cshow :: ListPoliciesGrantingServiceAccessEntry -> String
showsPrec :: Int -> ListPoliciesGrantingServiceAccessEntry -> ShowS
$cshowsPrec :: Int -> ListPoliciesGrantingServiceAccessEntry -> ShowS
Prelude.Show, (forall x.
 ListPoliciesGrantingServiceAccessEntry
 -> Rep ListPoliciesGrantingServiceAccessEntry x)
-> (forall x.
    Rep ListPoliciesGrantingServiceAccessEntry x
    -> ListPoliciesGrantingServiceAccessEntry)
-> Generic ListPoliciesGrantingServiceAccessEntry
forall x.
Rep ListPoliciesGrantingServiceAccessEntry x
-> ListPoliciesGrantingServiceAccessEntry
forall x.
ListPoliciesGrantingServiceAccessEntry
-> Rep ListPoliciesGrantingServiceAccessEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPoliciesGrantingServiceAccessEntry x
-> ListPoliciesGrantingServiceAccessEntry
$cfrom :: forall x.
ListPoliciesGrantingServiceAccessEntry
-> Rep ListPoliciesGrantingServiceAccessEntry x
Prelude.Generic)

-- |
-- Create a value of 'ListPoliciesGrantingServiceAccessEntry' 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:
--
-- 'serviceNamespace', 'listPoliciesGrantingServiceAccessEntry_serviceNamespace' - The namespace of the service that was accessed.
--
-- To learn the service namespace of a service, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html Actions, resources, and condition keys for Amazon Web Services services>
-- in the /Service Authorization Reference/. Choose the name of the service
-- to view details for that service. In the first paragraph, find the
-- service prefix. For example, @(service prefix: a4b)@. For more
-- information about service namespaces, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces Amazon Web Services service namespaces>
-- in the /Amazon Web Services General Reference/.
--
-- 'policies', 'listPoliciesGrantingServiceAccessEntry_policies' - The @PoliciesGrantingServiceAccess@ object that contains details about
-- the policy.
newListPoliciesGrantingServiceAccessEntry ::
  ListPoliciesGrantingServiceAccessEntry
newListPoliciesGrantingServiceAccessEntry :: ListPoliciesGrantingServiceAccessEntry
newListPoliciesGrantingServiceAccessEntry =
  ListPoliciesGrantingServiceAccessEntry' :: Maybe Text
-> Maybe [PolicyGrantingServiceAccess]
-> ListPoliciesGrantingServiceAccessEntry
ListPoliciesGrantingServiceAccessEntry'
    { $sel:serviceNamespace:ListPoliciesGrantingServiceAccessEntry' :: Maybe Text
serviceNamespace =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policies:ListPoliciesGrantingServiceAccessEntry' :: Maybe [PolicyGrantingServiceAccess]
policies = Maybe [PolicyGrantingServiceAccess]
forall a. Maybe a
Prelude.Nothing
    }

-- | The namespace of the service that was accessed.
--
-- To learn the service namespace of a service, see
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html Actions, resources, and condition keys for Amazon Web Services services>
-- in the /Service Authorization Reference/. Choose the name of the service
-- to view details for that service. In the first paragraph, find the
-- service prefix. For example, @(service prefix: a4b)@. For more
-- information about service namespaces, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#genref-aws-service-namespaces Amazon Web Services service namespaces>
-- in the /Amazon Web Services General Reference/.
listPoliciesGrantingServiceAccessEntry_serviceNamespace :: Lens.Lens' ListPoliciesGrantingServiceAccessEntry (Prelude.Maybe Prelude.Text)
listPoliciesGrantingServiceAccessEntry_serviceNamespace :: (Maybe Text -> f (Maybe Text))
-> ListPoliciesGrantingServiceAccessEntry
-> f ListPoliciesGrantingServiceAccessEntry
listPoliciesGrantingServiceAccessEntry_serviceNamespace = (ListPoliciesGrantingServiceAccessEntry -> Maybe Text)
-> (ListPoliciesGrantingServiceAccessEntry
    -> Maybe Text -> ListPoliciesGrantingServiceAccessEntry)
-> Lens
     ListPoliciesGrantingServiceAccessEntry
     ListPoliciesGrantingServiceAccessEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPoliciesGrantingServiceAccessEntry' {Maybe Text
serviceNamespace :: Maybe Text
$sel:serviceNamespace:ListPoliciesGrantingServiceAccessEntry' :: ListPoliciesGrantingServiceAccessEntry -> Maybe Text
serviceNamespace} -> Maybe Text
serviceNamespace) (\s :: ListPoliciesGrantingServiceAccessEntry
s@ListPoliciesGrantingServiceAccessEntry' {} Maybe Text
a -> ListPoliciesGrantingServiceAccessEntry
s {$sel:serviceNamespace:ListPoliciesGrantingServiceAccessEntry' :: Maybe Text
serviceNamespace = Maybe Text
a} :: ListPoliciesGrantingServiceAccessEntry)

-- | The @PoliciesGrantingServiceAccess@ object that contains details about
-- the policy.
listPoliciesGrantingServiceAccessEntry_policies :: Lens.Lens' ListPoliciesGrantingServiceAccessEntry (Prelude.Maybe [PolicyGrantingServiceAccess])
listPoliciesGrantingServiceAccessEntry_policies :: (Maybe [PolicyGrantingServiceAccess]
 -> f (Maybe [PolicyGrantingServiceAccess]))
-> ListPoliciesGrantingServiceAccessEntry
-> f ListPoliciesGrantingServiceAccessEntry
listPoliciesGrantingServiceAccessEntry_policies = (ListPoliciesGrantingServiceAccessEntry
 -> Maybe [PolicyGrantingServiceAccess])
-> (ListPoliciesGrantingServiceAccessEntry
    -> Maybe [PolicyGrantingServiceAccess]
    -> ListPoliciesGrantingServiceAccessEntry)
-> Lens
     ListPoliciesGrantingServiceAccessEntry
     ListPoliciesGrantingServiceAccessEntry
     (Maybe [PolicyGrantingServiceAccess])
     (Maybe [PolicyGrantingServiceAccess])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPoliciesGrantingServiceAccessEntry' {Maybe [PolicyGrantingServiceAccess]
policies :: Maybe [PolicyGrantingServiceAccess]
$sel:policies:ListPoliciesGrantingServiceAccessEntry' :: ListPoliciesGrantingServiceAccessEntry
-> Maybe [PolicyGrantingServiceAccess]
policies} -> Maybe [PolicyGrantingServiceAccess]
policies) (\s :: ListPoliciesGrantingServiceAccessEntry
s@ListPoliciesGrantingServiceAccessEntry' {} Maybe [PolicyGrantingServiceAccess]
a -> ListPoliciesGrantingServiceAccessEntry
s {$sel:policies:ListPoliciesGrantingServiceAccessEntry' :: Maybe [PolicyGrantingServiceAccess]
policies = Maybe [PolicyGrantingServiceAccess]
a} :: ListPoliciesGrantingServiceAccessEntry) ((Maybe [PolicyGrantingServiceAccess]
  -> f (Maybe [PolicyGrantingServiceAccess]))
 -> ListPoliciesGrantingServiceAccessEntry
 -> f ListPoliciesGrantingServiceAccessEntry)
-> ((Maybe [PolicyGrantingServiceAccess]
     -> f (Maybe [PolicyGrantingServiceAccess]))
    -> Maybe [PolicyGrantingServiceAccess]
    -> f (Maybe [PolicyGrantingServiceAccess]))
-> (Maybe [PolicyGrantingServiceAccess]
    -> f (Maybe [PolicyGrantingServiceAccess]))
-> ListPoliciesGrantingServiceAccessEntry
-> f ListPoliciesGrantingServiceAccessEntry
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PolicyGrantingServiceAccess]
  [PolicyGrantingServiceAccess]
  [PolicyGrantingServiceAccess]
  [PolicyGrantingServiceAccess]
-> Iso
     (Maybe [PolicyGrantingServiceAccess])
     (Maybe [PolicyGrantingServiceAccess])
     (Maybe [PolicyGrantingServiceAccess])
     (Maybe [PolicyGrantingServiceAccess])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [PolicyGrantingServiceAccess]
  [PolicyGrantingServiceAccess]
  [PolicyGrantingServiceAccess]
  [PolicyGrantingServiceAccess]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.FromXML
    ListPoliciesGrantingServiceAccessEntry
  where
  parseXML :: [Node] -> Either String ListPoliciesGrantingServiceAccessEntry
parseXML [Node]
x =
    Maybe Text
-> Maybe [PolicyGrantingServiceAccess]
-> ListPoliciesGrantingServiceAccessEntry
ListPoliciesGrantingServiceAccessEntry'
      (Maybe Text
 -> Maybe [PolicyGrantingServiceAccess]
 -> ListPoliciesGrantingServiceAccessEntry)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [PolicyGrantingServiceAccess]
      -> ListPoliciesGrantingServiceAccessEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ServiceNamespace")
      Either
  String
  (Maybe [PolicyGrantingServiceAccess]
   -> ListPoliciesGrantingServiceAccessEntry)
-> Either String (Maybe [PolicyGrantingServiceAccess])
-> Either String ListPoliciesGrantingServiceAccessEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Policies" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [PolicyGrantingServiceAccess]))
-> Either String (Maybe [PolicyGrantingServiceAccess])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [PolicyGrantingServiceAccess])
-> [Node] -> Either String (Maybe [PolicyGrantingServiceAccess])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [PolicyGrantingServiceAccess]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )

instance
  Prelude.Hashable
    ListPoliciesGrantingServiceAccessEntry

instance
  Prelude.NFData
    ListPoliciesGrantingServiceAccessEntry