{-# 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.Glacier.DeleteVault
-- 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)
--
-- This operation deletes a vault. Amazon S3 Glacier will delete a vault
-- only if there are no archives in the vault as of the last inventory and
-- there have been no writes to the vault since the last inventory. If
-- either of these conditions is not satisfied, the vault deletion fails
-- (that is, the vault is not removed) and Amazon S3 Glacier returns an
-- error. You can use DescribeVault to return the number of archives in a
-- vault, and you can use
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/api-initiate-job-post.html Initiate a Job (POST jobs)>
-- to initiate a new inventory retrieval for a vault. The inventory
-- contains the archive IDs you use to delete archives using
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/api-archive-delete.html Delete Archive (DELETE archive)>.
--
-- This operation is idempotent.
--
-- An AWS account has full permission to perform all operations (actions).
-- However, AWS Identity and Access Management (IAM) users don\'t have any
-- permissions by default. You must grant them explicit permission to
-- perform specific actions. For more information, see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/using-iam-with-amazon-glacier.html Access Control Using AWS Identity and Access Management (IAM)>.
--
-- For conceptual information and underlying REST API, see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/deleting-vaults.html Deleting a Vault in Amazon Glacier>
-- and
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/api-vault-delete.html Delete Vault>
-- in the /Amazon S3 Glacier Developer Guide/.
module Amazonka.Glacier.DeleteVault
  ( -- * Creating a Request
    DeleteVault (..),
    newDeleteVault,

    -- * Request Lenses
    deleteVault_accountId,
    deleteVault_vaultName,

    -- * Destructuring the Response
    DeleteVaultResponse (..),
    newDeleteVaultResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Glacier.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Provides options for deleting a vault from Amazon S3 Glacier.
--
-- /See:/ 'newDeleteVault' smart constructor.
data DeleteVault = DeleteVault'
  { -- | The @AccountId@ value is the AWS account ID of the account that owns the
    -- vault. You can either specify an AWS account ID or optionally a single
    -- \'@-@\' (hyphen), in which case Amazon S3 Glacier uses the AWS account
    -- ID associated with the credentials used to sign the request. If you use
    -- an account ID, do not include any hyphens (\'-\') in the ID.
    DeleteVault -> Text
accountId :: Prelude.Text,
    -- | The name of the vault.
    DeleteVault -> Text
vaultName :: Prelude.Text
  }
  deriving (DeleteVault -> DeleteVault -> Bool
(DeleteVault -> DeleteVault -> Bool)
-> (DeleteVault -> DeleteVault -> Bool) -> Eq DeleteVault
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteVault -> DeleteVault -> Bool
$c/= :: DeleteVault -> DeleteVault -> Bool
== :: DeleteVault -> DeleteVault -> Bool
$c== :: DeleteVault -> DeleteVault -> Bool
Prelude.Eq, ReadPrec [DeleteVault]
ReadPrec DeleteVault
Int -> ReadS DeleteVault
ReadS [DeleteVault]
(Int -> ReadS DeleteVault)
-> ReadS [DeleteVault]
-> ReadPrec DeleteVault
-> ReadPrec [DeleteVault]
-> Read DeleteVault
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteVault]
$creadListPrec :: ReadPrec [DeleteVault]
readPrec :: ReadPrec DeleteVault
$creadPrec :: ReadPrec DeleteVault
readList :: ReadS [DeleteVault]
$creadList :: ReadS [DeleteVault]
readsPrec :: Int -> ReadS DeleteVault
$creadsPrec :: Int -> ReadS DeleteVault
Prelude.Read, Int -> DeleteVault -> ShowS
[DeleteVault] -> ShowS
DeleteVault -> String
(Int -> DeleteVault -> ShowS)
-> (DeleteVault -> String)
-> ([DeleteVault] -> ShowS)
-> Show DeleteVault
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteVault] -> ShowS
$cshowList :: [DeleteVault] -> ShowS
show :: DeleteVault -> String
$cshow :: DeleteVault -> String
showsPrec :: Int -> DeleteVault -> ShowS
$cshowsPrec :: Int -> DeleteVault -> ShowS
Prelude.Show, (forall x. DeleteVault -> Rep DeleteVault x)
-> (forall x. Rep DeleteVault x -> DeleteVault)
-> Generic DeleteVault
forall x. Rep DeleteVault x -> DeleteVault
forall x. DeleteVault -> Rep DeleteVault x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteVault x -> DeleteVault
$cfrom :: forall x. DeleteVault -> Rep DeleteVault x
Prelude.Generic)

-- |
-- Create a value of 'DeleteVault' 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:
--
-- 'accountId', 'deleteVault_accountId' - The @AccountId@ value is the AWS account ID of the account that owns the
-- vault. You can either specify an AWS account ID or optionally a single
-- \'@-@\' (hyphen), in which case Amazon S3 Glacier uses the AWS account
-- ID associated with the credentials used to sign the request. If you use
-- an account ID, do not include any hyphens (\'-\') in the ID.
--
-- 'vaultName', 'deleteVault_vaultName' - The name of the vault.
newDeleteVault ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'vaultName'
  Prelude.Text ->
  DeleteVault
newDeleteVault :: Text -> Text -> DeleteVault
newDeleteVault Text
pAccountId_ Text
pVaultName_ =
  DeleteVault' :: Text -> Text -> DeleteVault
DeleteVault'
    { $sel:accountId:DeleteVault' :: Text
accountId = Text
pAccountId_,
      $sel:vaultName:DeleteVault' :: Text
vaultName = Text
pVaultName_
    }

-- | The @AccountId@ value is the AWS account ID of the account that owns the
-- vault. You can either specify an AWS account ID or optionally a single
-- \'@-@\' (hyphen), in which case Amazon S3 Glacier uses the AWS account
-- ID associated with the credentials used to sign the request. If you use
-- an account ID, do not include any hyphens (\'-\') in the ID.
deleteVault_accountId :: Lens.Lens' DeleteVault Prelude.Text
deleteVault_accountId :: (Text -> f Text) -> DeleteVault -> f DeleteVault
deleteVault_accountId = (DeleteVault -> Text)
-> (DeleteVault -> Text -> DeleteVault)
-> Lens DeleteVault DeleteVault Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVault' {Text
accountId :: Text
$sel:accountId:DeleteVault' :: DeleteVault -> Text
accountId} -> Text
accountId) (\s :: DeleteVault
s@DeleteVault' {} Text
a -> DeleteVault
s {$sel:accountId:DeleteVault' :: Text
accountId = Text
a} :: DeleteVault)

-- | The name of the vault.
deleteVault_vaultName :: Lens.Lens' DeleteVault Prelude.Text
deleteVault_vaultName :: (Text -> f Text) -> DeleteVault -> f DeleteVault
deleteVault_vaultName = (DeleteVault -> Text)
-> (DeleteVault -> Text -> DeleteVault)
-> Lens DeleteVault DeleteVault Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVault' {Text
vaultName :: Text
$sel:vaultName:DeleteVault' :: DeleteVault -> Text
vaultName} -> Text
vaultName) (\s :: DeleteVault
s@DeleteVault' {} Text
a -> DeleteVault
s {$sel:vaultName:DeleteVault' :: Text
vaultName = Text
a} :: DeleteVault)

instance Core.AWSRequest DeleteVault where
  type AWSResponse DeleteVault = DeleteVaultResponse
  request :: DeleteVault -> Request DeleteVault
request =
    ByteString -> Request DeleteVault -> Request DeleteVault
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
      (Request DeleteVault -> Request DeleteVault)
-> (DeleteVault -> Request DeleteVault)
-> DeleteVault
-> Request DeleteVault
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> DeleteVault -> Request DeleteVault
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteVault)))
response = AWSResponse DeleteVault
-> Logger
-> Service
-> Proxy DeleteVault
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteVault)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteVault
DeleteVaultResponse
DeleteVaultResponse'

instance Prelude.Hashable DeleteVault

instance Prelude.NFData DeleteVault

instance Core.ToHeaders DeleteVault where
  toHeaders :: DeleteVault -> [Header]
toHeaders = [Header] -> DeleteVault -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DeleteVault where
  toPath :: DeleteVault -> ByteString
toPath DeleteVault' {Text
vaultName :: Text
accountId :: Text
$sel:vaultName:DeleteVault' :: DeleteVault -> Text
$sel:accountId:DeleteVault' :: DeleteVault -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
accountId,
        ByteString
"/vaults/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
vaultName
      ]

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

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

-- |
-- Create a value of 'DeleteVaultResponse' 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.
newDeleteVaultResponse ::
  DeleteVaultResponse
newDeleteVaultResponse :: DeleteVaultResponse
newDeleteVaultResponse = DeleteVaultResponse
DeleteVaultResponse'

instance Prelude.NFData DeleteVaultResponse