{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:targetId:DescribeEffectivePolicy' :: Maybe Text
targetId =
forall a. Maybe a
Prelude.Nothing,
$sel:policyType:DescribeEffectivePolicy' :: EffectivePolicyType
policyType = EffectivePolicyType
pPolicyType_
}
describeEffectivePolicy_targetId :: Lens.Lens' DescribeEffectivePolicy (Prelude.Maybe Prelude.Text)
describeEffectivePolicy_targetId :: Lens' DescribeEffectivePolicy (Maybe Text)
describeEffectivePolicy_targetId = 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 :: Lens' DescribeEffectivePolicy EffectivePolicyType
describeEffectivePolicy_policyType = 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 :: (Service -> Service)
-> DescribeEffectivePolicy -> Request DescribeEffectivePolicy
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeEffectivePolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DescribeEffectivePolicy)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe EffectivePolicy -> Int -> DescribeEffectivePolicyResponse
DescribeEffectivePolicyResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"EffectivePolicy")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable DescribeEffectivePolicy where
hashWithSalt :: Int -> DescribeEffectivePolicy -> Int
hashWithSalt Int
_salt DescribeEffectivePolicy' {Maybe Text
EffectivePolicyType
policyType :: EffectivePolicyType
targetId :: Maybe Text
$sel:policyType:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> EffectivePolicyType
$sel:targetId:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetId
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EffectivePolicyType
policyType
instance Prelude.NFData DescribeEffectivePolicy where
rnf :: DescribeEffectivePolicy -> ()
rnf DescribeEffectivePolicy' {Maybe Text
EffectivePolicyType
policyType :: EffectivePolicyType
targetId :: Maybe Text
$sel:policyType:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> EffectivePolicyType
$sel:targetId:DescribeEffectivePolicy' :: DescribeEffectivePolicy -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetId
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf EffectivePolicyType
policyType
instance Data.ToHeaders DescribeEffectivePolicy where
toHeaders :: DescribeEffectivePolicy -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSOrganizationsV20161128.DescribeEffectivePolicy" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"TargetId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetId,
forall a. a -> Maybe a
Prelude.Just (Key
"PolicyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EffectivePolicyType
policyType)
]
)
instance Data.ToPath DescribeEffectivePolicy where
toPath :: DescribeEffectivePolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery DescribeEffectivePolicy where
toQuery :: DescribeEffectivePolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
{ $sel:effectivePolicy:DescribeEffectivePolicyResponse' :: Maybe EffectivePolicy
effectivePolicy =
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeEffectivePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
describeEffectivePolicyResponse_effectivePolicy :: Lens.Lens' DescribeEffectivePolicyResponse (Prelude.Maybe EffectivePolicy)
describeEffectivePolicyResponse_effectivePolicy :: Lens' DescribeEffectivePolicyResponse (Maybe EffectivePolicy)
describeEffectivePolicyResponse_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 :: Lens' DescribeEffectivePolicyResponse Int
describeEffectivePolicyResponse_httpStatus = 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
where
rnf :: DescribeEffectivePolicyResponse -> ()
rnf DescribeEffectivePolicyResponse' {Int
Maybe EffectivePolicy
httpStatus :: Int
effectivePolicy :: Maybe EffectivePolicy
$sel:httpStatus:DescribeEffectivePolicyResponse' :: DescribeEffectivePolicyResponse -> Int
$sel:effectivePolicy:DescribeEffectivePolicyResponse' :: DescribeEffectivePolicyResponse -> Maybe EffectivePolicy
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe EffectivePolicy
effectivePolicy
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus