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

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

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

import           GHC.Generics            ( Generic )

import           Network.DO.Spaces.Types
                 ( Action(..)
                 , Bucket
                 , Method(DELETE)
                 , MonadSpaces
                 , SpacesRequestBuilder(..)
                 )

-- | Delete a single 'Bucket'. Note that it must be empty
data DeleteBucket = DeleteBucket
    { DeleteBucket -> Bucket
bucket :: Bucket -- ^ The name of the 'Bucket' to delete
    }
    deriving ( Int -> DeleteBucket -> ShowS
[DeleteBucket] -> ShowS
DeleteBucket -> String
(Int -> DeleteBucket -> ShowS)
-> (DeleteBucket -> String)
-> ([DeleteBucket] -> ShowS)
-> Show DeleteBucket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteBucket] -> ShowS
$cshowList :: [DeleteBucket] -> ShowS
show :: DeleteBucket -> String
$cshow :: DeleteBucket -> String
showsPrec :: Int -> DeleteBucket -> ShowS
$cshowsPrec :: Int -> DeleteBucket -> ShowS
Show, DeleteBucket -> DeleteBucket -> Bool
(DeleteBucket -> DeleteBucket -> Bool)
-> (DeleteBucket -> DeleteBucket -> Bool) -> Eq DeleteBucket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteBucket -> DeleteBucket -> Bool
$c/= :: DeleteBucket -> DeleteBucket -> Bool
== :: DeleteBucket -> DeleteBucket -> Bool
$c== :: DeleteBucket -> DeleteBucket -> Bool
Eq, (forall x. DeleteBucket -> Rep DeleteBucket x)
-> (forall x. Rep DeleteBucket x -> DeleteBucket)
-> Generic DeleteBucket
forall x. Rep DeleteBucket x -> DeleteBucket
forall x. DeleteBucket -> Rep DeleteBucket x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteBucket x -> DeleteBucket
$cfrom :: forall x. DeleteBucket -> Rep DeleteBucket x
Generic )

type DeleteBucketResponse = ()

instance MonadSpaces m => Action m DeleteBucket where
    type ConsumedResponse DeleteBucket = DeleteBucketResponse

    buildRequest :: DeleteBucket -> m SpacesRequestBuilder
buildRequest DeleteBucket { Bucket
bucket :: Bucket
$sel:bucket:DeleteBucket :: DeleteBucket -> 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:method:SpacesRequestBuilder :: Maybe Method
method         = Method -> Maybe Method
forall a. a -> Maybe a
Just Method
DELETE
               , $sel:bucket:SpacesRequestBuilder :: Maybe Bucket
bucket         = Bucket -> Maybe Bucket
forall a. a -> Maybe a
Just Bucket
bucket
               , $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:queryString:SpacesRequestBuilder :: Maybe Query
queryString    = Maybe Query
forall a. Maybe a
Nothing
               , $sel:subresources:SpacesRequestBuilder :: Maybe Query
subresources   = Maybe Query
forall a. Maybe a
Nothing
               , $sel:headers:SpacesRequestBuilder :: [Header]
headers        = [Header]
forall a. Monoid a => a
mempty
               , $sel:overrideRegion:SpacesRequestBuilder :: Maybe Region
overrideRegion = Maybe Region
forall a. Maybe a
Nothing
               , Spaces
$sel:spaces:SpacesRequestBuilder :: Spaces
spaces :: Spaces
..
               }

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