{-# 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.ServerlessApplicationRepository.PutApplicationPolicy
(
PutApplicationPolicy (..),
newPutApplicationPolicy,
putApplicationPolicy_applicationId,
putApplicationPolicy_statements,
PutApplicationPolicyResponse (..),
newPutApplicationPolicyResponse,
putApplicationPolicyResponse_statements,
putApplicationPolicyResponse_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.ServerlessApplicationRepository.Types
data PutApplicationPolicy = PutApplicationPolicy'
{
PutApplicationPolicy -> Text
applicationId :: Prelude.Text,
PutApplicationPolicy -> [ApplicationPolicyStatement]
statements :: [ApplicationPolicyStatement]
}
deriving (PutApplicationPolicy -> PutApplicationPolicy -> Bool
(PutApplicationPolicy -> PutApplicationPolicy -> Bool)
-> (PutApplicationPolicy -> PutApplicationPolicy -> Bool)
-> Eq PutApplicationPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutApplicationPolicy -> PutApplicationPolicy -> Bool
$c/= :: PutApplicationPolicy -> PutApplicationPolicy -> Bool
== :: PutApplicationPolicy -> PutApplicationPolicy -> Bool
$c== :: PutApplicationPolicy -> PutApplicationPolicy -> Bool
Prelude.Eq, ReadPrec [PutApplicationPolicy]
ReadPrec PutApplicationPolicy
Int -> ReadS PutApplicationPolicy
ReadS [PutApplicationPolicy]
(Int -> ReadS PutApplicationPolicy)
-> ReadS [PutApplicationPolicy]
-> ReadPrec PutApplicationPolicy
-> ReadPrec [PutApplicationPolicy]
-> Read PutApplicationPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutApplicationPolicy]
$creadListPrec :: ReadPrec [PutApplicationPolicy]
readPrec :: ReadPrec PutApplicationPolicy
$creadPrec :: ReadPrec PutApplicationPolicy
readList :: ReadS [PutApplicationPolicy]
$creadList :: ReadS [PutApplicationPolicy]
readsPrec :: Int -> ReadS PutApplicationPolicy
$creadsPrec :: Int -> ReadS PutApplicationPolicy
Prelude.Read, Int -> PutApplicationPolicy -> ShowS
[PutApplicationPolicy] -> ShowS
PutApplicationPolicy -> String
(Int -> PutApplicationPolicy -> ShowS)
-> (PutApplicationPolicy -> String)
-> ([PutApplicationPolicy] -> ShowS)
-> Show PutApplicationPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutApplicationPolicy] -> ShowS
$cshowList :: [PutApplicationPolicy] -> ShowS
show :: PutApplicationPolicy -> String
$cshow :: PutApplicationPolicy -> String
showsPrec :: Int -> PutApplicationPolicy -> ShowS
$cshowsPrec :: Int -> PutApplicationPolicy -> ShowS
Prelude.Show, (forall x. PutApplicationPolicy -> Rep PutApplicationPolicy x)
-> (forall x. Rep PutApplicationPolicy x -> PutApplicationPolicy)
-> Generic PutApplicationPolicy
forall x. Rep PutApplicationPolicy x -> PutApplicationPolicy
forall x. PutApplicationPolicy -> Rep PutApplicationPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PutApplicationPolicy x -> PutApplicationPolicy
$cfrom :: forall x. PutApplicationPolicy -> Rep PutApplicationPolicy x
Prelude.Generic)
newPutApplicationPolicy ::
Prelude.Text ->
PutApplicationPolicy
newPutApplicationPolicy :: Text -> PutApplicationPolicy
newPutApplicationPolicy Text
pApplicationId_ =
PutApplicationPolicy' :: Text -> [ApplicationPolicyStatement] -> PutApplicationPolicy
PutApplicationPolicy'
{ $sel:applicationId:PutApplicationPolicy' :: Text
applicationId =
Text
pApplicationId_,
$sel:statements:PutApplicationPolicy' :: [ApplicationPolicyStatement]
statements = [ApplicationPolicyStatement]
forall a. Monoid a => a
Prelude.mempty
}
putApplicationPolicy_applicationId :: Lens.Lens' PutApplicationPolicy Prelude.Text
putApplicationPolicy_applicationId :: (Text -> f Text) -> PutApplicationPolicy -> f PutApplicationPolicy
putApplicationPolicy_applicationId = (PutApplicationPolicy -> Text)
-> (PutApplicationPolicy -> Text -> PutApplicationPolicy)
-> Lens PutApplicationPolicy PutApplicationPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutApplicationPolicy' {Text
applicationId :: Text
$sel:applicationId:PutApplicationPolicy' :: PutApplicationPolicy -> Text
applicationId} -> Text
applicationId) (\s :: PutApplicationPolicy
s@PutApplicationPolicy' {} Text
a -> PutApplicationPolicy
s {$sel:applicationId:PutApplicationPolicy' :: Text
applicationId = Text
a} :: PutApplicationPolicy)
putApplicationPolicy_statements :: Lens.Lens' PutApplicationPolicy [ApplicationPolicyStatement]
putApplicationPolicy_statements :: ([ApplicationPolicyStatement] -> f [ApplicationPolicyStatement])
-> PutApplicationPolicy -> f PutApplicationPolicy
putApplicationPolicy_statements = (PutApplicationPolicy -> [ApplicationPolicyStatement])
-> (PutApplicationPolicy
-> [ApplicationPolicyStatement] -> PutApplicationPolicy)
-> Lens
PutApplicationPolicy
PutApplicationPolicy
[ApplicationPolicyStatement]
[ApplicationPolicyStatement]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutApplicationPolicy' {[ApplicationPolicyStatement]
statements :: [ApplicationPolicyStatement]
$sel:statements:PutApplicationPolicy' :: PutApplicationPolicy -> [ApplicationPolicyStatement]
statements} -> [ApplicationPolicyStatement]
statements) (\s :: PutApplicationPolicy
s@PutApplicationPolicy' {} [ApplicationPolicyStatement]
a -> PutApplicationPolicy
s {$sel:statements:PutApplicationPolicy' :: [ApplicationPolicyStatement]
statements = [ApplicationPolicyStatement]
a} :: PutApplicationPolicy) (([ApplicationPolicyStatement] -> f [ApplicationPolicyStatement])
-> PutApplicationPolicy -> f PutApplicationPolicy)
-> (([ApplicationPolicyStatement]
-> f [ApplicationPolicyStatement])
-> [ApplicationPolicyStatement] -> f [ApplicationPolicyStatement])
-> ([ApplicationPolicyStatement] -> f [ApplicationPolicyStatement])
-> PutApplicationPolicy
-> f PutApplicationPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ApplicationPolicyStatement] -> f [ApplicationPolicyStatement])
-> [ApplicationPolicyStatement] -> f [ApplicationPolicyStatement]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest PutApplicationPolicy where
type
AWSResponse PutApplicationPolicy =
PutApplicationPolicyResponse
request :: PutApplicationPolicy -> Request PutApplicationPolicy
request = Service -> PutApplicationPolicy -> Request PutApplicationPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
response :: Logger
-> Service
-> Proxy PutApplicationPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutApplicationPolicy)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse PutApplicationPolicy))
-> Logger
-> Service
-> Proxy PutApplicationPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse PutApplicationPolicy)))
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 [ApplicationPolicyStatement]
-> Int -> PutApplicationPolicyResponse
PutApplicationPolicyResponse'
(Maybe [ApplicationPolicyStatement]
-> Int -> PutApplicationPolicyResponse)
-> Either String (Maybe [ApplicationPolicyStatement])
-> Either String (Int -> PutApplicationPolicyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Either String (Maybe (Maybe [ApplicationPolicyStatement]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"statements" Either String (Maybe (Maybe [ApplicationPolicyStatement]))
-> Maybe [ApplicationPolicyStatement]
-> Either String (Maybe [ApplicationPolicyStatement])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ApplicationPolicyStatement]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> PutApplicationPolicyResponse)
-> Either String Int -> Either String PutApplicationPolicyResponse
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 PutApplicationPolicy
instance Prelude.NFData PutApplicationPolicy
instance Core.ToHeaders PutApplicationPolicy where
toHeaders :: PutApplicationPolicy -> ResponseHeaders
toHeaders =
ResponseHeaders -> PutApplicationPolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 PutApplicationPolicy where
toJSON :: PutApplicationPolicy -> Value
toJSON PutApplicationPolicy' {[ApplicationPolicyStatement]
Text
statements :: [ApplicationPolicyStatement]
applicationId :: Text
$sel:statements:PutApplicationPolicy' :: PutApplicationPolicy -> [ApplicationPolicyStatement]
$sel:applicationId:PutApplicationPolicy' :: PutApplicationPolicy -> 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
"statements" Text -> [ApplicationPolicyStatement] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ApplicationPolicyStatement]
statements)]
)
instance Core.ToPath PutApplicationPolicy where
toPath :: PutApplicationPolicy -> ByteString
toPath PutApplicationPolicy' {[ApplicationPolicyStatement]
Text
statements :: [ApplicationPolicyStatement]
applicationId :: Text
$sel:statements:PutApplicationPolicy' :: PutApplicationPolicy -> [ApplicationPolicyStatement]
$sel:applicationId:PutApplicationPolicy' :: PutApplicationPolicy -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/applications/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId,
ByteString
"/policy"
]
instance Core.ToQuery PutApplicationPolicy where
toQuery :: PutApplicationPolicy -> QueryString
toQuery = QueryString -> PutApplicationPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data PutApplicationPolicyResponse = PutApplicationPolicyResponse'
{
PutApplicationPolicyResponse -> Maybe [ApplicationPolicyStatement]
statements :: Prelude.Maybe [ApplicationPolicyStatement],
PutApplicationPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (PutApplicationPolicyResponse
-> PutApplicationPolicyResponse -> Bool
(PutApplicationPolicyResponse
-> PutApplicationPolicyResponse -> Bool)
-> (PutApplicationPolicyResponse
-> PutApplicationPolicyResponse -> Bool)
-> Eq PutApplicationPolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutApplicationPolicyResponse
-> PutApplicationPolicyResponse -> Bool
$c/= :: PutApplicationPolicyResponse
-> PutApplicationPolicyResponse -> Bool
== :: PutApplicationPolicyResponse
-> PutApplicationPolicyResponse -> Bool
$c== :: PutApplicationPolicyResponse
-> PutApplicationPolicyResponse -> Bool
Prelude.Eq, ReadPrec [PutApplicationPolicyResponse]
ReadPrec PutApplicationPolicyResponse
Int -> ReadS PutApplicationPolicyResponse
ReadS [PutApplicationPolicyResponse]
(Int -> ReadS PutApplicationPolicyResponse)
-> ReadS [PutApplicationPolicyResponse]
-> ReadPrec PutApplicationPolicyResponse
-> ReadPrec [PutApplicationPolicyResponse]
-> Read PutApplicationPolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutApplicationPolicyResponse]
$creadListPrec :: ReadPrec [PutApplicationPolicyResponse]
readPrec :: ReadPrec PutApplicationPolicyResponse
$creadPrec :: ReadPrec PutApplicationPolicyResponse
readList :: ReadS [PutApplicationPolicyResponse]
$creadList :: ReadS [PutApplicationPolicyResponse]
readsPrec :: Int -> ReadS PutApplicationPolicyResponse
$creadsPrec :: Int -> ReadS PutApplicationPolicyResponse
Prelude.Read, Int -> PutApplicationPolicyResponse -> ShowS
[PutApplicationPolicyResponse] -> ShowS
PutApplicationPolicyResponse -> String
(Int -> PutApplicationPolicyResponse -> ShowS)
-> (PutApplicationPolicyResponse -> String)
-> ([PutApplicationPolicyResponse] -> ShowS)
-> Show PutApplicationPolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutApplicationPolicyResponse] -> ShowS
$cshowList :: [PutApplicationPolicyResponse] -> ShowS
show :: PutApplicationPolicyResponse -> String
$cshow :: PutApplicationPolicyResponse -> String
showsPrec :: Int -> PutApplicationPolicyResponse -> ShowS
$cshowsPrec :: Int -> PutApplicationPolicyResponse -> ShowS
Prelude.Show, (forall x.
PutApplicationPolicyResponse -> Rep PutApplicationPolicyResponse x)
-> (forall x.
Rep PutApplicationPolicyResponse x -> PutApplicationPolicyResponse)
-> Generic PutApplicationPolicyResponse
forall x.
Rep PutApplicationPolicyResponse x -> PutApplicationPolicyResponse
forall x.
PutApplicationPolicyResponse -> Rep PutApplicationPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutApplicationPolicyResponse x -> PutApplicationPolicyResponse
$cfrom :: forall x.
PutApplicationPolicyResponse -> Rep PutApplicationPolicyResponse x
Prelude.Generic)
newPutApplicationPolicyResponse ::
Prelude.Int ->
PutApplicationPolicyResponse
newPutApplicationPolicyResponse :: Int -> PutApplicationPolicyResponse
newPutApplicationPolicyResponse Int
pHttpStatus_ =
PutApplicationPolicyResponse' :: Maybe [ApplicationPolicyStatement]
-> Int -> PutApplicationPolicyResponse
PutApplicationPolicyResponse'
{ $sel:statements:PutApplicationPolicyResponse' :: Maybe [ApplicationPolicyStatement]
statements =
Maybe [ApplicationPolicyStatement]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:PutApplicationPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
putApplicationPolicyResponse_statements :: Lens.Lens' PutApplicationPolicyResponse (Prelude.Maybe [ApplicationPolicyStatement])
putApplicationPolicyResponse_statements :: (Maybe [ApplicationPolicyStatement]
-> f (Maybe [ApplicationPolicyStatement]))
-> PutApplicationPolicyResponse -> f PutApplicationPolicyResponse
putApplicationPolicyResponse_statements = (PutApplicationPolicyResponse
-> Maybe [ApplicationPolicyStatement])
-> (PutApplicationPolicyResponse
-> Maybe [ApplicationPolicyStatement]
-> PutApplicationPolicyResponse)
-> Lens
PutApplicationPolicyResponse
PutApplicationPolicyResponse
(Maybe [ApplicationPolicyStatement])
(Maybe [ApplicationPolicyStatement])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutApplicationPolicyResponse' {Maybe [ApplicationPolicyStatement]
statements :: Maybe [ApplicationPolicyStatement]
$sel:statements:PutApplicationPolicyResponse' :: PutApplicationPolicyResponse -> Maybe [ApplicationPolicyStatement]
statements} -> Maybe [ApplicationPolicyStatement]
statements) (\s :: PutApplicationPolicyResponse
s@PutApplicationPolicyResponse' {} Maybe [ApplicationPolicyStatement]
a -> PutApplicationPolicyResponse
s {$sel:statements:PutApplicationPolicyResponse' :: Maybe [ApplicationPolicyStatement]
statements = Maybe [ApplicationPolicyStatement]
a} :: PutApplicationPolicyResponse) ((Maybe [ApplicationPolicyStatement]
-> f (Maybe [ApplicationPolicyStatement]))
-> PutApplicationPolicyResponse -> f PutApplicationPolicyResponse)
-> ((Maybe [ApplicationPolicyStatement]
-> f (Maybe [ApplicationPolicyStatement]))
-> Maybe [ApplicationPolicyStatement]
-> f (Maybe [ApplicationPolicyStatement]))
-> (Maybe [ApplicationPolicyStatement]
-> f (Maybe [ApplicationPolicyStatement]))
-> PutApplicationPolicyResponse
-> f PutApplicationPolicyResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[ApplicationPolicyStatement]
[ApplicationPolicyStatement]
[ApplicationPolicyStatement]
[ApplicationPolicyStatement]
-> Iso
(Maybe [ApplicationPolicyStatement])
(Maybe [ApplicationPolicyStatement])
(Maybe [ApplicationPolicyStatement])
(Maybe [ApplicationPolicyStatement])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
[ApplicationPolicyStatement]
[ApplicationPolicyStatement]
[ApplicationPolicyStatement]
[ApplicationPolicyStatement]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
putApplicationPolicyResponse_httpStatus :: Lens.Lens' PutApplicationPolicyResponse Prelude.Int
putApplicationPolicyResponse_httpStatus :: (Int -> f Int)
-> PutApplicationPolicyResponse -> f PutApplicationPolicyResponse
putApplicationPolicyResponse_httpStatus = (PutApplicationPolicyResponse -> Int)
-> (PutApplicationPolicyResponse
-> Int -> PutApplicationPolicyResponse)
-> Lens
PutApplicationPolicyResponse PutApplicationPolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutApplicationPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutApplicationPolicyResponse' :: PutApplicationPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutApplicationPolicyResponse
s@PutApplicationPolicyResponse' {} Int
a -> PutApplicationPolicyResponse
s {$sel:httpStatus:PutApplicationPolicyResponse' :: Int
httpStatus = Int
a} :: PutApplicationPolicyResponse)
instance Prelude.NFData PutApplicationPolicyResponse