{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}

-- |
-- Module      : Network.DO.Spaces.Actions.DeleteBucketCORS
-- Copyright   : (c) 2021 Rory Tyler Hayford
-- License     : BSD-3-Clause
-- Maintainer  : rory.hayford@protonmail.com
-- Stability   : experimental
-- Portability : GHC
--
module Network.DO.Spaces.Actions.DeleteBucketCORS
    ( DeleteBucketCORS(..)
    , DeleteBucketCORSResponse
    ) where

import           Control.Monad.Reader    ( MonadReader(ask) )

import           Data.ByteString         ( ByteString )

import           GHC.Generics            ( Generic )

import           Network.DO.Spaces.Types
                 ( Action(..)
                 , Bucket
                 , Method(DELETE)
                 , MonadSpaces
                 , SpacesRequestBuilder(..)
                 )
import qualified Network.HTTP.Types      as H

-- | Delete all of a 'Bucket'\'s configured 'Network.DO.Spaces.Types.CORSRule's
data DeleteBucketCORS = DeleteBucketCORS { DeleteBucketCORS -> Bucket
bucket :: Bucket }
    deriving ( Int -> DeleteBucketCORS -> ShowS
[DeleteBucketCORS] -> ShowS
DeleteBucketCORS -> String
(Int -> DeleteBucketCORS -> ShowS)
-> (DeleteBucketCORS -> String)
-> ([DeleteBucketCORS] -> ShowS)
-> Show DeleteBucketCORS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucketCORS] -> ShowS
$cshowList :: [DeleteBucketCORS] -> ShowS
show :: DeleteBucketCORS -> String
$cshow :: DeleteBucketCORS -> String
showsPrec :: Int -> DeleteBucketCORS -> ShowS
$cshowsPrec :: Int -> DeleteBucketCORS -> ShowS
Show, DeleteBucketCORS -> DeleteBucketCORS -> Bool
(DeleteBucketCORS -> DeleteBucketCORS -> Bool)
-> (DeleteBucketCORS -> DeleteBucketCORS -> Bool)
-> Eq DeleteBucketCORS
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucketCORS -> DeleteBucketCORS -> Bool
$c/= :: DeleteBucketCORS -> DeleteBucketCORS -> Bool
== :: DeleteBucketCORS -> DeleteBucketCORS -> Bool
$c== :: DeleteBucketCORS -> DeleteBucketCORS -> Bool
Eq, (forall x. DeleteBucketCORS -> Rep DeleteBucketCORS x)
-> (forall x. Rep DeleteBucketCORS x -> DeleteBucketCORS)
-> Generic DeleteBucketCORS
forall x. Rep DeleteBucketCORS x -> DeleteBucketCORS
forall x. DeleteBucketCORS -> Rep DeleteBucketCORS x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBucketCORS x -> DeleteBucketCORS
$cfrom :: forall x. DeleteBucketCORS -> Rep DeleteBucketCORS x
Generic )

type DeleteBucketCORSResponse = ()

instance MonadSpaces m => Action m DeleteBucketCORS where
    type ConsumedResponse DeleteBucketCORS = DeleteBucketCORSResponse

    buildRequest :: DeleteBucketCORS -> m SpacesRequestBuilder
buildRequest DeleteBucketCORS { Bucket
bucket :: Bucket
$sel:bucket:DeleteBucketCORS :: DeleteBucketCORS -> Bucket
.. } = do
        Spaces
spaces <- m Spaces
forall r (m :: * -> *). MonadReader r m => m r
ask
        SpacesRequestBuilder -> m SpacesRequestBuilder
forall (m :: * -> *) a. Monad m => a -> m a
return SpacesRequestBuilder :: Spaces
-> Maybe RequestBody
-> Maybe Method
-> [Header]
-> Maybe Bucket
-> Maybe Object
-> Maybe Query
-> Maybe Query
-> Maybe Region
-> SpacesRequestBuilder
SpacesRequestBuilder
               { $sel:bucket:SpacesRequestBuilder :: Maybe Bucket
bucket         = Bucket -> Maybe Bucket
forall a. a -> Maybe a
Just Bucket
bucket
               , $sel:method:SpacesRequestBuilder :: Maybe Method
method         = Method -> Maybe Method
forall a. a -> Maybe a
Just Method
DELETE
               , $sel:body:SpacesRequestBuilder :: Maybe RequestBody
body           = Maybe RequestBody
forall a. Maybe a
Nothing
               , $sel:object:SpacesRequestBuilder :: Maybe Object
object         = Maybe Object
forall a. Maybe a
Nothing
               , $sel:overrideRegion:SpacesRequestBuilder :: Maybe Region
overrideRegion = Maybe Region
forall a. Maybe a
Nothing
               , $sel:queryString:SpacesRequestBuilder :: Maybe Query
queryString    = Maybe Query
forall a. Maybe a
Nothing
               , $sel:headers:SpacesRequestBuilder :: [Header]
headers        = [Header]
forall a. Monoid a => a
mempty
               , $sel:subresources:SpacesRequestBuilder :: Maybe Query
subresources   = Query -> Maybe Query
forall a. a -> Maybe a
Just
                     (Query -> Maybe Query) -> Query -> Maybe Query
forall a b. (a -> b) -> a -> b
$ Query -> Query
forall a. QueryLike a => a -> Query
H.toQuery [ ( ByteString
"cors" :: ByteString
                                   , Maybe ByteString
forall a. Maybe a
Nothing :: Maybe ByteString
                                   )
                                 ]
               , Spaces
$sel:spaces:SpacesRequestBuilder :: Spaces
spaces :: Spaces
..
               }

    consumeResponse :: RawResponse m -> m (ConsumedResponse DeleteBucketCORS)
consumeResponse RawResponse m
_ = () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()