{-# 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.UpdatePolicy
(
UpdatePolicy (..),
newUpdatePolicy,
updatePolicy_content,
updatePolicy_name,
updatePolicy_description,
updatePolicy_policyId,
UpdatePolicyResponse (..),
newUpdatePolicyResponse,
updatePolicyResponse_policy,
updatePolicyResponse_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 UpdatePolicy = UpdatePolicy'
{
UpdatePolicy -> Maybe Text
content :: Prelude.Maybe Prelude.Text,
UpdatePolicy -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
UpdatePolicy -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
UpdatePolicy -> Text
policyId :: Prelude.Text
}
deriving (UpdatePolicy -> UpdatePolicy -> Bool
(UpdatePolicy -> UpdatePolicy -> Bool)
-> (UpdatePolicy -> UpdatePolicy -> Bool) -> Eq UpdatePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePolicy -> UpdatePolicy -> Bool
$c/= :: UpdatePolicy -> UpdatePolicy -> Bool
== :: UpdatePolicy -> UpdatePolicy -> Bool
$c== :: UpdatePolicy -> UpdatePolicy -> Bool
Prelude.Eq, ReadPrec [UpdatePolicy]
ReadPrec UpdatePolicy
Int -> ReadS UpdatePolicy
ReadS [UpdatePolicy]
(Int -> ReadS UpdatePolicy)
-> ReadS [UpdatePolicy]
-> ReadPrec UpdatePolicy
-> ReadPrec [UpdatePolicy]
-> Read UpdatePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePolicy]
$creadListPrec :: ReadPrec [UpdatePolicy]
readPrec :: ReadPrec UpdatePolicy
$creadPrec :: ReadPrec UpdatePolicy
readList :: ReadS [UpdatePolicy]
$creadList :: ReadS [UpdatePolicy]
readsPrec :: Int -> ReadS UpdatePolicy
$creadsPrec :: Int -> ReadS UpdatePolicy
Prelude.Read, Int -> UpdatePolicy -> ShowS
[UpdatePolicy] -> ShowS
UpdatePolicy -> String
(Int -> UpdatePolicy -> ShowS)
-> (UpdatePolicy -> String)
-> ([UpdatePolicy] -> ShowS)
-> Show UpdatePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePolicy] -> ShowS
$cshowList :: [UpdatePolicy] -> ShowS
show :: UpdatePolicy -> String
$cshow :: UpdatePolicy -> String
showsPrec :: Int -> UpdatePolicy -> ShowS
$cshowsPrec :: Int -> UpdatePolicy -> ShowS
Prelude.Show, (forall x. UpdatePolicy -> Rep UpdatePolicy x)
-> (forall x. Rep UpdatePolicy x -> UpdatePolicy)
-> Generic UpdatePolicy
forall x. Rep UpdatePolicy x -> UpdatePolicy
forall x. UpdatePolicy -> Rep UpdatePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePolicy x -> UpdatePolicy
$cfrom :: forall x. UpdatePolicy -> Rep UpdatePolicy x
Prelude.Generic)
newUpdatePolicy ::
Prelude.Text ->
UpdatePolicy
newUpdatePolicy :: Text -> UpdatePolicy
newUpdatePolicy Text
pPolicyId_ =
UpdatePolicy' :: Maybe Text -> Maybe Text -> Maybe Text -> Text -> UpdatePolicy
UpdatePolicy'
{ $sel:content:UpdatePolicy' :: Maybe Text
content = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:UpdatePolicy' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:description:UpdatePolicy' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:policyId:UpdatePolicy' :: Text
policyId = Text
pPolicyId_
}
updatePolicy_content :: Lens.Lens' UpdatePolicy (Prelude.Maybe Prelude.Text)
updatePolicy_content :: (Maybe Text -> f (Maybe Text)) -> UpdatePolicy -> f UpdatePolicy
updatePolicy_content = (UpdatePolicy -> Maybe Text)
-> (UpdatePolicy -> Maybe Text -> UpdatePolicy)
-> Lens UpdatePolicy UpdatePolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePolicy' {Maybe Text
content :: Maybe Text
$sel:content:UpdatePolicy' :: UpdatePolicy -> Maybe Text
content} -> Maybe Text
content) (\s :: UpdatePolicy
s@UpdatePolicy' {} Maybe Text
a -> UpdatePolicy
s {$sel:content:UpdatePolicy' :: Maybe Text
content = Maybe Text
a} :: UpdatePolicy)
updatePolicy_name :: Lens.Lens' UpdatePolicy (Prelude.Maybe Prelude.Text)
updatePolicy_name :: (Maybe Text -> f (Maybe Text)) -> UpdatePolicy -> f UpdatePolicy
updatePolicy_name = (UpdatePolicy -> Maybe Text)
-> (UpdatePolicy -> Maybe Text -> UpdatePolicy)
-> Lens UpdatePolicy UpdatePolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePolicy' {Maybe Text
name :: Maybe Text
$sel:name:UpdatePolicy' :: UpdatePolicy -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdatePolicy
s@UpdatePolicy' {} Maybe Text
a -> UpdatePolicy
s {$sel:name:UpdatePolicy' :: Maybe Text
name = Maybe Text
a} :: UpdatePolicy)
updatePolicy_description :: Lens.Lens' UpdatePolicy (Prelude.Maybe Prelude.Text)
updatePolicy_description :: (Maybe Text -> f (Maybe Text)) -> UpdatePolicy -> f UpdatePolicy
updatePolicy_description = (UpdatePolicy -> Maybe Text)
-> (UpdatePolicy -> Maybe Text -> UpdatePolicy)
-> Lens UpdatePolicy UpdatePolicy (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePolicy' {Maybe Text
description :: Maybe Text
$sel:description:UpdatePolicy' :: UpdatePolicy -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdatePolicy
s@UpdatePolicy' {} Maybe Text
a -> UpdatePolicy
s {$sel:description:UpdatePolicy' :: Maybe Text
description = Maybe Text
a} :: UpdatePolicy)
updatePolicy_policyId :: Lens.Lens' UpdatePolicy Prelude.Text
updatePolicy_policyId :: (Text -> f Text) -> UpdatePolicy -> f UpdatePolicy
updatePolicy_policyId = (UpdatePolicy -> Text)
-> (UpdatePolicy -> Text -> UpdatePolicy)
-> Lens UpdatePolicy UpdatePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePolicy' {Text
policyId :: Text
$sel:policyId:UpdatePolicy' :: UpdatePolicy -> Text
policyId} -> Text
policyId) (\s :: UpdatePolicy
s@UpdatePolicy' {} Text
a -> UpdatePolicy
s {$sel:policyId:UpdatePolicy' :: Text
policyId = Text
a} :: UpdatePolicy)
instance Core.AWSRequest UpdatePolicy where
type AWSResponse UpdatePolicy = UpdatePolicyResponse
request :: UpdatePolicy -> Request UpdatePolicy
request = Service -> UpdatePolicy -> Request UpdatePolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy UpdatePolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdatePolicy)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse UpdatePolicy))
-> Logger
-> Service
-> Proxy UpdatePolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdatePolicy)))
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 Policy -> Int -> UpdatePolicyResponse
UpdatePolicyResponse'
(Maybe Policy -> Int -> UpdatePolicyResponse)
-> Either String (Maybe Policy)
-> Either String (Int -> UpdatePolicyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Policy)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Policy")
Either String (Int -> UpdatePolicyResponse)
-> Either String Int -> Either String UpdatePolicyResponse
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 UpdatePolicy
instance Prelude.NFData UpdatePolicy
instance Core.ToHeaders UpdatePolicy where
toHeaders :: UpdatePolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> UpdatePolicy -> 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.UpdatePolicy" ::
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 UpdatePolicy where
toJSON :: UpdatePolicy -> Value
toJSON UpdatePolicy' {Maybe Text
Text
policyId :: Text
description :: Maybe Text
name :: Maybe Text
content :: Maybe Text
$sel:policyId:UpdatePolicy' :: UpdatePolicy -> Text
$sel:description:UpdatePolicy' :: UpdatePolicy -> Maybe Text
$sel:name:UpdatePolicy' :: UpdatePolicy -> Maybe Text
$sel:content:UpdatePolicy' :: UpdatePolicy -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Content" 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
content,
(Text
"Name" 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
name,
(Text
"Description" 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
description,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"PolicyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
policyId)
]
)
instance Core.ToPath UpdatePolicy where
toPath :: UpdatePolicy -> ByteString
toPath = ByteString -> UpdatePolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery UpdatePolicy where
toQuery :: UpdatePolicy -> QueryString
toQuery = QueryString -> UpdatePolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data UpdatePolicyResponse = UpdatePolicyResponse'
{
UpdatePolicyResponse -> Maybe Policy
policy :: Prelude.Maybe Policy,
UpdatePolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (UpdatePolicyResponse -> UpdatePolicyResponse -> Bool
(UpdatePolicyResponse -> UpdatePolicyResponse -> Bool)
-> (UpdatePolicyResponse -> UpdatePolicyResponse -> Bool)
-> Eq UpdatePolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePolicyResponse -> UpdatePolicyResponse -> Bool
$c/= :: UpdatePolicyResponse -> UpdatePolicyResponse -> Bool
== :: UpdatePolicyResponse -> UpdatePolicyResponse -> Bool
$c== :: UpdatePolicyResponse -> UpdatePolicyResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePolicyResponse]
ReadPrec UpdatePolicyResponse
Int -> ReadS UpdatePolicyResponse
ReadS [UpdatePolicyResponse]
(Int -> ReadS UpdatePolicyResponse)
-> ReadS [UpdatePolicyResponse]
-> ReadPrec UpdatePolicyResponse
-> ReadPrec [UpdatePolicyResponse]
-> Read UpdatePolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePolicyResponse]
$creadListPrec :: ReadPrec [UpdatePolicyResponse]
readPrec :: ReadPrec UpdatePolicyResponse
$creadPrec :: ReadPrec UpdatePolicyResponse
readList :: ReadS [UpdatePolicyResponse]
$creadList :: ReadS [UpdatePolicyResponse]
readsPrec :: Int -> ReadS UpdatePolicyResponse
$creadsPrec :: Int -> ReadS UpdatePolicyResponse
Prelude.Read, Int -> UpdatePolicyResponse -> ShowS
[UpdatePolicyResponse] -> ShowS
UpdatePolicyResponse -> String
(Int -> UpdatePolicyResponse -> ShowS)
-> (UpdatePolicyResponse -> String)
-> ([UpdatePolicyResponse] -> ShowS)
-> Show UpdatePolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePolicyResponse] -> ShowS
$cshowList :: [UpdatePolicyResponse] -> ShowS
show :: UpdatePolicyResponse -> String
$cshow :: UpdatePolicyResponse -> String
showsPrec :: Int -> UpdatePolicyResponse -> ShowS
$cshowsPrec :: Int -> UpdatePolicyResponse -> ShowS
Prelude.Show, (forall x. UpdatePolicyResponse -> Rep UpdatePolicyResponse x)
-> (forall x. Rep UpdatePolicyResponse x -> UpdatePolicyResponse)
-> Generic UpdatePolicyResponse
forall x. Rep UpdatePolicyResponse x -> UpdatePolicyResponse
forall x. UpdatePolicyResponse -> Rep UpdatePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePolicyResponse x -> UpdatePolicyResponse
$cfrom :: forall x. UpdatePolicyResponse -> Rep UpdatePolicyResponse x
Prelude.Generic)
newUpdatePolicyResponse ::
Prelude.Int ->
UpdatePolicyResponse
newUpdatePolicyResponse :: Int -> UpdatePolicyResponse
newUpdatePolicyResponse Int
pHttpStatus_ =
UpdatePolicyResponse' :: Maybe Policy -> Int -> UpdatePolicyResponse
UpdatePolicyResponse'
{ $sel:policy:UpdatePolicyResponse' :: Maybe Policy
policy = Maybe Policy
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:UpdatePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
updatePolicyResponse_policy :: Lens.Lens' UpdatePolicyResponse (Prelude.Maybe Policy)
updatePolicyResponse_policy :: (Maybe Policy -> f (Maybe Policy))
-> UpdatePolicyResponse -> f UpdatePolicyResponse
updatePolicyResponse_policy = (UpdatePolicyResponse -> Maybe Policy)
-> (UpdatePolicyResponse -> Maybe Policy -> UpdatePolicyResponse)
-> Lens
UpdatePolicyResponse
UpdatePolicyResponse
(Maybe Policy)
(Maybe Policy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePolicyResponse' {Maybe Policy
policy :: Maybe Policy
$sel:policy:UpdatePolicyResponse' :: UpdatePolicyResponse -> Maybe Policy
policy} -> Maybe Policy
policy) (\s :: UpdatePolicyResponse
s@UpdatePolicyResponse' {} Maybe Policy
a -> UpdatePolicyResponse
s {$sel:policy:UpdatePolicyResponse' :: Maybe Policy
policy = Maybe Policy
a} :: UpdatePolicyResponse)
updatePolicyResponse_httpStatus :: Lens.Lens' UpdatePolicyResponse Prelude.Int
updatePolicyResponse_httpStatus :: (Int -> f Int) -> UpdatePolicyResponse -> f UpdatePolicyResponse
updatePolicyResponse_httpStatus = (UpdatePolicyResponse -> Int)
-> (UpdatePolicyResponse -> Int -> UpdatePolicyResponse)
-> Lens UpdatePolicyResponse UpdatePolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdatePolicyResponse' :: UpdatePolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdatePolicyResponse
s@UpdatePolicyResponse' {} Int
a -> UpdatePolicyResponse
s {$sel:httpStatus:UpdatePolicyResponse' :: Int
httpStatus = Int
a} :: UpdatePolicyResponse)
instance Prelude.NFData UpdatePolicyResponse