{-# 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-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 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 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 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
(DeleteArchive -> DeleteArchive -> Bool)
-> (DeleteArchive -> DeleteArchive -> Bool) -> Eq DeleteArchive
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]
(Int -> ReadS DeleteArchive)
-> ReadS [DeleteArchive]
-> ReadPrec DeleteArchive
-> ReadPrec [DeleteArchive]
-> Read 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
(Int -> DeleteArchive -> ShowS)
-> (DeleteArchive -> String)
-> ([DeleteArchive] -> ShowS)
-> Show DeleteArchive
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. DeleteArchive -> Rep DeleteArchive x)
-> (forall x. Rep DeleteArchive x -> DeleteArchive)
-> Generic DeleteArchive
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' :: Text -> Text -> Text -> DeleteArchive
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 :: (Text -> f Text) -> DeleteArchive -> f DeleteArchive
deleteArchive_accountId = (DeleteArchive -> Text)
-> (DeleteArchive -> Text -> DeleteArchive)
-> Lens DeleteArchive DeleteArchive Text Text
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 :: (Text -> f Text) -> DeleteArchive -> f DeleteArchive
deleteArchive_vaultName = (DeleteArchive -> Text)
-> (DeleteArchive -> Text -> DeleteArchive)
-> Lens DeleteArchive DeleteArchive Text Text
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 :: (Text -> f Text) -> DeleteArchive -> f DeleteArchive
deleteArchive_archiveId = (DeleteArchive -> Text)
-> (DeleteArchive -> Text -> DeleteArchive)
-> Lens DeleteArchive DeleteArchive Text Text
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 :: DeleteArchive -> Request DeleteArchive
request =
    ByteString -> Request DeleteArchive -> Request DeleteArchive
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
      (Request DeleteArchive -> Request DeleteArchive)
-> (DeleteArchive -> Request DeleteArchive)
-> DeleteArchive
-> Request DeleteArchive
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> DeleteArchive -> Request DeleteArchive
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteArchive
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteArchive)))
response =
    AWSResponse DeleteArchive
-> Logger
-> Service
-> Proxy DeleteArchive
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteArchive)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse DeleteArchive
DeleteArchiveResponse
DeleteArchiveResponse'

instance Prelude.Hashable DeleteArchive

instance Prelude.NFData DeleteArchive

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

instance Core.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
..} =
    [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,
        ByteString
"/archives/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
archiveId
      ]

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

-- | /See:/ 'newDeleteArchiveResponse' smart constructor.
data DeleteArchiveResponse = DeleteArchiveResponse'
  {
  }
  deriving (DeleteArchiveResponse -> DeleteArchiveResponse -> Bool
(DeleteArchiveResponse -> DeleteArchiveResponse -> Bool)
-> (DeleteArchiveResponse -> DeleteArchiveResponse -> Bool)
-> Eq DeleteArchiveResponse
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]
(Int -> ReadS DeleteArchiveResponse)
-> ReadS [DeleteArchiveResponse]
-> ReadPrec DeleteArchiveResponse
-> ReadPrec [DeleteArchiveResponse]
-> Read 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
(Int -> DeleteArchiveResponse -> ShowS)
-> (DeleteArchiveResponse -> String)
-> ([DeleteArchiveResponse] -> ShowS)
-> Show DeleteArchiveResponse
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. DeleteArchiveResponse -> Rep DeleteArchiveResponse x)
-> (forall x. Rep DeleteArchiveResponse x -> DeleteArchiveResponse)
-> Generic DeleteArchiveResponse
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