{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
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
(DeleteContainer -> DeleteContainer -> Bool)
-> (DeleteContainer -> DeleteContainer -> Bool)
-> Eq DeleteContainer
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]
(Int -> ReadS DeleteContainer)
-> ReadS [DeleteContainer]
-> ReadPrec DeleteContainer
-> ReadPrec [DeleteContainer]
-> Read 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
(Int -> DeleteContainer -> ShowS)
-> (DeleteContainer -> String)
-> ([DeleteContainer] -> ShowS)
-> Show DeleteContainer
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. DeleteContainer -> Rep DeleteContainer x)
-> (forall x. Rep DeleteContainer x -> DeleteContainer)
-> Generic DeleteContainer
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' :: Text -> DeleteContainer
DeleteContainer' {$sel:containerName:DeleteContainer' :: Text
containerName = Text
pContainerName_}

-- | The name of the container to delete.
deleteContainer_containerName :: Lens.Lens' DeleteContainer Prelude.Text
deleteContainer_containerName :: (Text -> f Text) -> DeleteContainer -> f DeleteContainer
deleteContainer_containerName = (DeleteContainer -> Text)
-> (DeleteContainer -> Text -> DeleteContainer)
-> Lens DeleteContainer DeleteContainer Text Text
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 :: DeleteContainer -> Request DeleteContainer
request = Service -> DeleteContainer -> Request DeleteContainer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteContainer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteContainer)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteContainer))
-> Logger
-> Service
-> Proxy DeleteContainer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteContainer)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteContainerResponse
DeleteContainerResponse'
            (Int -> DeleteContainerResponse)
-> Either String Int -> Either String DeleteContainerResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteContainer

instance Prelude.NFData DeleteContainer

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

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

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

instance Core.ToQuery DeleteContainer where
  toQuery :: DeleteContainer -> QueryString
toQuery = QueryString -> DeleteContainer -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteContainerResponse -> DeleteContainerResponse -> Bool)
-> (DeleteContainerResponse -> DeleteContainerResponse -> Bool)
-> Eq DeleteContainerResponse
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]
(Int -> ReadS DeleteContainerResponse)
-> ReadS [DeleteContainerResponse]
-> ReadPrec DeleteContainerResponse
-> ReadPrec [DeleteContainerResponse]
-> Read 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
(Int -> DeleteContainerResponse -> ShowS)
-> (DeleteContainerResponse -> String)
-> ([DeleteContainerResponse] -> ShowS)
-> Show DeleteContainerResponse
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.
 DeleteContainerResponse -> Rep DeleteContainerResponse x)
-> (forall x.
    Rep DeleteContainerResponse x -> DeleteContainerResponse)
-> Generic DeleteContainerResponse
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' :: Int -> DeleteContainerResponse
DeleteContainerResponse' {$sel:httpStatus:DeleteContainerResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteContainerResponse_httpStatus :: Lens.Lens' DeleteContainerResponse Prelude.Int
deleteContainerResponse_httpStatus :: (Int -> f Int)
-> DeleteContainerResponse -> f DeleteContainerResponse
deleteContainerResponse_httpStatus = (DeleteContainerResponse -> Int)
-> (DeleteContainerResponse -> Int -> DeleteContainerResponse)
-> Lens DeleteContainerResponse DeleteContainerResponse Int Int
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