{-# 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 #-}
module Amazonka.Organizations.DescribeEffectivePolicy
(
DescribeEffectivePolicy (..),
newDescribeEffectivePolicy,
describeEffectivePolicy_targetId,
describeEffectivePolicy_policyType,
DescribeEffectivePolicyResponse (..),
newDescribeEffectivePolicyResponse,
describeEffectivePolicyResponse_effectivePolicy,
describeEffectivePolicyResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data DescribeEffectivePolicy = DescribeEffectivePolicy'
{
DescribeEffectivePolicy -> Maybe Text
targetId :: Prelude.Maybe Prelude.Text,
DescribeEffectivePolicy -> EffectivePolicyType
policyType :: EffectivePolicyType
}
deriving (DescribeEffectivePolicy -> DescribeEffectivePolicy -> Bool
(DescribeEffectivePolicy -> DescribeEffectivePolicy -> Bool)
-> (DescribeEffectivePolicy -> DescribeEffectivePolicy -> Bool)
-> Eq DescribeEffectivePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEffectivePolicy -> DescribeEffectivePolicy -> Bool
$c/= :: DescribeEffectivePolicy -> DescribeEffectivePolicy -> Bool
== :: DescribeEffectivePolicy -> DescribeEffectivePolicy -> Bool
$c== :: DescribeEffectivePolicy -> DescribeEffectivePolicy -> Bool
Prelude.Eq, ReadPrec [DescribeEffectivePolicy]
ReadPrec DescribeEffectivePolicy
Int -> ReadS DescribeEffectivePolicy
ReadS [DescribeEffectivePolicy]
(Int -> ReadS DescribeEffectivePolicy)
-> ReadS [DescribeEffectivePolicy]
-> ReadPrec DescribeEffectivePolicy
-> ReadPrec [DescribeEffectivePolicy]
-> Read DescribeEffectivePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEffectivePolicy]
$creadListPrec :: ReadPrec [DescribeEffectivePolicy]
readPrec :: ReadPrec DescribeEffectivePolicy
$creadPrec :: ReadPrec DescribeEffectivePolicy
readList :: ReadS [DescribeEffectivePolicy]
$creadList :: ReadS [DescribeEffectivePolicy]
readsPrec :: Int -> ReadS DescribeEffectivePolicy
$creadsPrec :: Int -> ReadS DescribeEffectivePolicy
Prelude.Read, Int -> DescribeEffectivePolicy -> ShowS
[DescribeEffectivePolicy] -> ShowS
DescribeEffectivePolicy -> String
(Int -> DescribeEffectivePolicy -> ShowS)
-> (DescribeEffectivePolicy -> String)
-> ([DescribeEffectivePolicy] -> ShowS)
-> Show DescribeEffectivePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEffectivePolicy] -> ShowS
$cshowList :: [DescribeEffectivePolicy] -> ShowS
show :: DescribeEffectivePolicy -> String
$cshow :: DescribeEffectivePolicy -> String
showsPrec :: Int -> DescribeEffectivePolicy -> ShowS
$cshowsPrec :: Int -> DescribeEffectivePolicy -> ShowS
Prelude.Show, (forall x.
DescribeEffectivePolicy -> Rep DescribeEffectivePolicy x)
-> (forall x.
Rep DescribeEffectivePolicy x -> DescribeEffectivePolicy)
-> Generic DescribeEffectivePolicy
forall x. Rep DescribeEffectivePolicy x -> DescribeEffectivePolicy
forall x. DescribeEffectivePolicy -> Rep DescribeEffectivePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeEffectivePolicy x -> DescribeEffectivePolicy
$cfrom :: forall x. DescribeEffectivePolicy -> Rep DescribeEffectivePolicy x
Prelude.Generic)
newDescribeEffectivePolicy ::
EffectivePolicyType ->
DescribeEffectivePolicy
newDescribeEffectivePolicy :: EffectivePolicyType -> DescribeEffectivePolicy
newDescribeEffectivePolicy EffectivePolicyType
pPolicyType_ =
DescribeEffectivePolicy' :: Maybe Text -> EffectivePolicyType -> DescribeEffectivePolicy
DescribeEffectivePolicy'
{ $sel:targetId:DescribeEffectivePolicy' :: Maybe Text
targetId =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:policyType:DescribeEffectivePolicy' :: EffectivePolicyType
policyType = EffectivePolicyType
pPolicyType_
}
describeEffectivePolicy_targetId :: Lens.Lens' DescribeEffectivePolicy (Prelude.Maybe Prelude.Text)
describeEffectivePolicy_targetId :: (Maybe Text -> f (Maybe Text))
-> DescribeEffectivePolicy -> f DescribeEffectivePolicy
describeEffectivePolicy_targetId = (DescribeEffectivePolicy -> Maybe Text)
-> (DescribeEffectivePolicy
-> Maybe Text -> DescribeEffectivePolicy)
-> Lens
DescribeEffectivePolicy
DescribeEffectivePolicy
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEffectivePolicy' {Maybe Text
targetId :: Maybe Text
$sel:targetId:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> Maybe Text
targetId} -> Maybe Text
targetId) (\s :: DescribeEffectivePolicy
s@DescribeEffectivePolicy' {} Maybe Text
a -> DescribeEffectivePolicy
s {$sel:targetId:DescribeEffectivePolicy' :: Maybe Text
targetId = Maybe Text
a} :: DescribeEffectivePolicy)
describeEffectivePolicy_policyType :: Lens.Lens' DescribeEffectivePolicy EffectivePolicyType
describeEffectivePolicy_policyType :: (EffectivePolicyType -> f EffectivePolicyType)
-> DescribeEffectivePolicy -> f DescribeEffectivePolicy
describeEffectivePolicy_policyType = (DescribeEffectivePolicy -> EffectivePolicyType)
-> (DescribeEffectivePolicy
-> EffectivePolicyType -> DescribeEffectivePolicy)
-> Lens
DescribeEffectivePolicy
DescribeEffectivePolicy
EffectivePolicyType
EffectivePolicyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEffectivePolicy' {EffectivePolicyType
policyType :: EffectivePolicyType
$sel:policyType:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> EffectivePolicyType
policyType} -> EffectivePolicyType
policyType) (\s :: DescribeEffectivePolicy
s@DescribeEffectivePolicy' {} EffectivePolicyType
a -> DescribeEffectivePolicy
s {$sel:policyType:DescribeEffectivePolicy' :: EffectivePolicyType
policyType = EffectivePolicyType
a} :: DescribeEffectivePolicy)
instance Core.AWSRequest DescribeEffectivePolicy where
type
AWSResponse DescribeEffectivePolicy =
DescribeEffectivePolicyResponse
request :: DescribeEffectivePolicy -> Request DescribeEffectivePolicy
request = Service
-> DescribeEffectivePolicy -> Request DescribeEffectivePolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DescribeEffectivePolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DescribeEffectivePolicy)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DescribeEffectivePolicy))
-> Logger
-> Service
-> Proxy DescribeEffectivePolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DescribeEffectivePolicy)))
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 EffectivePolicy -> Int -> DescribeEffectivePolicyResponse
DescribeEffectivePolicyResponse'
(Maybe EffectivePolicy -> Int -> DescribeEffectivePolicyResponse)
-> Either String (Maybe EffectivePolicy)
-> Either String (Int -> DescribeEffectivePolicyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe EffectivePolicy)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"EffectivePolicy")
Either String (Int -> DescribeEffectivePolicyResponse)
-> Either String Int
-> Either String DescribeEffectivePolicyResponse
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 DescribeEffectivePolicy
instance Prelude.NFData DescribeEffectivePolicy
instance Core.ToHeaders DescribeEffectivePolicy where
toHeaders :: DescribeEffectivePolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> DescribeEffectivePolicy -> 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
"AWSOrganizationsV20161128.DescribeEffectivePolicy" ::
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 DescribeEffectivePolicy where
toJSON :: DescribeEffectivePolicy -> Value
toJSON DescribeEffectivePolicy' {Maybe Text
EffectivePolicyType
policyType :: EffectivePolicyType
targetId :: Maybe Text
$sel:policyType:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> EffectivePolicyType
$sel:targetId:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"TargetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetId,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PolicyType" Text -> EffectivePolicyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EffectivePolicyType
policyType)
]
)
instance Core.ToPath DescribeEffectivePolicy where
toPath :: DescribeEffectivePolicy -> ByteString
toPath = ByteString -> DescribeEffectivePolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DescribeEffectivePolicy where
toQuery :: DescribeEffectivePolicy -> QueryString
toQuery = QueryString -> DescribeEffectivePolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DescribeEffectivePolicyResponse = DescribeEffectivePolicyResponse'
{
DescribeEffectivePolicyResponse -> Maybe EffectivePolicy
effectivePolicy :: Prelude.Maybe EffectivePolicy,
DescribeEffectivePolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DescribeEffectivePolicyResponse
-> DescribeEffectivePolicyResponse -> Bool
(DescribeEffectivePolicyResponse
-> DescribeEffectivePolicyResponse -> Bool)
-> (DescribeEffectivePolicyResponse
-> DescribeEffectivePolicyResponse -> Bool)
-> Eq DescribeEffectivePolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeEffectivePolicyResponse
-> DescribeEffectivePolicyResponse -> Bool
$c/= :: DescribeEffectivePolicyResponse
-> DescribeEffectivePolicyResponse -> Bool
== :: DescribeEffectivePolicyResponse
-> DescribeEffectivePolicyResponse -> Bool
$c== :: DescribeEffectivePolicyResponse
-> DescribeEffectivePolicyResponse -> Bool
Prelude.Eq, ReadPrec [DescribeEffectivePolicyResponse]
ReadPrec DescribeEffectivePolicyResponse
Int -> ReadS DescribeEffectivePolicyResponse
ReadS [DescribeEffectivePolicyResponse]
(Int -> ReadS DescribeEffectivePolicyResponse)
-> ReadS [DescribeEffectivePolicyResponse]
-> ReadPrec DescribeEffectivePolicyResponse
-> ReadPrec [DescribeEffectivePolicyResponse]
-> Read DescribeEffectivePolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeEffectivePolicyResponse]
$creadListPrec :: ReadPrec [DescribeEffectivePolicyResponse]
readPrec :: ReadPrec DescribeEffectivePolicyResponse
$creadPrec :: ReadPrec DescribeEffectivePolicyResponse
readList :: ReadS [DescribeEffectivePolicyResponse]
$creadList :: ReadS [DescribeEffectivePolicyResponse]
readsPrec :: Int -> ReadS DescribeEffectivePolicyResponse
$creadsPrec :: Int -> ReadS DescribeEffectivePolicyResponse
Prelude.Read, Int -> DescribeEffectivePolicyResponse -> ShowS
[DescribeEffectivePolicyResponse] -> ShowS
DescribeEffectivePolicyResponse -> String
(Int -> DescribeEffectivePolicyResponse -> ShowS)
-> (DescribeEffectivePolicyResponse -> String)
-> ([DescribeEffectivePolicyResponse] -> ShowS)
-> Show DescribeEffectivePolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeEffectivePolicyResponse] -> ShowS
$cshowList :: [DescribeEffectivePolicyResponse] -> ShowS
show :: DescribeEffectivePolicyResponse -> String
$cshow :: DescribeEffectivePolicyResponse -> String
showsPrec :: Int -> DescribeEffectivePolicyResponse -> ShowS
$cshowsPrec :: Int -> DescribeEffectivePolicyResponse -> ShowS
Prelude.Show, (forall x.
DescribeEffectivePolicyResponse
-> Rep DescribeEffectivePolicyResponse x)
-> (forall x.
Rep DescribeEffectivePolicyResponse x
-> DescribeEffectivePolicyResponse)
-> Generic DescribeEffectivePolicyResponse
forall x.
Rep DescribeEffectivePolicyResponse x
-> DescribeEffectivePolicyResponse
forall x.
DescribeEffectivePolicyResponse
-> Rep DescribeEffectivePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeEffectivePolicyResponse x
-> DescribeEffectivePolicyResponse
$cfrom :: forall x.
DescribeEffectivePolicyResponse
-> Rep DescribeEffectivePolicyResponse x
Prelude.Generic)
newDescribeEffectivePolicyResponse ::
Prelude.Int ->
DescribeEffectivePolicyResponse
newDescribeEffectivePolicyResponse :: Int -> DescribeEffectivePolicyResponse
newDescribeEffectivePolicyResponse Int
pHttpStatus_ =
DescribeEffectivePolicyResponse' :: Maybe EffectivePolicy -> Int -> DescribeEffectivePolicyResponse
DescribeEffectivePolicyResponse'
{ $sel:effectivePolicy:DescribeEffectivePolicyResponse' :: Maybe EffectivePolicy
effectivePolicy =
Maybe EffectivePolicy
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeEffectivePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
describeEffectivePolicyResponse_effectivePolicy :: Lens.Lens' DescribeEffectivePolicyResponse (Prelude.Maybe EffectivePolicy)
describeEffectivePolicyResponse_effectivePolicy :: (Maybe EffectivePolicy -> f (Maybe EffectivePolicy))
-> DescribeEffectivePolicyResponse
-> f DescribeEffectivePolicyResponse
describeEffectivePolicyResponse_effectivePolicy = (DescribeEffectivePolicyResponse -> Maybe EffectivePolicy)
-> (DescribeEffectivePolicyResponse
-> Maybe EffectivePolicy -> DescribeEffectivePolicyResponse)
-> Lens
DescribeEffectivePolicyResponse
DescribeEffectivePolicyResponse
(Maybe EffectivePolicy)
(Maybe EffectivePolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEffectivePolicyResponse' {Maybe EffectivePolicy
effectivePolicy :: Maybe EffectivePolicy
$sel:effectivePolicy:DescribeEffectivePolicyResponse' :: DescribeEffectivePolicyResponse -> Maybe EffectivePolicy
effectivePolicy} -> Maybe EffectivePolicy
effectivePolicy) (\s :: DescribeEffectivePolicyResponse
s@DescribeEffectivePolicyResponse' {} Maybe EffectivePolicy
a -> DescribeEffectivePolicyResponse
s {$sel:effectivePolicy:DescribeEffectivePolicyResponse' :: Maybe EffectivePolicy
effectivePolicy = Maybe EffectivePolicy
a} :: DescribeEffectivePolicyResponse)
describeEffectivePolicyResponse_httpStatus :: Lens.Lens' DescribeEffectivePolicyResponse Prelude.Int
describeEffectivePolicyResponse_httpStatus :: (Int -> f Int)
-> DescribeEffectivePolicyResponse
-> f DescribeEffectivePolicyResponse
describeEffectivePolicyResponse_httpStatus = (DescribeEffectivePolicyResponse -> Int)
-> (DescribeEffectivePolicyResponse
-> Int -> DescribeEffectivePolicyResponse)
-> Lens
DescribeEffectivePolicyResponse
DescribeEffectivePolicyResponse
Int
Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeEffectivePolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeEffectivePolicyResponse' :: DescribeEffectivePolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeEffectivePolicyResponse
s@DescribeEffectivePolicyResponse' {} Int
a -> DescribeEffectivePolicyResponse
s {$sel:httpStatus:DescribeEffectivePolicyResponse' :: Int
httpStatus = Int
a} :: DescribeEffectivePolicyResponse)
instance
Prelude.NFData
DescribeEffectivePolicyResponse