{-# 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.AbortMultipartUpload
-- 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 aborts a multipart upload identified by the upload ID.
--
-- After the Abort Multipart Upload request succeeds, you cannot upload any
-- more parts to the multipart upload or complete the multipart upload.
-- Aborting a completed upload fails. However, aborting an already-aborted
-- upload will succeed, for a short time. For more information about
-- uploading a part and completing a multipart upload, see
-- UploadMultipartPart and CompleteMultipartUpload.
--
-- 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/working-with-archives.html Working with Archives in Amazon S3 Glacier>
-- and
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/api-multipart-abort-upload.html Abort Multipart Upload>
-- in the /Amazon Glacier Developer Guide/.
module Amazonka.Glacier.AbortMultipartUpload
  ( -- * Creating a Request
    AbortMultipartUpload (..),
    newAbortMultipartUpload,

    -- * Request Lenses
    abortMultipartUpload_accountId,
    abortMultipartUpload_vaultName,
    abortMultipartUpload_uploadId,

    -- * Destructuring the Response
    AbortMultipartUploadResponse (..),
    newAbortMultipartUploadResponse,
  )
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 to abort a multipart upload identified by the upload
-- ID.
--
-- For information about the underlying REST API, see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/api-multipart-abort-upload.html Abort Multipart Upload>.
-- For conceptual information, see
-- <https://docs.aws.amazon.com/amazonglacier/latest/dev/working-with-archives.html Working with Archives in Amazon S3 Glacier>.
--
-- /See:/ 'newAbortMultipartUpload' smart constructor.
data AbortMultipartUpload = AbortMultipartUpload'
  { -- | 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.
    AbortMultipartUpload -> Text
accountId :: Prelude.Text,
    -- | The name of the vault.
    AbortMultipartUpload -> Text
vaultName :: Prelude.Text,
    -- | The upload ID of the multipart upload to delete.
    AbortMultipartUpload -> Text
uploadId :: Prelude.Text
  }
  deriving (AbortMultipartUpload -> AbortMultipartUpload -> Bool
(AbortMultipartUpload -> AbortMultipartUpload -> Bool)
-> (AbortMultipartUpload -> AbortMultipartUpload -> Bool)
-> Eq AbortMultipartUpload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbortMultipartUpload -> AbortMultipartUpload -> Bool
$c/= :: AbortMultipartUpload -> AbortMultipartUpload -> Bool
== :: AbortMultipartUpload -> AbortMultipartUpload -> Bool
$c== :: AbortMultipartUpload -> AbortMultipartUpload -> Bool
Prelude.Eq, ReadPrec [AbortMultipartUpload]
ReadPrec AbortMultipartUpload
Int -> ReadS AbortMultipartUpload
ReadS [AbortMultipartUpload]
(Int -> ReadS AbortMultipartUpload)
-> ReadS [AbortMultipartUpload]
-> ReadPrec AbortMultipartUpload
-> ReadPrec [AbortMultipartUpload]
-> Read AbortMultipartUpload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AbortMultipartUpload]
$creadListPrec :: ReadPrec [AbortMultipartUpload]
readPrec :: ReadPrec AbortMultipartUpload
$creadPrec :: ReadPrec AbortMultipartUpload
readList :: ReadS [AbortMultipartUpload]
$creadList :: ReadS [AbortMultipartUpload]
readsPrec :: Int -> ReadS AbortMultipartUpload
$creadsPrec :: Int -> ReadS AbortMultipartUpload
Prelude.Read, Int -> AbortMultipartUpload -> ShowS
[AbortMultipartUpload] -> ShowS
AbortMultipartUpload -> String
(Int -> AbortMultipartUpload -> ShowS)
-> (AbortMultipartUpload -> String)
-> ([AbortMultipartUpload] -> ShowS)
-> Show AbortMultipartUpload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbortMultipartUpload] -> ShowS
$cshowList :: [AbortMultipartUpload] -> ShowS
show :: AbortMultipartUpload -> String
$cshow :: AbortMultipartUpload -> String
showsPrec :: Int -> AbortMultipartUpload -> ShowS
$cshowsPrec :: Int -> AbortMultipartUpload -> ShowS
Prelude.Show, (forall x. AbortMultipartUpload -> Rep AbortMultipartUpload x)
-> (forall x. Rep AbortMultipartUpload x -> AbortMultipartUpload)
-> Generic AbortMultipartUpload
forall x. Rep AbortMultipartUpload x -> AbortMultipartUpload
forall x. AbortMultipartUpload -> Rep AbortMultipartUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AbortMultipartUpload x -> AbortMultipartUpload
$cfrom :: forall x. AbortMultipartUpload -> Rep AbortMultipartUpload x
Prelude.Generic)

-- |
-- Create a value of 'AbortMultipartUpload' 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', 'abortMultipartUpload_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', 'abortMultipartUpload_vaultName' - The name of the vault.
--
-- 'uploadId', 'abortMultipartUpload_uploadId' - The upload ID of the multipart upload to delete.
newAbortMultipartUpload ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'vaultName'
  Prelude.Text ->
  -- | 'uploadId'
  Prelude.Text ->
  AbortMultipartUpload
newAbortMultipartUpload :: Text -> Text -> Text -> AbortMultipartUpload
newAbortMultipartUpload
  Text
pAccountId_
  Text
pVaultName_
  Text
pUploadId_ =
    AbortMultipartUpload' :: Text -> Text -> Text -> AbortMultipartUpload
AbortMultipartUpload'
      { $sel:accountId:AbortMultipartUpload' :: Text
accountId = Text
pAccountId_,
        $sel:vaultName:AbortMultipartUpload' :: Text
vaultName = Text
pVaultName_,
        $sel:uploadId:AbortMultipartUpload' :: Text
uploadId = Text
pUploadId_
      }

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

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

-- | The upload ID of the multipart upload to delete.
abortMultipartUpload_uploadId :: Lens.Lens' AbortMultipartUpload Prelude.Text
abortMultipartUpload_uploadId :: (Text -> f Text) -> AbortMultipartUpload -> f AbortMultipartUpload
abortMultipartUpload_uploadId = (AbortMultipartUpload -> Text)
-> (AbortMultipartUpload -> Text -> AbortMultipartUpload)
-> Lens AbortMultipartUpload AbortMultipartUpload Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbortMultipartUpload' {Text
uploadId :: Text
$sel:uploadId:AbortMultipartUpload' :: AbortMultipartUpload -> Text
uploadId} -> Text
uploadId) (\s :: AbortMultipartUpload
s@AbortMultipartUpload' {} Text
a -> AbortMultipartUpload
s {$sel:uploadId:AbortMultipartUpload' :: Text
uploadId = Text
a} :: AbortMultipartUpload)

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

instance Prelude.Hashable AbortMultipartUpload

instance Prelude.NFData AbortMultipartUpload

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

instance Core.ToPath AbortMultipartUpload where
  toPath :: AbortMultipartUpload -> ByteString
toPath AbortMultipartUpload' {Text
uploadId :: Text
vaultName :: Text
accountId :: Text
$sel:uploadId:AbortMultipartUpload' :: AbortMultipartUpload -> Text
$sel:vaultName:AbortMultipartUpload' :: AbortMultipartUpload -> Text
$sel:accountId:AbortMultipartUpload' :: AbortMultipartUpload -> 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
"/multipart-uploads/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
uploadId
      ]

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

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

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

instance Prelude.NFData AbortMultipartUploadResponse