module Aws.S3.Commands.PutBucketVersioning where
import Aws.Core
import Aws.S3.Core
import Network.HTTP.Types (toQuery)
import qualified Data.Map as M
import qualified Data.Text.Encoding as T
import qualified Network.HTTP.Conduit as HTTP
import qualified Text.XML as XML
import qualified Data.ByteString.Lazy.Char8 as B8
data VersioningState = VersioningSuspended | VersioningEnabled
deriving (Int -> VersioningState -> ShowS
[VersioningState] -> ShowS
VersioningState -> String
(Int -> VersioningState -> ShowS)
-> (VersioningState -> String)
-> ([VersioningState] -> ShowS)
-> Show VersioningState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VersioningState] -> ShowS
$cshowList :: [VersioningState] -> ShowS
show :: VersioningState -> String
$cshow :: VersioningState -> String
showsPrec :: Int -> VersioningState -> ShowS
$cshowsPrec :: Int -> VersioningState -> ShowS
Show)
data PutBucketVersioning
= PutBucketVersioning
{ PutBucketVersioning -> Bucket
pbvBucket :: Bucket
, PutBucketVersioning -> VersioningState
pbvVersioningConfiguration :: VersioningState
}
deriving (Int -> PutBucketVersioning -> ShowS
[PutBucketVersioning] -> ShowS
PutBucketVersioning -> String
(Int -> PutBucketVersioning -> ShowS)
-> (PutBucketVersioning -> String)
-> ([PutBucketVersioning] -> ShowS)
-> Show PutBucketVersioning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutBucketVersioning] -> ShowS
$cshowList :: [PutBucketVersioning] -> ShowS
show :: PutBucketVersioning -> String
$cshow :: PutBucketVersioning -> String
showsPrec :: Int -> PutBucketVersioning -> ShowS
$cshowsPrec :: Int -> PutBucketVersioning -> ShowS
Show)
putBucketVersioning :: Bucket -> VersioningState -> PutBucketVersioning
putBucketVersioning :: Bucket -> VersioningState -> PutBucketVersioning
putBucketVersioning = Bucket -> VersioningState -> PutBucketVersioning
PutBucketVersioning
data PutBucketVersioningResponse
= PutBucketVersioningResponse
deriving (Int -> PutBucketVersioningResponse -> ShowS
[PutBucketVersioningResponse] -> ShowS
PutBucketVersioningResponse -> String
(Int -> PutBucketVersioningResponse -> ShowS)
-> (PutBucketVersioningResponse -> String)
-> ([PutBucketVersioningResponse] -> ShowS)
-> Show PutBucketVersioningResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutBucketVersioningResponse] -> ShowS
$cshowList :: [PutBucketVersioningResponse] -> ShowS
show :: PutBucketVersioningResponse -> String
$cshow :: PutBucketVersioningResponse -> String
showsPrec :: Int -> PutBucketVersioningResponse -> ShowS
$cshowsPrec :: Int -> PutBucketVersioningResponse -> ShowS
Show)
instance SignQuery PutBucketVersioning where
type ServiceConfiguration PutBucketVersioning = S3Configuration
signQuery :: PutBucketVersioning
-> ServiceConfiguration PutBucketVersioning queryType
-> SignatureData
-> SignedQuery
signQuery PutBucketVersioning{Bucket
VersioningState
pbvVersioningConfiguration :: VersioningState
pbvBucket :: Bucket
pbvVersioningConfiguration :: PutBucketVersioning -> VersioningState
pbvBucket :: PutBucketVersioning -> Bucket
..} = S3Query
-> S3Configuration queryType -> SignatureData -> SignedQuery
forall qt.
S3Query -> S3Configuration qt -> SignatureData -> SignedQuery
s3SignQuery (S3Query
-> S3Configuration queryType -> SignatureData -> SignedQuery)
-> S3Query
-> S3Configuration queryType
-> SignatureData
-> SignedQuery
forall a b. (a -> b) -> a -> b
$ S3Query :: Method
-> Maybe ByteString
-> Maybe ByteString
-> Query
-> Query
-> Maybe ByteString
-> Maybe (Digest MD5)
-> RequestHeaders
-> RequestHeaders
-> Maybe RequestBody
-> S3Query
S3Query
{ s3QMethod :: Method
s3QMethod = Method
Put
, s3QBucket :: Maybe ByteString
s3QBucket = ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (ByteString -> Maybe ByteString) -> ByteString -> Maybe ByteString
forall a b. (a -> b) -> a -> b
$ Bucket -> ByteString
T.encodeUtf8 Bucket
pbvBucket
, s3QSubresources :: Query
s3QSubresources = [(ByteString, Maybe ByteString)] -> Query
forall a. QueryLike a => a -> Query
toQuery [(ByteString
"versioning" :: B8.ByteString, Maybe ByteString
forall a. Maybe a
Nothing :: Maybe B8.ByteString)]
, s3QQuery :: Query
s3QQuery = []
, s3QContentType :: Maybe ByteString
s3QContentType = Maybe ByteString
forall a. Maybe a
Nothing
, s3QContentMd5 :: Maybe (Digest MD5)
s3QContentMd5 = Maybe (Digest MD5)
forall a. Maybe a
Nothing
, s3QObject :: Maybe ByteString
s3QObject = Maybe ByteString
forall a. Maybe a
Nothing
, s3QAmzHeaders :: RequestHeaders
s3QAmzHeaders = []
, s3QOtherHeaders :: RequestHeaders
s3QOtherHeaders = []
, s3QRequestBody :: Maybe RequestBody
s3QRequestBody = (RequestBody -> Maybe RequestBody
forall a. a -> Maybe a
Just (RequestBody -> Maybe RequestBody)
-> (Document -> RequestBody) -> Document -> Maybe RequestBody
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> RequestBody
HTTP.RequestBodyLBS (ByteString -> RequestBody)
-> (Document -> ByteString) -> Document -> RequestBody
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RenderSettings -> Document -> ByteString
XML.renderLBS RenderSettings
forall a. Default a => a
XML.def)
Document :: Prologue -> Element -> [Miscellaneous] -> Document
XML.Document
{ documentPrologue :: Prologue
XML.documentPrologue = [Miscellaneous] -> Maybe Doctype -> [Miscellaneous] -> Prologue
XML.Prologue [] Maybe Doctype
forall a. Maybe a
Nothing []
, documentRoot :: Element
XML.documentRoot = Element :: Name -> Map Name Bucket -> [Node] -> Element
XML.Element
{ elementName :: Name
XML.elementName = Name
"{http://s3.amazonaws.com/doc/2006-03-01/}VersioningConfiguration"
, elementAttributes :: Map Name Bucket
XML.elementAttributes = Map Name Bucket
forall k a. Map k a
M.empty
, elementNodes :: [Node]
XML.elementNodes = [ Element -> Node
XML.NodeElement (Element :: Name -> Map Name Bucket -> [Node] -> Element
XML.Element
{ elementName :: Name
XML.elementName = Name
"{http://s3.amazonaws.com/doc/2006-03-01/}Status"
, elementAttributes :: Map Name Bucket
XML.elementAttributes = Map Name Bucket
forall k a. Map k a
M.empty
, elementNodes :: [Node]
XML.elementNodes = case VersioningState
pbvVersioningConfiguration of
VersioningState
VersioningSuspended -> [Bucket -> Node
XML.NodeContent Bucket
"Suspended"]
VersioningState
VersioningEnabled -> [Bucket -> Node
XML.NodeContent Bucket
"Enabled"]
})]
}
, documentEpilogue :: [Miscellaneous]
XML.documentEpilogue = []
}
}
instance ResponseConsumer r PutBucketVersioningResponse where
type ResponseMetadata PutBucketVersioningResponse = S3Metadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata PutBucketVersioningResponse)
-> HTTPResponseConsumer PutBucketVersioningResponse
responseConsumer Request
_ r
_ = HTTPResponseConsumer PutBucketVersioningResponse
-> IORef S3Metadata
-> HTTPResponseConsumer PutBucketVersioningResponse
forall a.
HTTPResponseConsumer a
-> IORef S3Metadata -> HTTPResponseConsumer a
s3ResponseConsumer (HTTPResponseConsumer PutBucketVersioningResponse
-> IORef S3Metadata
-> HTTPResponseConsumer PutBucketVersioningResponse)
-> HTTPResponseConsumer PutBucketVersioningResponse
-> IORef S3Metadata
-> HTTPResponseConsumer PutBucketVersioningResponse
forall a b. (a -> b) -> a -> b
$ \Response (ConduitM () ByteString (ResourceT IO) ())
_ -> PutBucketVersioningResponse
-> ResourceT IO PutBucketVersioningResponse
forall (m :: * -> *) a. Monad m => a -> m a
return PutBucketVersioningResponse
PutBucketVersioningResponse
instance Transaction PutBucketVersioning PutBucketVersioningResponse
instance AsMemoryResponse PutBucketVersioningResponse where
type MemoryResponse PutBucketVersioningResponse = PutBucketVersioningResponse
loadToMemory :: PutBucketVersioningResponse
-> ResourceT IO (MemoryResponse PutBucketVersioningResponse)
loadToMemory = PutBucketVersioningResponse
-> ResourceT IO (MemoryResponse PutBucketVersioningResponse)
forall (m :: * -> *) a. Monad m => a -> m a
return