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

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

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

import           GHC.Generics            ( Generic )

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

-- | Delete a single 'Object'
data DeleteObject = DeleteObject { DeleteObject -> Bucket
bucket :: Bucket, DeleteObject -> Object
object :: Object }
    deriving ( Int -> DeleteObject -> ShowS
[DeleteObject] -> ShowS
DeleteObject -> String
(Int -> DeleteObject -> ShowS)
-> (DeleteObject -> String)
-> ([DeleteObject] -> ShowS)
-> Show DeleteObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteObject] -> ShowS
$cshowList :: [DeleteObject] -> ShowS
show :: DeleteObject -> String
$cshow :: DeleteObject -> String
showsPrec :: Int -> DeleteObject -> ShowS
$cshowsPrec :: Int -> DeleteObject -> ShowS
Show, DeleteObject -> DeleteObject -> Bool
(DeleteObject -> DeleteObject -> Bool)
-> (DeleteObject -> DeleteObject -> Bool) -> Eq DeleteObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteObject -> DeleteObject -> Bool
$c/= :: DeleteObject -> DeleteObject -> Bool
== :: DeleteObject -> DeleteObject -> Bool
$c== :: DeleteObject -> DeleteObject -> Bool
Eq, (forall x. DeleteObject -> Rep DeleteObject x)
-> (forall x. Rep DeleteObject x -> DeleteObject)
-> Generic DeleteObject
forall x. Rep DeleteObject x -> DeleteObject
forall x. DeleteObject -> Rep DeleteObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteObject x -> DeleteObject
$cfrom :: forall x. DeleteObject -> Rep DeleteObject x
Generic )

type DeleteObjectResponse = ()

instance MonadSpaces m => Action m DeleteObject where
    type ConsumedResponse DeleteObject = DeleteObjectResponse

    buildRequest :: DeleteObject -> m SpacesRequestBuilder
buildRequest DeleteObject { Object
Bucket
object :: Object
bucket :: Bucket
$sel:object:DeleteObject :: DeleteObject -> Object
$sel:bucket:DeleteObject :: DeleteObject -> 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:object:SpacesRequestBuilder :: Maybe Object
object         = Object -> Maybe Object
forall a. a -> Maybe a
Just Object
object
               , $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: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 DeleteObject)
consumeResponse RawResponse m
_ = () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()