{-# 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.GetContextKeysForPolicyResponse
-- 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.GetContextKeysForPolicyResponse where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the response to a successful GetContextKeysForPrincipalPolicy
-- or GetContextKeysForCustomPolicy request.
--
-- /See:/ 'newGetContextKeysForPolicyResponse' smart constructor.
data GetContextKeysForPolicyResponse = GetContextKeysForPolicyResponse'
  { -- | The list of context keys that are referenced in the input policies.
    GetContextKeysForPolicyResponse -> Maybe [Text]
contextKeyNames :: Prelude.Maybe [Prelude.Text]
  }
  deriving (GetContextKeysForPolicyResponse
-> GetContextKeysForPolicyResponse -> Bool
(GetContextKeysForPolicyResponse
 -> GetContextKeysForPolicyResponse -> Bool)
-> (GetContextKeysForPolicyResponse
    -> GetContextKeysForPolicyResponse -> Bool)
-> Eq GetContextKeysForPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetContextKeysForPolicyResponse
-> GetContextKeysForPolicyResponse -> Bool
$c/= :: GetContextKeysForPolicyResponse
-> GetContextKeysForPolicyResponse -> Bool
== :: GetContextKeysForPolicyResponse
-> GetContextKeysForPolicyResponse -> Bool
$c== :: GetContextKeysForPolicyResponse
-> GetContextKeysForPolicyResponse -> Bool
Prelude.Eq, ReadPrec [GetContextKeysForPolicyResponse]
ReadPrec GetContextKeysForPolicyResponse
Int -> ReadS GetContextKeysForPolicyResponse
ReadS [GetContextKeysForPolicyResponse]
(Int -> ReadS GetContextKeysForPolicyResponse)
-> ReadS [GetContextKeysForPolicyResponse]
-> ReadPrec GetContextKeysForPolicyResponse
-> ReadPrec [GetContextKeysForPolicyResponse]
-> Read GetContextKeysForPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetContextKeysForPolicyResponse]
$creadListPrec :: ReadPrec [GetContextKeysForPolicyResponse]
readPrec :: ReadPrec GetContextKeysForPolicyResponse
$creadPrec :: ReadPrec GetContextKeysForPolicyResponse
readList :: ReadS [GetContextKeysForPolicyResponse]
$creadList :: ReadS [GetContextKeysForPolicyResponse]
readsPrec :: Int -> ReadS GetContextKeysForPolicyResponse
$creadsPrec :: Int -> ReadS GetContextKeysForPolicyResponse
Prelude.Read, Int -> GetContextKeysForPolicyResponse -> ShowS
[GetContextKeysForPolicyResponse] -> ShowS
GetContextKeysForPolicyResponse -> String
(Int -> GetContextKeysForPolicyResponse -> ShowS)
-> (GetContextKeysForPolicyResponse -> String)
-> ([GetContextKeysForPolicyResponse] -> ShowS)
-> Show GetContextKeysForPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetContextKeysForPolicyResponse] -> ShowS
$cshowList :: [GetContextKeysForPolicyResponse] -> ShowS
show :: GetContextKeysForPolicyResponse -> String
$cshow :: GetContextKeysForPolicyResponse -> String
showsPrec :: Int -> GetContextKeysForPolicyResponse -> ShowS
$cshowsPrec :: Int -> GetContextKeysForPolicyResponse -> ShowS
Prelude.Show, (forall x.
 GetContextKeysForPolicyResponse
 -> Rep GetContextKeysForPolicyResponse x)
-> (forall x.
    Rep GetContextKeysForPolicyResponse x
    -> GetContextKeysForPolicyResponse)
-> Generic GetContextKeysForPolicyResponse
forall x.
Rep GetContextKeysForPolicyResponse x
-> GetContextKeysForPolicyResponse
forall x.
GetContextKeysForPolicyResponse
-> Rep GetContextKeysForPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetContextKeysForPolicyResponse x
-> GetContextKeysForPolicyResponse
$cfrom :: forall x.
GetContextKeysForPolicyResponse
-> Rep GetContextKeysForPolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetContextKeysForPolicyResponse' 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:
--
-- 'contextKeyNames', 'getContextKeysForPolicyResponse_contextKeyNames' - The list of context keys that are referenced in the input policies.
newGetContextKeysForPolicyResponse ::
  GetContextKeysForPolicyResponse
newGetContextKeysForPolicyResponse :: GetContextKeysForPolicyResponse
newGetContextKeysForPolicyResponse =
  GetContextKeysForPolicyResponse' :: Maybe [Text] -> GetContextKeysForPolicyResponse
GetContextKeysForPolicyResponse'
    { $sel:contextKeyNames:GetContextKeysForPolicyResponse' :: Maybe [Text]
contextKeyNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of context keys that are referenced in the input policies.
getContextKeysForPolicyResponse_contextKeyNames :: Lens.Lens' GetContextKeysForPolicyResponse (Prelude.Maybe [Prelude.Text])
getContextKeysForPolicyResponse_contextKeyNames :: (Maybe [Text] -> f (Maybe [Text]))
-> GetContextKeysForPolicyResponse
-> f GetContextKeysForPolicyResponse
getContextKeysForPolicyResponse_contextKeyNames = (GetContextKeysForPolicyResponse -> Maybe [Text])
-> (GetContextKeysForPolicyResponse
    -> Maybe [Text] -> GetContextKeysForPolicyResponse)
-> Lens
     GetContextKeysForPolicyResponse
     GetContextKeysForPolicyResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetContextKeysForPolicyResponse' {Maybe [Text]
contextKeyNames :: Maybe [Text]
$sel:contextKeyNames:GetContextKeysForPolicyResponse' :: GetContextKeysForPolicyResponse -> Maybe [Text]
contextKeyNames} -> Maybe [Text]
contextKeyNames) (\s :: GetContextKeysForPolicyResponse
s@GetContextKeysForPolicyResponse' {} Maybe [Text]
a -> GetContextKeysForPolicyResponse
s {$sel:contextKeyNames:GetContextKeysForPolicyResponse' :: Maybe [Text]
contextKeyNames = Maybe [Text]
a} :: GetContextKeysForPolicyResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> GetContextKeysForPolicyResponse
 -> f GetContextKeysForPolicyResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetContextKeysForPolicyResponse
-> f GetContextKeysForPolicyResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML GetContextKeysForPolicyResponse where
  parseXML :: [Node] -> Either String GetContextKeysForPolicyResponse
parseXML [Node]
x =
    Maybe [Text] -> GetContextKeysForPolicyResponse
GetContextKeysForPolicyResponse'
      (Maybe [Text] -> GetContextKeysForPolicyResponse)
-> Either String (Maybe [Text])
-> Either String GetContextKeysForPolicyResponse
forall (f :: * -> *) a b. Functor 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
"ContextKeyNames" 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 [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )

instance
  Prelude.Hashable
    GetContextKeysForPolicyResponse

instance
  Prelude.NFData
    GetContextKeysForPolicyResponse