{-# 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.MediaStore.DeleteContainer
-- 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 the specified container. Before you make a @DeleteContainer@
-- request, delete any objects in the container or in any folders in the
-- container. You can delete only empty containers.
module Amazonka.MediaStore.DeleteContainer
  ( -- * Creating a Request
    DeleteContainer (..),
    newDeleteContainer,

    -- * Request Lenses
    deleteContainer_containerName,

    -- * Destructuring the Response
    DeleteContainerResponse (..),
    newDeleteContainerResponse,

    -- * Response Lenses
    deleteContainerResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteContainer' smart constructor.
data DeleteContainer = DeleteContainer'
  { -- | The name of the container to delete.
    DeleteContainer -> Text
containerName :: Prelude.Text
  }
  deriving (DeleteContainer -> DeleteContainer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteContainer -> DeleteContainer -> Bool
$c/= :: DeleteContainer -> DeleteContainer -> Bool
== :: DeleteContainer -> DeleteContainer -> Bool
$c== :: DeleteContainer -> DeleteContainer -> Bool
Prelude.Eq, ReadPrec [DeleteContainer]
ReadPrec DeleteContainer
Int -> ReadS DeleteContainer
ReadS [DeleteContainer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteContainer]
$creadListPrec :: ReadPrec [DeleteContainer]
readPrec :: ReadPrec DeleteContainer
$creadPrec :: ReadPrec DeleteContainer
readList :: ReadS [DeleteContainer]
$creadList :: ReadS [DeleteContainer]
readsPrec :: Int -> ReadS DeleteContainer
$creadsPrec :: Int -> ReadS DeleteContainer
Prelude.Read, Int -> DeleteContainer -> ShowS
[DeleteContainer] -> ShowS
DeleteContainer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteContainer] -> ShowS
$cshowList :: [DeleteContainer] -> ShowS
show :: DeleteContainer -> String
$cshow :: DeleteContainer -> String
showsPrec :: Int -> DeleteContainer -> ShowS
$cshowsPrec :: Int -> DeleteContainer -> ShowS
Prelude.Show, forall x. Rep DeleteContainer x -> DeleteContainer
forall x. DeleteContainer -> Rep DeleteContainer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteContainer x -> DeleteContainer
$cfrom :: forall x. DeleteContainer -> Rep DeleteContainer x
Prelude.Generic)

-- |
-- Create a value of 'DeleteContainer' 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:
--
-- 'containerName', 'deleteContainer_containerName' - The name of the container to delete.
newDeleteContainer ::
  -- | 'containerName'
  Prelude.Text ->
  DeleteContainer
newDeleteContainer :: Text -> DeleteContainer
newDeleteContainer Text
pContainerName_ =
  DeleteContainer' {$sel:containerName:DeleteContainer' :: Text
containerName = Text
pContainerName_}

-- | The name of the container to delete.
deleteContainer_containerName :: Lens.Lens' DeleteContainer Prelude.Text
deleteContainer_containerName :: Lens' DeleteContainer Text
deleteContainer_containerName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContainer' {Text
containerName :: Text
$sel:containerName:DeleteContainer' :: DeleteContainer -> Text
containerName} -> Text
containerName) (\s :: DeleteContainer
s@DeleteContainer' {} Text
a -> DeleteContainer
s {$sel:containerName:DeleteContainer' :: Text
containerName = Text
a} :: DeleteContainer)

instance Core.AWSRequest DeleteContainer where
  type
    AWSResponse DeleteContainer =
      DeleteContainerResponse
  request :: (Service -> Service) -> DeleteContainer -> Request DeleteContainer
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteContainer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteContainer)))
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 -> DeleteContainerResponse
DeleteContainerResponse'
            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 DeleteContainer where
  hashWithSalt :: Int -> DeleteContainer -> Int
hashWithSalt Int
_salt DeleteContainer' {Text
containerName :: Text
$sel:containerName:DeleteContainer' :: DeleteContainer -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
containerName

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

instance Data.ToHeaders DeleteContainer where
  toHeaders :: DeleteContainer -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"MediaStore_20170901.DeleteContainer" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteContainer where
  toJSON :: DeleteContainer -> Value
toJSON DeleteContainer' {Text
containerName :: Text
$sel:containerName:DeleteContainer' :: DeleteContainer -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ContainerName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
containerName)
          ]
      )

instance Data.ToPath DeleteContainer where
  toPath :: DeleteContainer -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DeleteContainerResponse' 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', 'deleteContainerResponse_httpStatus' - The response's http status code.
newDeleteContainerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteContainerResponse
newDeleteContainerResponse :: Int -> DeleteContainerResponse
newDeleteContainerResponse Int
pHttpStatus_ =
  DeleteContainerResponse' {$sel:httpStatus:DeleteContainerResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

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