{-# 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.WAF.PutPermissionPolicy
(
PutPermissionPolicy (..),
newPutPermissionPolicy,
putPermissionPolicy_resourceArn,
putPermissionPolicy_policy,
PutPermissionPolicyResponse (..),
newPutPermissionPolicyResponse,
putPermissionPolicyResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WAF.Types
data PutPermissionPolicy = PutPermissionPolicy'
{
PutPermissionPolicy -> Text
resourceArn :: Prelude.Text,
PutPermissionPolicy -> Text
policy :: Prelude.Text
}
deriving (PutPermissionPolicy -> PutPermissionPolicy -> Bool
(PutPermissionPolicy -> PutPermissionPolicy -> Bool)
-> (PutPermissionPolicy -> PutPermissionPolicy -> Bool)
-> Eq PutPermissionPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutPermissionPolicy -> PutPermissionPolicy -> Bool
$c/= :: PutPermissionPolicy -> PutPermissionPolicy -> Bool
== :: PutPermissionPolicy -> PutPermissionPolicy -> Bool
$c== :: PutPermissionPolicy -> PutPermissionPolicy -> Bool
Prelude.Eq, ReadPrec [PutPermissionPolicy]
ReadPrec PutPermissionPolicy
Int -> ReadS PutPermissionPolicy
ReadS [PutPermissionPolicy]
(Int -> ReadS PutPermissionPolicy)
-> ReadS [PutPermissionPolicy]
-> ReadPrec PutPermissionPolicy
-> ReadPrec [PutPermissionPolicy]
-> Read PutPermissionPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutPermissionPolicy]
$creadListPrec :: ReadPrec [PutPermissionPolicy]
readPrec :: ReadPrec PutPermissionPolicy
$creadPrec :: ReadPrec PutPermissionPolicy
readList :: ReadS [PutPermissionPolicy]
$creadList :: ReadS [PutPermissionPolicy]
readsPrec :: Int -> ReadS PutPermissionPolicy
$creadsPrec :: Int -> ReadS PutPermissionPolicy
Prelude.Read, Int -> PutPermissionPolicy -> ShowS
[PutPermissionPolicy] -> ShowS
PutPermissionPolicy -> String
(Int -> PutPermissionPolicy -> ShowS)
-> (PutPermissionPolicy -> String)
-> ([PutPermissionPolicy] -> ShowS)
-> Show PutPermissionPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutPermissionPolicy] -> ShowS
$cshowList :: [PutPermissionPolicy] -> ShowS
show :: PutPermissionPolicy -> String
$cshow :: PutPermissionPolicy -> String
showsPrec :: Int -> PutPermissionPolicy -> ShowS
$cshowsPrec :: Int -> PutPermissionPolicy -> ShowS
Prelude.Show, (forall x. PutPermissionPolicy -> Rep PutPermissionPolicy x)
-> (forall x. Rep PutPermissionPolicy x -> PutPermissionPolicy)
-> Generic PutPermissionPolicy
forall x. Rep PutPermissionPolicy x -> PutPermissionPolicy
forall x. PutPermissionPolicy -> Rep PutPermissionPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutPermissionPolicy x -> PutPermissionPolicy
$cfrom :: forall x. PutPermissionPolicy -> Rep PutPermissionPolicy x
Prelude.Generic)
newPutPermissionPolicy ::
Prelude.Text ->
Prelude.Text ->
PutPermissionPolicy
newPutPermissionPolicy :: Text -> Text -> PutPermissionPolicy
newPutPermissionPolicy Text
pResourceArn_ Text
pPolicy_ =
PutPermissionPolicy' :: Text -> Text -> PutPermissionPolicy
PutPermissionPolicy'
{ $sel:resourceArn:PutPermissionPolicy' :: Text
resourceArn = Text
pResourceArn_,
$sel:policy:PutPermissionPolicy' :: Text
policy = Text
pPolicy_
}
putPermissionPolicy_resourceArn :: Lens.Lens' PutPermissionPolicy Prelude.Text
putPermissionPolicy_resourceArn :: (Text -> f Text) -> PutPermissionPolicy -> f PutPermissionPolicy
putPermissionPolicy_resourceArn = (PutPermissionPolicy -> Text)
-> (PutPermissionPolicy -> Text -> PutPermissionPolicy)
-> Lens PutPermissionPolicy PutPermissionPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPermissionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:PutPermissionPolicy' :: PutPermissionPolicy -> Text
resourceArn} -> Text
resourceArn) (\s :: PutPermissionPolicy
s@PutPermissionPolicy' {} Text
a -> PutPermissionPolicy
s {$sel:resourceArn:PutPermissionPolicy' :: Text
resourceArn = Text
a} :: PutPermissionPolicy)
putPermissionPolicy_policy :: Lens.Lens' PutPermissionPolicy Prelude.Text
putPermissionPolicy_policy :: (Text -> f Text) -> PutPermissionPolicy -> f PutPermissionPolicy
putPermissionPolicy_policy = (PutPermissionPolicy -> Text)
-> (PutPermissionPolicy -> Text -> PutPermissionPolicy)
-> Lens PutPermissionPolicy PutPermissionPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPermissionPolicy' {Text
policy :: Text
$sel:policy:PutPermissionPolicy' :: PutPermissionPolicy -> Text
policy} -> Text
policy) (\s :: PutPermissionPolicy
s@PutPermissionPolicy' {} Text
a -> PutPermissionPolicy
s {$sel:policy:PutPermissionPolicy' :: Text
policy = Text
a} :: PutPermissionPolicy)
instance Core.AWSRequest PutPermissionPolicy where
type
AWSResponse PutPermissionPolicy =
PutPermissionPolicyResponse
request :: PutPermissionPolicy -> Request PutPermissionPolicy
request = Service -> PutPermissionPolicy -> Request PutPermissionPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutPermissionPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutPermissionPolicy)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse PutPermissionPolicy))
-> Logger
-> Service
-> Proxy PutPermissionPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutPermissionPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> PutPermissionPolicyResponse
PutPermissionPolicyResponse'
(Int -> PutPermissionPolicyResponse)
-> Either String Int -> Either String PutPermissionPolicyResponse
forall (f :: * -> *) a b. Functor 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 PutPermissionPolicy
instance Prelude.NFData PutPermissionPolicy
instance Core.ToHeaders PutPermissionPolicy where
toHeaders :: PutPermissionPolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutPermissionPolicy -> 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
"AWSWAF_20150824.PutPermissionPolicy" ::
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 PutPermissionPolicy where
toJSON :: PutPermissionPolicy -> Value
toJSON PutPermissionPolicy' {Text
policy :: Text
resourceArn :: Text
$sel:policy:PutPermissionPolicy' :: PutPermissionPolicy -> Text
$sel:resourceArn:PutPermissionPolicy' :: PutPermissionPolicy -> 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
"ResourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Policy" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
policy)
]
)
instance Core.ToPath PutPermissionPolicy where
toPath :: PutPermissionPolicy -> ByteString
toPath = ByteString -> PutPermissionPolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery PutPermissionPolicy where
toQuery :: PutPermissionPolicy -> QueryString
toQuery = QueryString -> PutPermissionPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutPermissionPolicyResponse = PutPermissionPolicyResponse'
{
PutPermissionPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutPermissionPolicyResponse -> PutPermissionPolicyResponse -> Bool
(PutPermissionPolicyResponse
-> PutPermissionPolicyResponse -> Bool)
-> (PutPermissionPolicyResponse
-> PutPermissionPolicyResponse -> Bool)
-> Eq PutPermissionPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutPermissionPolicyResponse -> PutPermissionPolicyResponse -> Bool
$c/= :: PutPermissionPolicyResponse -> PutPermissionPolicyResponse -> Bool
== :: PutPermissionPolicyResponse -> PutPermissionPolicyResponse -> Bool
$c== :: PutPermissionPolicyResponse -> PutPermissionPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutPermissionPolicyResponse]
ReadPrec PutPermissionPolicyResponse
Int -> ReadS PutPermissionPolicyResponse
ReadS [PutPermissionPolicyResponse]
(Int -> ReadS PutPermissionPolicyResponse)
-> ReadS [PutPermissionPolicyResponse]
-> ReadPrec PutPermissionPolicyResponse
-> ReadPrec [PutPermissionPolicyResponse]
-> Read PutPermissionPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutPermissionPolicyResponse]
$creadListPrec :: ReadPrec [PutPermissionPolicyResponse]
readPrec :: ReadPrec PutPermissionPolicyResponse
$creadPrec :: ReadPrec PutPermissionPolicyResponse
readList :: ReadS [PutPermissionPolicyResponse]
$creadList :: ReadS [PutPermissionPolicyResponse]
readsPrec :: Int -> ReadS PutPermissionPolicyResponse
$creadsPrec :: Int -> ReadS PutPermissionPolicyResponse
Prelude.Read, Int -> PutPermissionPolicyResponse -> ShowS
[PutPermissionPolicyResponse] -> ShowS
PutPermissionPolicyResponse -> String
(Int -> PutPermissionPolicyResponse -> ShowS)
-> (PutPermissionPolicyResponse -> String)
-> ([PutPermissionPolicyResponse] -> ShowS)
-> Show PutPermissionPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutPermissionPolicyResponse] -> ShowS
$cshowList :: [PutPermissionPolicyResponse] -> ShowS
show :: PutPermissionPolicyResponse -> String
$cshow :: PutPermissionPolicyResponse -> String
showsPrec :: Int -> PutPermissionPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutPermissionPolicyResponse -> ShowS
Prelude.Show, (forall x.
PutPermissionPolicyResponse -> Rep PutPermissionPolicyResponse x)
-> (forall x.
Rep PutPermissionPolicyResponse x -> PutPermissionPolicyResponse)
-> Generic PutPermissionPolicyResponse
forall x.
Rep PutPermissionPolicyResponse x -> PutPermissionPolicyResponse
forall x.
PutPermissionPolicyResponse -> Rep PutPermissionPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutPermissionPolicyResponse x -> PutPermissionPolicyResponse
$cfrom :: forall x.
PutPermissionPolicyResponse -> Rep PutPermissionPolicyResponse x
Prelude.Generic)
newPutPermissionPolicyResponse ::
Prelude.Int ->
PutPermissionPolicyResponse
newPutPermissionPolicyResponse :: Int -> PutPermissionPolicyResponse
newPutPermissionPolicyResponse Int
pHttpStatus_ =
PutPermissionPolicyResponse' :: Int -> PutPermissionPolicyResponse
PutPermissionPolicyResponse'
{ $sel:httpStatus:PutPermissionPolicyResponse' :: Int
httpStatus =
Int
pHttpStatus_
}
putPermissionPolicyResponse_httpStatus :: Lens.Lens' PutPermissionPolicyResponse Prelude.Int
putPermissionPolicyResponse_httpStatus :: (Int -> f Int)
-> PutPermissionPolicyResponse -> f PutPermissionPolicyResponse
putPermissionPolicyResponse_httpStatus = (PutPermissionPolicyResponse -> Int)
-> (PutPermissionPolicyResponse
-> Int -> PutPermissionPolicyResponse)
-> Lens
PutPermissionPolicyResponse PutPermissionPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutPermissionPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutPermissionPolicyResponse' :: PutPermissionPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutPermissionPolicyResponse
s@PutPermissionPolicyResponse' {} Int
a -> PutPermissionPolicyResponse
s {$sel:httpStatus:PutPermissionPolicyResponse' :: Int
httpStatus = Int
a} :: PutPermissionPolicyResponse)
instance Prelude.NFData PutPermissionPolicyResponse