{-# 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.EnablePolicyType
(
EnablePolicyType (..),
newEnablePolicyType,
enablePolicyType_rootId,
enablePolicyType_policyType,
EnablePolicyTypeResponse (..),
newEnablePolicyTypeResponse,
enablePolicyTypeResponse_root,
enablePolicyTypeResponse_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 EnablePolicyType = EnablePolicyType'
{
EnablePolicyType -> Text
rootId :: Prelude.Text,
EnablePolicyType -> PolicyType
policyType :: PolicyType
}
deriving (EnablePolicyType -> EnablePolicyType -> Bool
(EnablePolicyType -> EnablePolicyType -> Bool)
-> (EnablePolicyType -> EnablePolicyType -> Bool)
-> Eq EnablePolicyType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnablePolicyType -> EnablePolicyType -> Bool
$c/= :: EnablePolicyType -> EnablePolicyType -> Bool
== :: EnablePolicyType -> EnablePolicyType -> Bool
$c== :: EnablePolicyType -> EnablePolicyType -> Bool
Prelude.Eq, ReadPrec [EnablePolicyType]
ReadPrec EnablePolicyType
Int -> ReadS EnablePolicyType
ReadS [EnablePolicyType]
(Int -> ReadS EnablePolicyType)
-> ReadS [EnablePolicyType]
-> ReadPrec EnablePolicyType
-> ReadPrec [EnablePolicyType]
-> Read EnablePolicyType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnablePolicyType]
$creadListPrec :: ReadPrec [EnablePolicyType]
readPrec :: ReadPrec EnablePolicyType
$creadPrec :: ReadPrec EnablePolicyType
readList :: ReadS [EnablePolicyType]
$creadList :: ReadS [EnablePolicyType]
readsPrec :: Int -> ReadS EnablePolicyType
$creadsPrec :: Int -> ReadS EnablePolicyType
Prelude.Read, Int -> EnablePolicyType -> ShowS
[EnablePolicyType] -> ShowS
EnablePolicyType -> String
(Int -> EnablePolicyType -> ShowS)
-> (EnablePolicyType -> String)
-> ([EnablePolicyType] -> ShowS)
-> Show EnablePolicyType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnablePolicyType] -> ShowS
$cshowList :: [EnablePolicyType] -> ShowS
show :: EnablePolicyType -> String
$cshow :: EnablePolicyType -> String
showsPrec :: Int -> EnablePolicyType -> ShowS
$cshowsPrec :: Int -> EnablePolicyType -> ShowS
Prelude.Show, (forall x. EnablePolicyType -> Rep EnablePolicyType x)
-> (forall x. Rep EnablePolicyType x -> EnablePolicyType)
-> Generic EnablePolicyType
forall x. Rep EnablePolicyType x -> EnablePolicyType
forall x. EnablePolicyType -> Rep EnablePolicyType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EnablePolicyType x -> EnablePolicyType
$cfrom :: forall x. EnablePolicyType -> Rep EnablePolicyType x
Prelude.Generic)
newEnablePolicyType ::
Prelude.Text ->
PolicyType ->
EnablePolicyType
newEnablePolicyType :: Text -> PolicyType -> EnablePolicyType
newEnablePolicyType Text
pRootId_ PolicyType
pPolicyType_ =
EnablePolicyType' :: Text -> PolicyType -> EnablePolicyType
EnablePolicyType'
{ $sel:rootId:EnablePolicyType' :: Text
rootId = Text
pRootId_,
$sel:policyType:EnablePolicyType' :: PolicyType
policyType = PolicyType
pPolicyType_
}
enablePolicyType_rootId :: Lens.Lens' EnablePolicyType Prelude.Text
enablePolicyType_rootId :: (Text -> f Text) -> EnablePolicyType -> f EnablePolicyType
enablePolicyType_rootId = (EnablePolicyType -> Text)
-> (EnablePolicyType -> Text -> EnablePolicyType)
-> Lens EnablePolicyType EnablePolicyType Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnablePolicyType' {Text
rootId :: Text
$sel:rootId:EnablePolicyType' :: EnablePolicyType -> Text
rootId} -> Text
rootId) (\s :: EnablePolicyType
s@EnablePolicyType' {} Text
a -> EnablePolicyType
s {$sel:rootId:EnablePolicyType' :: Text
rootId = Text
a} :: EnablePolicyType)
enablePolicyType_policyType :: Lens.Lens' EnablePolicyType PolicyType
enablePolicyType_policyType :: (PolicyType -> f PolicyType)
-> EnablePolicyType -> f EnablePolicyType
enablePolicyType_policyType = (EnablePolicyType -> PolicyType)
-> (EnablePolicyType -> PolicyType -> EnablePolicyType)
-> Lens EnablePolicyType EnablePolicyType PolicyType PolicyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnablePolicyType' {PolicyType
policyType :: PolicyType
$sel:policyType:EnablePolicyType' :: EnablePolicyType -> PolicyType
policyType} -> PolicyType
policyType) (\s :: EnablePolicyType
s@EnablePolicyType' {} PolicyType
a -> EnablePolicyType
s {$sel:policyType:EnablePolicyType' :: PolicyType
policyType = PolicyType
a} :: EnablePolicyType)
instance Core.AWSRequest EnablePolicyType where
type
AWSResponse EnablePolicyType =
EnablePolicyTypeResponse
request :: EnablePolicyType -> Request EnablePolicyType
request = Service -> EnablePolicyType -> Request EnablePolicyType
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy EnablePolicyType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnablePolicyType)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse EnablePolicyType))
-> Logger
-> Service
-> Proxy EnablePolicyType
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse EnablePolicyType)))
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 Root -> Int -> EnablePolicyTypeResponse
EnablePolicyTypeResponse'
(Maybe Root -> Int -> EnablePolicyTypeResponse)
-> Either String (Maybe Root)
-> Either String (Int -> EnablePolicyTypeResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Root)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Root")
Either String (Int -> EnablePolicyTypeResponse)
-> Either String Int -> Either String EnablePolicyTypeResponse
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 EnablePolicyType
instance Prelude.NFData EnablePolicyType
instance Core.ToHeaders EnablePolicyType where
toHeaders :: EnablePolicyType -> ResponseHeaders
toHeaders =
ResponseHeaders -> EnablePolicyType -> 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.EnablePolicyType" ::
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 EnablePolicyType where
toJSON :: EnablePolicyType -> Value
toJSON EnablePolicyType' {Text
PolicyType
policyType :: PolicyType
rootId :: Text
$sel:policyType:EnablePolicyType' :: EnablePolicyType -> PolicyType
$sel:rootId:EnablePolicyType' :: EnablePolicyType -> 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
"RootId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
rootId),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PolicyType" Text -> PolicyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= PolicyType
policyType)
]
)
instance Core.ToPath EnablePolicyType where
toPath :: EnablePolicyType -> ByteString
toPath = ByteString -> EnablePolicyType -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery EnablePolicyType where
toQuery :: EnablePolicyType -> QueryString
toQuery = QueryString -> EnablePolicyType -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data EnablePolicyTypeResponse = EnablePolicyTypeResponse'
{
EnablePolicyTypeResponse -> Maybe Root
root :: Prelude.Maybe Root,
EnablePolicyTypeResponse -> Int
httpStatus :: Prelude.Int
}
deriving (EnablePolicyTypeResponse -> EnablePolicyTypeResponse -> Bool
(EnablePolicyTypeResponse -> EnablePolicyTypeResponse -> Bool)
-> (EnablePolicyTypeResponse -> EnablePolicyTypeResponse -> Bool)
-> Eq EnablePolicyTypeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnablePolicyTypeResponse -> EnablePolicyTypeResponse -> Bool
$c/= :: EnablePolicyTypeResponse -> EnablePolicyTypeResponse -> Bool
== :: EnablePolicyTypeResponse -> EnablePolicyTypeResponse -> Bool
$c== :: EnablePolicyTypeResponse -> EnablePolicyTypeResponse -> Bool
Prelude.Eq, ReadPrec [EnablePolicyTypeResponse]
ReadPrec EnablePolicyTypeResponse
Int -> ReadS EnablePolicyTypeResponse
ReadS [EnablePolicyTypeResponse]
(Int -> ReadS EnablePolicyTypeResponse)
-> ReadS [EnablePolicyTypeResponse]
-> ReadPrec EnablePolicyTypeResponse
-> ReadPrec [EnablePolicyTypeResponse]
-> Read EnablePolicyTypeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EnablePolicyTypeResponse]
$creadListPrec :: ReadPrec [EnablePolicyTypeResponse]
readPrec :: ReadPrec EnablePolicyTypeResponse
$creadPrec :: ReadPrec EnablePolicyTypeResponse
readList :: ReadS [EnablePolicyTypeResponse]
$creadList :: ReadS [EnablePolicyTypeResponse]
readsPrec :: Int -> ReadS EnablePolicyTypeResponse
$creadsPrec :: Int -> ReadS EnablePolicyTypeResponse
Prelude.Read, Int -> EnablePolicyTypeResponse -> ShowS
[EnablePolicyTypeResponse] -> ShowS
EnablePolicyTypeResponse -> String
(Int -> EnablePolicyTypeResponse -> ShowS)
-> (EnablePolicyTypeResponse -> String)
-> ([EnablePolicyTypeResponse] -> ShowS)
-> Show EnablePolicyTypeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnablePolicyTypeResponse] -> ShowS
$cshowList :: [EnablePolicyTypeResponse] -> ShowS
show :: EnablePolicyTypeResponse -> String
$cshow :: EnablePolicyTypeResponse -> String
showsPrec :: Int -> EnablePolicyTypeResponse -> ShowS
$cshowsPrec :: Int -> EnablePolicyTypeResponse -> ShowS
Prelude.Show, (forall x.
EnablePolicyTypeResponse -> Rep EnablePolicyTypeResponse x)
-> (forall x.
Rep EnablePolicyTypeResponse x -> EnablePolicyTypeResponse)
-> Generic EnablePolicyTypeResponse
forall x.
Rep EnablePolicyTypeResponse x -> EnablePolicyTypeResponse
forall x.
EnablePolicyTypeResponse -> Rep EnablePolicyTypeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EnablePolicyTypeResponse x -> EnablePolicyTypeResponse
$cfrom :: forall x.
EnablePolicyTypeResponse -> Rep EnablePolicyTypeResponse x
Prelude.Generic)
newEnablePolicyTypeResponse ::
Prelude.Int ->
EnablePolicyTypeResponse
newEnablePolicyTypeResponse :: Int -> EnablePolicyTypeResponse
newEnablePolicyTypeResponse Int
pHttpStatus_ =
EnablePolicyTypeResponse' :: Maybe Root -> Int -> EnablePolicyTypeResponse
EnablePolicyTypeResponse'
{ $sel:root:EnablePolicyTypeResponse' :: Maybe Root
root = Maybe Root
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:EnablePolicyTypeResponse' :: Int
httpStatus = Int
pHttpStatus_
}
enablePolicyTypeResponse_root :: Lens.Lens' EnablePolicyTypeResponse (Prelude.Maybe Root)
enablePolicyTypeResponse_root :: (Maybe Root -> f (Maybe Root))
-> EnablePolicyTypeResponse -> f EnablePolicyTypeResponse
enablePolicyTypeResponse_root = (EnablePolicyTypeResponse -> Maybe Root)
-> (EnablePolicyTypeResponse
-> Maybe Root -> EnablePolicyTypeResponse)
-> Lens
EnablePolicyTypeResponse
EnablePolicyTypeResponse
(Maybe Root)
(Maybe Root)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnablePolicyTypeResponse' {Maybe Root
root :: Maybe Root
$sel:root:EnablePolicyTypeResponse' :: EnablePolicyTypeResponse -> Maybe Root
root} -> Maybe Root
root) (\s :: EnablePolicyTypeResponse
s@EnablePolicyTypeResponse' {} Maybe Root
a -> EnablePolicyTypeResponse
s {$sel:root:EnablePolicyTypeResponse' :: Maybe Root
root = Maybe Root
a} :: EnablePolicyTypeResponse)
enablePolicyTypeResponse_httpStatus :: Lens.Lens' EnablePolicyTypeResponse Prelude.Int
enablePolicyTypeResponse_httpStatus :: (Int -> f Int)
-> EnablePolicyTypeResponse -> f EnablePolicyTypeResponse
enablePolicyTypeResponse_httpStatus = (EnablePolicyTypeResponse -> Int)
-> (EnablePolicyTypeResponse -> Int -> EnablePolicyTypeResponse)
-> Lens EnablePolicyTypeResponse EnablePolicyTypeResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EnablePolicyTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:EnablePolicyTypeResponse' :: EnablePolicyTypeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: EnablePolicyTypeResponse
s@EnablePolicyTypeResponse' {} Int
a -> EnablePolicyTypeResponse
s {$sel:httpStatus:EnablePolicyTypeResponse' :: Int
httpStatus = Int
a} :: EnablePolicyTypeResponse)
instance Prelude.NFData EnablePolicyTypeResponse