module Aws.Sqs.Commands.Permission where
import Aws.Core
import Aws.Sqs.Core
import qualified Data.ByteString.Char8 as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import qualified Network.HTTP.Types as HTTP
data AddPermission = AddPermission {
AddPermission -> Text
apLabel :: T.Text,
AddPermission -> [(Text, SqsPermission)]
apPermissions :: [(T.Text,SqsPermission)],
AddPermission -> QueueName
apQueueName :: QueueName
} deriving (Int -> AddPermission -> ShowS
[AddPermission] -> ShowS
AddPermission -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [AddPermission] -> ShowS
$cshowList :: [AddPermission] -> ShowS
show :: AddPermission -> [Char]
$cshow :: AddPermission -> [Char]
showsPrec :: Int -> AddPermission -> ShowS
$cshowsPrec :: Int -> AddPermission -> ShowS
Show)
data AddPermissionResponse = AddPermissionResponse
deriving (Int -> AddPermissionResponse -> ShowS
[AddPermissionResponse] -> ShowS
AddPermissionResponse -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [AddPermissionResponse] -> ShowS
$cshowList :: [AddPermissionResponse] -> ShowS
show :: AddPermissionResponse -> [Char]
$cshow :: AddPermissionResponse -> [Char]
showsPrec :: Int -> AddPermissionResponse -> ShowS
$cshowsPrec :: Int -> AddPermissionResponse -> ShowS
Show)
formatPermissions :: [(T.Text,SqsPermission)] -> [HTTP.QueryItem]
formatPermissions :: [(Text, SqsPermission)] -> [QueryItem]
formatPermissions [(Text, SqsPermission)]
perms =
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith(\ (Text, SqsPermission)
x Integer
y -> [([Char] -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ [Char]
"AwsAccountId." forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Integer
y, forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ [Char] -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack forall a b. (a -> b) -> a -> b
$ forall a b. (a, b) -> a
fst (Text, SqsPermission)
x),
([Char] -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ [Char]
"ActionName." forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show Integer
y, forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ [Char] -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack forall a b. (a -> b) -> a -> b
$ SqsPermission -> Text
printPermission forall a b. (a -> b) -> a -> b
$ forall a b. (a, b) -> b
snd (Text, SqsPermission)
x)]) [(Text, SqsPermission)]
perms [Integer
1 :: Integer ..]
instance ResponseConsumer r AddPermissionResponse where
type ResponseMetadata AddPermissionResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata AddPermissionResponse)
-> HTTPResponseConsumer AddPermissionResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer forall {m :: * -> *} {p}. Monad m => p -> m AddPermissionResponse
parse
where
parse :: p -> m AddPermissionResponse
parse p
_ = do
forall (m :: * -> *) a. Monad m => a -> m a
return AddPermissionResponse {}
instance SignQuery AddPermission where
type ServiceConfiguration AddPermission = SqsConfiguration
signQuery :: forall queryType.
AddPermission
-> ServiceConfiguration AddPermission queryType
-> SignatureData
-> SignedQuery
signQuery AddPermission {[(Text, SqsPermission)]
Text
QueueName
apQueueName :: QueueName
apPermissions :: [(Text, SqsPermission)]
apLabel :: Text
apQueueName :: AddPermission -> QueueName
apPermissions :: AddPermission -> [(Text, SqsPermission)]
apLabel :: AddPermission -> Text
..} = forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery {
sqsQueueName :: Maybe QueueName
sqsQueueName = forall a. a -> Maybe a
Just QueueName
apQueueName,
sqsQuery :: [QueryItem]
sqsQuery = [(ByteString
"Action", forall a. a -> Maybe a
Just ByteString
"AddPermission"),
(ByteString
"QueueName", forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ [Char] -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack forall a b. (a -> b) -> a -> b
$ QueueName -> Text
printQueueName QueueName
apQueueName),
(ByteString
"Label", forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ [Char] -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ Text -> [Char]
T.unpack Text
apLabel)] forall a. [a] -> [a] -> [a]
++ [(Text, SqsPermission)] -> [QueryItem]
formatPermissions [(Text, SqsPermission)]
apPermissions}
instance Transaction AddPermission AddPermissionResponse
instance AsMemoryResponse AddPermissionResponse where
type MemoryResponse AddPermissionResponse = AddPermissionResponse
loadToMemory :: AddPermissionResponse
-> ResourceT IO (MemoryResponse AddPermissionResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
data RemovePermission = RemovePermission {
RemovePermission -> Text
rpLabel :: T.Text,
RemovePermission -> QueueName
rpQueueName :: QueueName
} deriving (Int -> RemovePermission -> ShowS
[RemovePermission] -> ShowS
RemovePermission -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RemovePermission] -> ShowS
$cshowList :: [RemovePermission] -> ShowS
show :: RemovePermission -> [Char]
$cshow :: RemovePermission -> [Char]
showsPrec :: Int -> RemovePermission -> ShowS
$cshowsPrec :: Int -> RemovePermission -> ShowS
Show)
data RemovePermissionResponse = RemovePermissionResponse
deriving (Int -> RemovePermissionResponse -> ShowS
[RemovePermissionResponse] -> ShowS
RemovePermissionResponse -> [Char]
forall a.
(Int -> a -> ShowS) -> (a -> [Char]) -> ([a] -> ShowS) -> Show a
showList :: [RemovePermissionResponse] -> ShowS
$cshowList :: [RemovePermissionResponse] -> ShowS
show :: RemovePermissionResponse -> [Char]
$cshow :: RemovePermissionResponse -> [Char]
showsPrec :: Int -> RemovePermissionResponse -> ShowS
$cshowsPrec :: Int -> RemovePermissionResponse -> ShowS
Show)
instance ResponseConsumer r RemovePermissionResponse where
type ResponseMetadata RemovePermissionResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata RemovePermissionResponse)
-> HTTPResponseConsumer RemovePermissionResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer forall {m :: * -> *} {p}.
Monad m =>
p -> m RemovePermissionResponse
parse
where
parse :: p -> m RemovePermissionResponse
parse p
_ = do
forall (m :: * -> *) a. Monad m => a -> m a
return RemovePermissionResponse {}
instance SignQuery RemovePermission where
type ServiceConfiguration RemovePermission = SqsConfiguration
signQuery :: forall queryType.
RemovePermission
-> ServiceConfiguration RemovePermission queryType
-> SignatureData
-> SignedQuery
signQuery RemovePermission {Text
QueueName
rpQueueName :: QueueName
rpLabel :: Text
rpQueueName :: RemovePermission -> QueueName
rpLabel :: RemovePermission -> Text
..} = forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery {
sqsQueueName :: Maybe QueueName
sqsQueueName = forall a. a -> Maybe a
Just QueueName
rpQueueName,
sqsQuery :: [QueryItem]
sqsQuery = [(ByteString
"Action", forall a. a -> Maybe a
Just ByteString
"RemovePermission"),
(ByteString
"Label", forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Text -> ByteString
TE.encodeUtf8 Text
rpLabel )]}
instance Transaction RemovePermission RemovePermissionResponse
instance AsMemoryResponse RemovePermissionResponse where
type MemoryResponse RemovePermissionResponse = RemovePermissionResponse
loadToMemory :: RemovePermissionResponse
-> ResourceT IO (MemoryResponse RemovePermissionResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return