{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.MediaStoreData.DeleteObject
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes an object at the specified path.
module Amazonka.MediaStoreData.DeleteObject
  ( -- * Creating a Request
    DeleteObject (..),
    newDeleteObject,

    -- * Request Lenses
    deleteObject_path,

    -- * Destructuring the Response
    DeleteObjectResponse (..),
    newDeleteObjectResponse,

    -- * Response Lenses
    deleteObjectResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaStoreData.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteObject' smart constructor.
data DeleteObject = DeleteObject'
  { -- | The path (including the file name) where the object is stored in the
    -- container. Format: \<folder name>\/\<folder name>\/\<file name>
    DeleteObject -> Text
path :: Prelude.Text
  }
  deriving (DeleteObject -> DeleteObject -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteObject -> DeleteObject -> Bool
$c/= :: DeleteObject -> DeleteObject -> Bool
== :: DeleteObject -> DeleteObject -> Bool
$c== :: DeleteObject -> DeleteObject -> Bool
Prelude.Eq, ReadPrec [DeleteObject]
ReadPrec DeleteObject
Int -> ReadS DeleteObject
ReadS [DeleteObject]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteObject]
$creadListPrec :: ReadPrec [DeleteObject]
readPrec :: ReadPrec DeleteObject
$creadPrec :: ReadPrec DeleteObject
readList :: ReadS [DeleteObject]
$creadList :: ReadS [DeleteObject]
readsPrec :: Int -> ReadS DeleteObject
$creadsPrec :: Int -> ReadS DeleteObject
Prelude.Read, Int -> DeleteObject -> ShowS
[DeleteObject] -> ShowS
DeleteObject -> String
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
Prelude.Show, 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
Prelude.Generic)

-- |
-- Create a value of 'DeleteObject' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'path', 'deleteObject_path' - The path (including the file name) where the object is stored in the
-- container. Format: \<folder name>\/\<folder name>\/\<file name>
newDeleteObject ::
  -- | 'path'
  Prelude.Text ->
  DeleteObject
newDeleteObject :: Text -> DeleteObject
newDeleteObject Text
pPath_ = DeleteObject' {$sel:path:DeleteObject' :: Text
path = Text
pPath_}

-- | The path (including the file name) where the object is stored in the
-- container. Format: \<folder name>\/\<folder name>\/\<file name>
deleteObject_path :: Lens.Lens' DeleteObject Prelude.Text
deleteObject_path :: Lens' DeleteObject Text
deleteObject_path = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObject' {Text
path :: Text
$sel:path:DeleteObject' :: DeleteObject -> Text
path} -> Text
path) (\s :: DeleteObject
s@DeleteObject' {} Text
a -> DeleteObject
s {$sel:path:DeleteObject' :: Text
path = Text
a} :: DeleteObject)

instance Core.AWSRequest DeleteObject where
  type AWSResponse DeleteObject = DeleteObjectResponse
  request :: (Service -> Service) -> DeleteObject -> Request DeleteObject
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteObject
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteObject)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteObjectResponse
DeleteObjectResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteObject where
  hashWithSalt :: Int -> DeleteObject -> Int
hashWithSalt Int
_salt DeleteObject' {Text
path :: Text
$sel:path:DeleteObject' :: DeleteObject -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
path

instance Prelude.NFData DeleteObject where
  rnf :: DeleteObject -> ()
rnf DeleteObject' {Text
path :: Text
$sel:path:DeleteObject' :: DeleteObject -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
path

instance Data.ToHeaders DeleteObject where
  toHeaders :: DeleteObject -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath DeleteObject where
  toPath :: DeleteObject -> ByteString
toPath DeleteObject' {Text
path :: Text
$sel:path:DeleteObject' :: DeleteObject -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
path]

instance Data.ToQuery DeleteObject where
  toQuery :: DeleteObject -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDeleteObjectResponse' smart constructor.
data DeleteObjectResponse = DeleteObjectResponse'
  { -- | The response's http status code.
    DeleteObjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteObjectResponse -> DeleteObjectResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
$c/= :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
== :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
$c== :: DeleteObjectResponse -> DeleteObjectResponse -> Bool
Prelude.Eq, ReadPrec [DeleteObjectResponse]
ReadPrec DeleteObjectResponse
Int -> ReadS DeleteObjectResponse
ReadS [DeleteObjectResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteObjectResponse]
$creadListPrec :: ReadPrec [DeleteObjectResponse]
readPrec :: ReadPrec DeleteObjectResponse
$creadPrec :: ReadPrec DeleteObjectResponse
readList :: ReadS [DeleteObjectResponse]
$creadList :: ReadS [DeleteObjectResponse]
readsPrec :: Int -> ReadS DeleteObjectResponse
$creadsPrec :: Int -> ReadS DeleteObjectResponse
Prelude.Read, Int -> DeleteObjectResponse -> ShowS
[DeleteObjectResponse] -> ShowS
DeleteObjectResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteObjectResponse] -> ShowS
$cshowList :: [DeleteObjectResponse] -> ShowS
show :: DeleteObjectResponse -> String
$cshow :: DeleteObjectResponse -> String
showsPrec :: Int -> DeleteObjectResponse -> ShowS
$cshowsPrec :: Int -> DeleteObjectResponse -> ShowS
Prelude.Show, forall x. Rep DeleteObjectResponse x -> DeleteObjectResponse
forall x. DeleteObjectResponse -> Rep DeleteObjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteObjectResponse x -> DeleteObjectResponse
$cfrom :: forall x. DeleteObjectResponse -> Rep DeleteObjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteObjectResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'deleteObjectResponse_httpStatus' - The response's http status code.
newDeleteObjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteObjectResponse
newDeleteObjectResponse :: Int -> DeleteObjectResponse
newDeleteObjectResponse Int
pHttpStatus_ =
  DeleteObjectResponse' {$sel:httpStatus:DeleteObjectResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteObjectResponse_httpStatus :: Lens.Lens' DeleteObjectResponse Prelude.Int
deleteObjectResponse_httpStatus :: Lens' DeleteObjectResponse Int
deleteObjectResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteObjectResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteObjectResponse' :: DeleteObjectResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteObjectResponse
s@DeleteObjectResponse' {} Int
a -> DeleteObjectResponse
s {$sel:httpStatus:DeleteObjectResponse' :: Int
httpStatus = Int
a} :: DeleteObjectResponse)

instance Prelude.NFData DeleteObjectResponse where
  rnf :: DeleteObjectResponse -> ()
rnf DeleteObjectResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteObjectResponse' :: DeleteObjectResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus