{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.S3.GetBucketWebsite
(
getBucketWebsite
, GetBucketWebsite
, gbwBucket
, getBucketWebsiteResponse
, GetBucketWebsiteResponse
, gbwrsRedirectAllRequestsTo
, gbwrsErrorDocument
, gbwrsIndexDocument
, gbwrsRoutingRules
, gbwrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.S3.Types
import Network.AWS.S3.Types.Product
newtype GetBucketWebsite = GetBucketWebsite'
{ _gbwBucket :: BucketName
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getBucketWebsite
:: BucketName
-> GetBucketWebsite
getBucketWebsite pBucket_ = GetBucketWebsite' {_gbwBucket = pBucket_}
gbwBucket :: Lens' GetBucketWebsite BucketName
gbwBucket = lens _gbwBucket (\ s a -> s{_gbwBucket = a})
instance AWSRequest GetBucketWebsite where
type Rs GetBucketWebsite = GetBucketWebsiteResponse
request = get s3
response
= receiveXML
(\ s h x ->
GetBucketWebsiteResponse' <$>
(x .@? "RedirectAllRequestsTo") <*>
(x .@? "ErrorDocument")
<*> (x .@? "IndexDocument")
<*>
(x .@? "RoutingRules" .!@ mempty >>=
may (parseXMLList "RoutingRule"))
<*> (pure (fromEnum s)))
instance Hashable GetBucketWebsite where
instance NFData GetBucketWebsite where
instance ToHeaders GetBucketWebsite where
toHeaders = const mempty
instance ToPath GetBucketWebsite where
toPath GetBucketWebsite'{..}
= mconcat ["/", toBS _gbwBucket]
instance ToQuery GetBucketWebsite where
toQuery = const (mconcat ["website"])
data GetBucketWebsiteResponse = GetBucketWebsiteResponse'
{ _gbwrsRedirectAllRequestsTo :: !(Maybe RedirectAllRequestsTo)
, _gbwrsErrorDocument :: !(Maybe ErrorDocument)
, _gbwrsIndexDocument :: !(Maybe IndexDocument)
, _gbwrsRoutingRules :: !(Maybe [RoutingRule])
, _gbwrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getBucketWebsiteResponse
:: Int
-> GetBucketWebsiteResponse
getBucketWebsiteResponse pResponseStatus_ =
GetBucketWebsiteResponse'
{ _gbwrsRedirectAllRequestsTo = Nothing
, _gbwrsErrorDocument = Nothing
, _gbwrsIndexDocument = Nothing
, _gbwrsRoutingRules = Nothing
, _gbwrsResponseStatus = pResponseStatus_
}
gbwrsRedirectAllRequestsTo :: Lens' GetBucketWebsiteResponse (Maybe RedirectAllRequestsTo)
gbwrsRedirectAllRequestsTo = lens _gbwrsRedirectAllRequestsTo (\ s a -> s{_gbwrsRedirectAllRequestsTo = a})
gbwrsErrorDocument :: Lens' GetBucketWebsiteResponse (Maybe ErrorDocument)
gbwrsErrorDocument = lens _gbwrsErrorDocument (\ s a -> s{_gbwrsErrorDocument = a})
gbwrsIndexDocument :: Lens' GetBucketWebsiteResponse (Maybe IndexDocument)
gbwrsIndexDocument = lens _gbwrsIndexDocument (\ s a -> s{_gbwrsIndexDocument = a})
gbwrsRoutingRules :: Lens' GetBucketWebsiteResponse [RoutingRule]
gbwrsRoutingRules = lens _gbwrsRoutingRules (\ s a -> s{_gbwrsRoutingRules = a}) . _Default . _Coerce
gbwrsResponseStatus :: Lens' GetBucketWebsiteResponse Int
gbwrsResponseStatus = lens _gbwrsResponseStatus (\ s a -> s{_gbwrsResponseStatus = a})
instance NFData GetBucketWebsiteResponse where