{-# 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.DeleteArchive
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation deletes an archive from a vault. Subsequent requests to
-- initiate a retrieval of this archive will fail. Archive retrievals that
-- are in progress for this archive ID may or may not succeed according to
-- the following scenarios:
--
-- -   If the archive retrieval job is actively preparing the data for
--     download when Amazon S3 Glacier receives the delete archive request,
--     the archival retrieval operation might fail.
--
-- -   If the archive retrieval job has successfully prepared the archive
--     for download when Amazon S3 Glacier receives the delete archive
--     request, you will be able to download the output.
--
-- This operation is idempotent. Attempting to delete an already-deleted
-- archive does not result in an error.
--
-- 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-an-archive.html Deleting an Archive in Amazon Glacier>
-- and
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/api-archive-delete.html Delete Archive>
-- in the /Amazon Glacier Developer Guide/.
module Amazonka.Glacier.DeleteArchive
  ( -- * Creating a Request
    DeleteArchive (..),
    newDeleteArchive,

    -- * Request Lenses
    deleteArchive_accountId,
    deleteArchive_vaultName,
    deleteArchive_archiveId,

    -- * Destructuring the Response
    DeleteArchiveResponse (..),
    newDeleteArchiveResponse,
  )
where

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

-- | Provides options for deleting an archive from an Amazon S3 Glacier
-- vault.
--
-- /See:/ 'newDeleteArchive' smart constructor.
data DeleteArchive = DeleteArchive'
  { -- | 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.
    DeleteArchive -> Text
accountId :: Prelude.Text,
    -- | The name of the vault.
    DeleteArchive -> Text
vaultName :: Prelude.Text,
    -- | The ID of the archive to delete.
    DeleteArchive -> Text
archiveId :: Prelude.Text
  }
  deriving (DeleteArchive -> DeleteArchive -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteArchive -> DeleteArchive -> Bool
$c/= :: DeleteArchive -> DeleteArchive -> Bool
== :: DeleteArchive -> DeleteArchive -> Bool
$c== :: DeleteArchive -> DeleteArchive -> Bool
Prelude.Eq, ReadPrec [DeleteArchive]
ReadPrec DeleteArchive
Int -> ReadS DeleteArchive
ReadS [DeleteArchive]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteArchive]
$creadListPrec :: ReadPrec [DeleteArchive]
readPrec :: ReadPrec DeleteArchive
$creadPrec :: ReadPrec DeleteArchive
readList :: ReadS [DeleteArchive]
$creadList :: ReadS [DeleteArchive]
readsPrec :: Int -> ReadS DeleteArchive
$creadsPrec :: Int -> ReadS DeleteArchive
Prelude.Read, Int -> DeleteArchive -> ShowS
[DeleteArchive] -> ShowS
DeleteArchive -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteArchive] -> ShowS
$cshowList :: [DeleteArchive] -> ShowS
show :: DeleteArchive -> String
$cshow :: DeleteArchive -> String
showsPrec :: Int -> DeleteArchive -> ShowS
$cshowsPrec :: Int -> DeleteArchive -> ShowS
Prelude.Show, forall x. Rep DeleteArchive x -> DeleteArchive
forall x. DeleteArchive -> Rep DeleteArchive x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteArchive x -> DeleteArchive
$cfrom :: forall x. DeleteArchive -> Rep DeleteArchive x
Prelude.Generic)

-- |
-- Create a value of 'DeleteArchive' 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', 'deleteArchive_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', 'deleteArchive_vaultName' - The name of the vault.
--
-- 'archiveId', 'deleteArchive_archiveId' - The ID of the archive to delete.
newDeleteArchive ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'vaultName'
  Prelude.Text ->
  -- | 'archiveId'
  Prelude.Text ->
  DeleteArchive
newDeleteArchive :: Text -> Text -> Text -> DeleteArchive
newDeleteArchive Text
pAccountId_ Text
pVaultName_ Text
pArchiveId_ =
  DeleteArchive'
    { $sel:accountId:DeleteArchive' :: Text
accountId = Text
pAccountId_,
      $sel:vaultName:DeleteArchive' :: Text
vaultName = Text
pVaultName_,
      $sel:archiveId:DeleteArchive' :: Text
archiveId = Text
pArchiveId_
    }

-- | 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.
deleteArchive_accountId :: Lens.Lens' DeleteArchive Prelude.Text
deleteArchive_accountId :: Lens' DeleteArchive Text
deleteArchive_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteArchive' {Text
accountId :: Text
$sel:accountId:DeleteArchive' :: DeleteArchive -> Text
accountId} -> Text
accountId) (\s :: DeleteArchive
s@DeleteArchive' {} Text
a -> DeleteArchive
s {$sel:accountId:DeleteArchive' :: Text
accountId = Text
a} :: DeleteArchive)

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

-- | The ID of the archive to delete.
deleteArchive_archiveId :: Lens.Lens' DeleteArchive Prelude.Text
deleteArchive_archiveId :: Lens' DeleteArchive Text
deleteArchive_archiveId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteArchive' {Text
archiveId :: Text
$sel:archiveId:DeleteArchive' :: DeleteArchive -> Text
archiveId} -> Text
archiveId) (\s :: DeleteArchive
s@DeleteArchive' {} Text
a -> DeleteArchive
s {$sel:archiveId:DeleteArchive' :: Text
archiveId = Text
a} :: DeleteArchive)

instance Core.AWSRequest DeleteArchive where
  type
    AWSResponse DeleteArchive =
      DeleteArchiveResponse
  request :: (Service -> Service) -> DeleteArchive -> Request DeleteArchive
request Service -> Service
overrides =
    forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core.version Service
defaultService)
      forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 DeleteArchive
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteArchive)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DeleteArchiveResponse
DeleteArchiveResponse'

instance Prelude.Hashable DeleteArchive where
  hashWithSalt :: Int -> DeleteArchive -> Int
hashWithSalt Int
_salt DeleteArchive' {Text
archiveId :: Text
vaultName :: Text
accountId :: Text
$sel:archiveId:DeleteArchive' :: DeleteArchive -> Text
$sel:vaultName:DeleteArchive' :: DeleteArchive -> Text
$sel:accountId:DeleteArchive' :: DeleteArchive -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
vaultName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
archiveId

instance Prelude.NFData DeleteArchive where
  rnf :: DeleteArchive -> ()
rnf DeleteArchive' {Text
archiveId :: Text
vaultName :: Text
accountId :: Text
$sel:archiveId:DeleteArchive' :: DeleteArchive -> Text
$sel:vaultName:DeleteArchive' :: DeleteArchive -> Text
$sel:accountId:DeleteArchive' :: DeleteArchive -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
vaultName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
archiveId

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

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

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

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

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

instance Prelude.NFData DeleteArchiveResponse where
  rnf :: DeleteArchiveResponse -> ()
rnf DeleteArchiveResponse
_ = ()