{-# 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.ListParts
-- 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 lists the parts of an archive that have been uploaded in
-- a specific multipart upload. You can make this request at any time
-- during an in-progress multipart upload before you complete the upload
-- (see CompleteMultipartUpload. List Parts returns an error for completed
-- uploads. The list returned in the List Parts response is sorted by part
-- range.
--
-- The List Parts operation supports pagination. By default, this operation
-- returns up to 50 uploaded parts in the response. You should always check
-- the response for a @marker@ at which to continue the list; if there are
-- no more items the @marker@ is @null@. To return a list of parts that
-- begins at a specific part, set the @marker@ request parameter to the
-- value you obtained from a previous List Parts request. You can also
-- limit the number of parts returned in the response by specifying the
-- @limit@ parameter in the request.
--
-- 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 the 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-list-parts.html List Parts>
-- in the /Amazon Glacier Developer Guide/.
--
-- This operation returns paginated results.
module Amazonka.Glacier.ListParts
  ( -- * Creating a Request
    ListParts (..),
    newListParts,

    -- * Request Lenses
    listParts_marker,
    listParts_limit,
    listParts_accountId,
    listParts_vaultName,
    listParts_uploadId,

    -- * Destructuring the Response
    ListPartsResponse (..),
    newListPartsResponse,

    -- * Response Lenses
    listPartsResponse_parts,
    listPartsResponse_multipartUploadId,
    listPartsResponse_partSizeInBytes,
    listPartsResponse_archiveDescription,
    listPartsResponse_vaultARN,
    listPartsResponse_marker,
    listPartsResponse_creationDate,
    listPartsResponse_httpStatus,
  )
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 retrieving a list of parts of an archive that have
-- been uploaded in a specific multipart upload.
--
-- /See:/ 'newListParts' smart constructor.
data ListParts = ListParts'
  { -- | An opaque string used for pagination. This value specifies the part at
    -- which the listing of parts should begin. Get the marker value from the
    -- response of a previous List Parts response. You need only include the
    -- marker if you are continuing the pagination of results started in a
    -- previous List Parts request.
    ListParts -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of parts to be returned. The default limit is 50. The
    -- number of parts returned might be fewer than the specified limit, but
    -- the number of returned parts never exceeds the limit.
    ListParts -> Maybe Text
limit :: Prelude.Maybe Prelude.Text,
    -- | 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.
    ListParts -> Text
accountId :: Prelude.Text,
    -- | The name of the vault.
    ListParts -> Text
vaultName :: Prelude.Text,
    -- | The upload ID of the multipart upload.
    ListParts -> Text
uploadId :: Prelude.Text
  }
  deriving (ListParts -> ListParts -> Bool
(ListParts -> ListParts -> Bool)
-> (ListParts -> ListParts -> Bool) -> Eq ListParts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListParts -> ListParts -> Bool
$c/= :: ListParts -> ListParts -> Bool
== :: ListParts -> ListParts -> Bool
$c== :: ListParts -> ListParts -> Bool
Prelude.Eq, ReadPrec [ListParts]
ReadPrec ListParts
Int -> ReadS ListParts
ReadS [ListParts]
(Int -> ReadS ListParts)
-> ReadS [ListParts]
-> ReadPrec ListParts
-> ReadPrec [ListParts]
-> Read ListParts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListParts]
$creadListPrec :: ReadPrec [ListParts]
readPrec :: ReadPrec ListParts
$creadPrec :: ReadPrec ListParts
readList :: ReadS [ListParts]
$creadList :: ReadS [ListParts]
readsPrec :: Int -> ReadS ListParts
$creadsPrec :: Int -> ReadS ListParts
Prelude.Read, Int -> ListParts -> ShowS
[ListParts] -> ShowS
ListParts -> String
(Int -> ListParts -> ShowS)
-> (ListParts -> String)
-> ([ListParts] -> ShowS)
-> Show ListParts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListParts] -> ShowS
$cshowList :: [ListParts] -> ShowS
show :: ListParts -> String
$cshow :: ListParts -> String
showsPrec :: Int -> ListParts -> ShowS
$cshowsPrec :: Int -> ListParts -> ShowS
Prelude.Show, (forall x. ListParts -> Rep ListParts x)
-> (forall x. Rep ListParts x -> ListParts) -> Generic ListParts
forall x. Rep ListParts x -> ListParts
forall x. ListParts -> Rep ListParts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListParts x -> ListParts
$cfrom :: forall x. ListParts -> Rep ListParts x
Prelude.Generic)

-- |
-- Create a value of 'ListParts' 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:
--
-- 'marker', 'listParts_marker' - An opaque string used for pagination. This value specifies the part at
-- which the listing of parts should begin. Get the marker value from the
-- response of a previous List Parts response. You need only include the
-- marker if you are continuing the pagination of results started in a
-- previous List Parts request.
--
-- 'limit', 'listParts_limit' - The maximum number of parts to be returned. The default limit is 50. The
-- number of parts returned might be fewer than the specified limit, but
-- the number of returned parts never exceeds the limit.
--
-- 'accountId', 'listParts_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', 'listParts_vaultName' - The name of the vault.
--
-- 'uploadId', 'listParts_uploadId' - The upload ID of the multipart upload.
newListParts ::
  -- | 'accountId'
  Prelude.Text ->
  -- | 'vaultName'
  Prelude.Text ->
  -- | 'uploadId'
  Prelude.Text ->
  ListParts
newListParts :: Text -> Text -> Text -> ListParts
newListParts Text
pAccountId_ Text
pVaultName_ Text
pUploadId_ =
  ListParts' :: Maybe Text -> Maybe Text -> Text -> Text -> Text -> ListParts
ListParts'
    { $sel:marker:ListParts' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:ListParts' :: Maybe Text
limit = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:accountId:ListParts' :: Text
accountId = Text
pAccountId_,
      $sel:vaultName:ListParts' :: Text
vaultName = Text
pVaultName_,
      $sel:uploadId:ListParts' :: Text
uploadId = Text
pUploadId_
    }

-- | An opaque string used for pagination. This value specifies the part at
-- which the listing of parts should begin. Get the marker value from the
-- response of a previous List Parts response. You need only include the
-- marker if you are continuing the pagination of results started in a
-- previous List Parts request.
listParts_marker :: Lens.Lens' ListParts (Prelude.Maybe Prelude.Text)
listParts_marker :: (Maybe Text -> f (Maybe Text)) -> ListParts -> f ListParts
listParts_marker = (ListParts -> Maybe Text)
-> (ListParts -> Maybe Text -> ListParts)
-> Lens ListParts ListParts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListParts' {Maybe Text
marker :: Maybe Text
$sel:marker:ListParts' :: ListParts -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListParts
s@ListParts' {} Maybe Text
a -> ListParts
s {$sel:marker:ListParts' :: Maybe Text
marker = Maybe Text
a} :: ListParts)

-- | The maximum number of parts to be returned. The default limit is 50. The
-- number of parts returned might be fewer than the specified limit, but
-- the number of returned parts never exceeds the limit.
listParts_limit :: Lens.Lens' ListParts (Prelude.Maybe Prelude.Text)
listParts_limit :: (Maybe Text -> f (Maybe Text)) -> ListParts -> f ListParts
listParts_limit = (ListParts -> Maybe Text)
-> (ListParts -> Maybe Text -> ListParts)
-> Lens ListParts ListParts (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListParts' {Maybe Text
limit :: Maybe Text
$sel:limit:ListParts' :: ListParts -> Maybe Text
limit} -> Maybe Text
limit) (\s :: ListParts
s@ListParts' {} Maybe Text
a -> ListParts
s {$sel:limit:ListParts' :: Maybe Text
limit = Maybe Text
a} :: ListParts)

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

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

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

instance Core.AWSPager ListParts where
  page :: ListParts -> AWSResponse ListParts -> Maybe ListParts
page ListParts
rq AWSResponse ListParts
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListParts
ListPartsResponse
rs
            ListPartsResponse
-> Getting (First Text) ListPartsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPartsResponse -> Const (First Text) ListPartsResponse
Lens' ListPartsResponse (Maybe Text)
listPartsResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPartsResponse -> Const (First Text) ListPartsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPartsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListParts
forall a. Maybe a
Prelude.Nothing
    | Maybe [PartListElement] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListParts
ListPartsResponse
rs
            ListPartsResponse
-> Getting
     (First [PartListElement]) ListPartsResponse [PartListElement]
-> Maybe [PartListElement]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [PartListElement]
 -> Const (First [PartListElement]) (Maybe [PartListElement]))
-> ListPartsResponse
-> Const (First [PartListElement]) ListPartsResponse
Lens' ListPartsResponse (Maybe [PartListElement])
listPartsResponse_parts ((Maybe [PartListElement]
  -> Const (First [PartListElement]) (Maybe [PartListElement]))
 -> ListPartsResponse
 -> Const (First [PartListElement]) ListPartsResponse)
-> (([PartListElement]
     -> Const (First [PartListElement]) [PartListElement])
    -> Maybe [PartListElement]
    -> Const (First [PartListElement]) (Maybe [PartListElement]))
-> Getting
     (First [PartListElement]) ListPartsResponse [PartListElement]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PartListElement]
 -> Const (First [PartListElement]) [PartListElement])
-> Maybe [PartListElement]
-> Const (First [PartListElement]) (Maybe [PartListElement])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListParts
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListParts -> Maybe ListParts
forall a. a -> Maybe a
Prelude.Just (ListParts -> Maybe ListParts) -> ListParts -> Maybe ListParts
forall a b. (a -> b) -> a -> b
Prelude.$
        ListParts
rq
          ListParts -> (ListParts -> ListParts) -> ListParts
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListParts -> Identity ListParts
Lens ListParts ListParts (Maybe Text) (Maybe Text)
listParts_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> ListParts -> Identity ListParts)
-> Maybe Text -> ListParts -> ListParts
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListParts
ListPartsResponse
rs
          ListPartsResponse
-> Getting (First Text) ListPartsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPartsResponse -> Const (First Text) ListPartsResponse
Lens' ListPartsResponse (Maybe Text)
listPartsResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPartsResponse -> Const (First Text) ListPartsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPartsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListParts where
  type AWSResponse ListParts = ListPartsResponse
  request :: ListParts -> Request ListParts
request =
    ByteString -> Request ListParts -> Request ListParts
forall a. ByteString -> Request a -> Request a
Request.glacierVersionHeader (Service -> ByteString
Core._serviceVersion Service
defaultService)
      (Request ListParts -> Request ListParts)
-> (ListParts -> Request ListParts)
-> ListParts
-> Request ListParts
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Service -> ListParts -> Request ListParts
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListParts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListParts)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListParts))
-> Logger
-> Service
-> Proxy ListParts
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListParts)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [PartListElement]
-> Maybe Text
-> Maybe Integer
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> ListPartsResponse
ListPartsResponse'
            (Maybe [PartListElement]
 -> Maybe Text
 -> Maybe Integer
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> ListPartsResponse)
-> Either String (Maybe [PartListElement])
-> Either
     String
     (Maybe Text
      -> Maybe Integer
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> ListPartsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [PartListElement]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Parts" Either String (Maybe (Maybe [PartListElement]))
-> Maybe [PartListElement]
-> Either String (Maybe [PartListElement])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PartListElement]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe Text
   -> Maybe Integer
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> ListPartsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Integer
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> ListPartsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"MultipartUploadId")
            Either
  String
  (Maybe Integer
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> ListPartsResponse)
-> Either String (Maybe Integer)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> ListPartsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PartSizeInBytes")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> ListPartsResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Int -> ListPartsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ArchiveDescription")
            Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Int -> ListPartsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> ListPartsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"VaultARN")
            Either
  String (Maybe Text -> Maybe Text -> Int -> ListPartsResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> ListPartsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Marker")
            Either String (Maybe Text -> Int -> ListPartsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListPartsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CreationDate")
            Either String (Int -> ListPartsResponse)
-> Either String Int -> Either String ListPartsResponse
forall (f :: * -> *) a b. Applicative f => 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 ListParts

instance Prelude.NFData ListParts

instance Core.ToHeaders ListParts where
  toHeaders :: ListParts -> ResponseHeaders
toHeaders = ResponseHeaders -> ListParts -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ListParts where
  toPath :: ListParts -> ByteString
toPath ListParts' {Maybe Text
Text
uploadId :: Text
vaultName :: Text
accountId :: Text
limit :: Maybe Text
marker :: Maybe Text
$sel:uploadId:ListParts' :: ListParts -> Text
$sel:vaultName:ListParts' :: ListParts -> Text
$sel:accountId:ListParts' :: ListParts -> Text
$sel:limit:ListParts' :: ListParts -> Maybe Text
$sel:marker:ListParts' :: ListParts -> Maybe 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 ListParts where
  toQuery :: ListParts -> QueryString
toQuery ListParts' {Maybe Text
Text
uploadId :: Text
vaultName :: Text
accountId :: Text
limit :: Maybe Text
marker :: Maybe Text
$sel:uploadId:ListParts' :: ListParts -> Text
$sel:vaultName:ListParts' :: ListParts -> Text
$sel:accountId:ListParts' :: ListParts -> Text
$sel:limit:ListParts' :: ListParts -> Maybe Text
$sel:marker:ListParts' :: ListParts -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker, ByteString
"limit" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
limit]

-- | Contains the Amazon S3 Glacier response to your request.
--
-- /See:/ 'newListPartsResponse' smart constructor.
data ListPartsResponse = ListPartsResponse'
  { -- | A list of the part sizes of the multipart upload. Each object in the
    -- array contains a @RangeBytes@ and @sha256-tree-hash@ name\/value pair.
    ListPartsResponse -> Maybe [PartListElement]
parts :: Prelude.Maybe [PartListElement],
    -- | The ID of the upload to which the parts are associated.
    ListPartsResponse -> Maybe Text
multipartUploadId :: Prelude.Maybe Prelude.Text,
    -- | The part size in bytes. This is the same value that you specified in the
    -- Initiate Multipart Upload request.
    ListPartsResponse -> Maybe Integer
partSizeInBytes :: Prelude.Maybe Prelude.Integer,
    -- | The description of the archive that was specified in the Initiate
    -- Multipart Upload request.
    ListPartsResponse -> Maybe Text
archiveDescription :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the vault to which the multipart
    -- upload was initiated.
    ListPartsResponse -> Maybe Text
vaultARN :: Prelude.Maybe Prelude.Text,
    -- | An opaque string that represents where to continue pagination of the
    -- results. You use the marker in a new List Parts request to obtain more
    -- jobs in the list. If there are no more parts, this value is @null@.
    ListPartsResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The UTC time at which the multipart upload was initiated.
    ListPartsResponse -> Maybe Text
creationDate :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListPartsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPartsResponse -> ListPartsResponse -> Bool
(ListPartsResponse -> ListPartsResponse -> Bool)
-> (ListPartsResponse -> ListPartsResponse -> Bool)
-> Eq ListPartsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPartsResponse -> ListPartsResponse -> Bool
$c/= :: ListPartsResponse -> ListPartsResponse -> Bool
== :: ListPartsResponse -> ListPartsResponse -> Bool
$c== :: ListPartsResponse -> ListPartsResponse -> Bool
Prelude.Eq, ReadPrec [ListPartsResponse]
ReadPrec ListPartsResponse
Int -> ReadS ListPartsResponse
ReadS [ListPartsResponse]
(Int -> ReadS ListPartsResponse)
-> ReadS [ListPartsResponse]
-> ReadPrec ListPartsResponse
-> ReadPrec [ListPartsResponse]
-> Read ListPartsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPartsResponse]
$creadListPrec :: ReadPrec [ListPartsResponse]
readPrec :: ReadPrec ListPartsResponse
$creadPrec :: ReadPrec ListPartsResponse
readList :: ReadS [ListPartsResponse]
$creadList :: ReadS [ListPartsResponse]
readsPrec :: Int -> ReadS ListPartsResponse
$creadsPrec :: Int -> ReadS ListPartsResponse
Prelude.Read, Int -> ListPartsResponse -> ShowS
[ListPartsResponse] -> ShowS
ListPartsResponse -> String
(Int -> ListPartsResponse -> ShowS)
-> (ListPartsResponse -> String)
-> ([ListPartsResponse] -> ShowS)
-> Show ListPartsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPartsResponse] -> ShowS
$cshowList :: [ListPartsResponse] -> ShowS
show :: ListPartsResponse -> String
$cshow :: ListPartsResponse -> String
showsPrec :: Int -> ListPartsResponse -> ShowS
$cshowsPrec :: Int -> ListPartsResponse -> ShowS
Prelude.Show, (forall x. ListPartsResponse -> Rep ListPartsResponse x)
-> (forall x. Rep ListPartsResponse x -> ListPartsResponse)
-> Generic ListPartsResponse
forall x. Rep ListPartsResponse x -> ListPartsResponse
forall x. ListPartsResponse -> Rep ListPartsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPartsResponse x -> ListPartsResponse
$cfrom :: forall x. ListPartsResponse -> Rep ListPartsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPartsResponse' 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:
--
-- 'parts', 'listPartsResponse_parts' - A list of the part sizes of the multipart upload. Each object in the
-- array contains a @RangeBytes@ and @sha256-tree-hash@ name\/value pair.
--
-- 'multipartUploadId', 'listPartsResponse_multipartUploadId' - The ID of the upload to which the parts are associated.
--
-- 'partSizeInBytes', 'listPartsResponse_partSizeInBytes' - The part size in bytes. This is the same value that you specified in the
-- Initiate Multipart Upload request.
--
-- 'archiveDescription', 'listPartsResponse_archiveDescription' - The description of the archive that was specified in the Initiate
-- Multipart Upload request.
--
-- 'vaultARN', 'listPartsResponse_vaultARN' - The Amazon Resource Name (ARN) of the vault to which the multipart
-- upload was initiated.
--
-- 'marker', 'listPartsResponse_marker' - An opaque string that represents where to continue pagination of the
-- results. You use the marker in a new List Parts request to obtain more
-- jobs in the list. If there are no more parts, this value is @null@.
--
-- 'creationDate', 'listPartsResponse_creationDate' - The UTC time at which the multipart upload was initiated.
--
-- 'httpStatus', 'listPartsResponse_httpStatus' - The response's http status code.
newListPartsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPartsResponse
newListPartsResponse :: Int -> ListPartsResponse
newListPartsResponse Int
pHttpStatus_ =
  ListPartsResponse' :: Maybe [PartListElement]
-> Maybe Text
-> Maybe Integer
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> ListPartsResponse
ListPartsResponse'
    { $sel:parts:ListPartsResponse' :: Maybe [PartListElement]
parts = Maybe [PartListElement]
forall a. Maybe a
Prelude.Nothing,
      $sel:multipartUploadId:ListPartsResponse' :: Maybe Text
multipartUploadId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:partSizeInBytes:ListPartsResponse' :: Maybe Integer
partSizeInBytes = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:archiveDescription:ListPartsResponse' :: Maybe Text
archiveDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vaultARN:ListPartsResponse' :: Maybe Text
vaultARN = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:ListPartsResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:ListPartsResponse' :: Maybe Text
creationDate = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPartsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of the part sizes of the multipart upload. Each object in the
-- array contains a @RangeBytes@ and @sha256-tree-hash@ name\/value pair.
listPartsResponse_parts :: Lens.Lens' ListPartsResponse (Prelude.Maybe [PartListElement])
listPartsResponse_parts :: (Maybe [PartListElement] -> f (Maybe [PartListElement]))
-> ListPartsResponse -> f ListPartsResponse
listPartsResponse_parts = (ListPartsResponse -> Maybe [PartListElement])
-> (ListPartsResponse
    -> Maybe [PartListElement] -> ListPartsResponse)
-> Lens' ListPartsResponse (Maybe [PartListElement])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Maybe [PartListElement]
parts :: Maybe [PartListElement]
$sel:parts:ListPartsResponse' :: ListPartsResponse -> Maybe [PartListElement]
parts} -> Maybe [PartListElement]
parts) (\s :: ListPartsResponse
s@ListPartsResponse' {} Maybe [PartListElement]
a -> ListPartsResponse
s {$sel:parts:ListPartsResponse' :: Maybe [PartListElement]
parts = Maybe [PartListElement]
a} :: ListPartsResponse) ((Maybe [PartListElement] -> f (Maybe [PartListElement]))
 -> ListPartsResponse -> f ListPartsResponse)
-> ((Maybe [PartListElement] -> f (Maybe [PartListElement]))
    -> Maybe [PartListElement] -> f (Maybe [PartListElement]))
-> (Maybe [PartListElement] -> f (Maybe [PartListElement]))
-> ListPartsResponse
-> f ListPartsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PartListElement]
  [PartListElement]
  [PartListElement]
  [PartListElement]
-> Iso
     (Maybe [PartListElement])
     (Maybe [PartListElement])
     (Maybe [PartListElement])
     (Maybe [PartListElement])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [PartListElement]
  [PartListElement]
  [PartListElement]
  [PartListElement]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID of the upload to which the parts are associated.
listPartsResponse_multipartUploadId :: Lens.Lens' ListPartsResponse (Prelude.Maybe Prelude.Text)
listPartsResponse_multipartUploadId :: (Maybe Text -> f (Maybe Text))
-> ListPartsResponse -> f ListPartsResponse
listPartsResponse_multipartUploadId = (ListPartsResponse -> Maybe Text)
-> (ListPartsResponse -> Maybe Text -> ListPartsResponse)
-> Lens' ListPartsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Maybe Text
multipartUploadId :: Maybe Text
$sel:multipartUploadId:ListPartsResponse' :: ListPartsResponse -> Maybe Text
multipartUploadId} -> Maybe Text
multipartUploadId) (\s :: ListPartsResponse
s@ListPartsResponse' {} Maybe Text
a -> ListPartsResponse
s {$sel:multipartUploadId:ListPartsResponse' :: Maybe Text
multipartUploadId = Maybe Text
a} :: ListPartsResponse)

-- | The part size in bytes. This is the same value that you specified in the
-- Initiate Multipart Upload request.
listPartsResponse_partSizeInBytes :: Lens.Lens' ListPartsResponse (Prelude.Maybe Prelude.Integer)
listPartsResponse_partSizeInBytes :: (Maybe Integer -> f (Maybe Integer))
-> ListPartsResponse -> f ListPartsResponse
listPartsResponse_partSizeInBytes = (ListPartsResponse -> Maybe Integer)
-> (ListPartsResponse -> Maybe Integer -> ListPartsResponse)
-> Lens
     ListPartsResponse ListPartsResponse (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Maybe Integer
partSizeInBytes :: Maybe Integer
$sel:partSizeInBytes:ListPartsResponse' :: ListPartsResponse -> Maybe Integer
partSizeInBytes} -> Maybe Integer
partSizeInBytes) (\s :: ListPartsResponse
s@ListPartsResponse' {} Maybe Integer
a -> ListPartsResponse
s {$sel:partSizeInBytes:ListPartsResponse' :: Maybe Integer
partSizeInBytes = Maybe Integer
a} :: ListPartsResponse)

-- | The description of the archive that was specified in the Initiate
-- Multipart Upload request.
listPartsResponse_archiveDescription :: Lens.Lens' ListPartsResponse (Prelude.Maybe Prelude.Text)
listPartsResponse_archiveDescription :: (Maybe Text -> f (Maybe Text))
-> ListPartsResponse -> f ListPartsResponse
listPartsResponse_archiveDescription = (ListPartsResponse -> Maybe Text)
-> (ListPartsResponse -> Maybe Text -> ListPartsResponse)
-> Lens' ListPartsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Maybe Text
archiveDescription :: Maybe Text
$sel:archiveDescription:ListPartsResponse' :: ListPartsResponse -> Maybe Text
archiveDescription} -> Maybe Text
archiveDescription) (\s :: ListPartsResponse
s@ListPartsResponse' {} Maybe Text
a -> ListPartsResponse
s {$sel:archiveDescription:ListPartsResponse' :: Maybe Text
archiveDescription = Maybe Text
a} :: ListPartsResponse)

-- | The Amazon Resource Name (ARN) of the vault to which the multipart
-- upload was initiated.
listPartsResponse_vaultARN :: Lens.Lens' ListPartsResponse (Prelude.Maybe Prelude.Text)
listPartsResponse_vaultARN :: (Maybe Text -> f (Maybe Text))
-> ListPartsResponse -> f ListPartsResponse
listPartsResponse_vaultARN = (ListPartsResponse -> Maybe Text)
-> (ListPartsResponse -> Maybe Text -> ListPartsResponse)
-> Lens' ListPartsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Maybe Text
vaultARN :: Maybe Text
$sel:vaultARN:ListPartsResponse' :: ListPartsResponse -> Maybe Text
vaultARN} -> Maybe Text
vaultARN) (\s :: ListPartsResponse
s@ListPartsResponse' {} Maybe Text
a -> ListPartsResponse
s {$sel:vaultARN:ListPartsResponse' :: Maybe Text
vaultARN = Maybe Text
a} :: ListPartsResponse)

-- | An opaque string that represents where to continue pagination of the
-- results. You use the marker in a new List Parts request to obtain more
-- jobs in the list. If there are no more parts, this value is @null@.
listPartsResponse_marker :: Lens.Lens' ListPartsResponse (Prelude.Maybe Prelude.Text)
listPartsResponse_marker :: (Maybe Text -> f (Maybe Text))
-> ListPartsResponse -> f ListPartsResponse
listPartsResponse_marker = (ListPartsResponse -> Maybe Text)
-> (ListPartsResponse -> Maybe Text -> ListPartsResponse)
-> Lens' ListPartsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPartsResponse' :: ListPartsResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListPartsResponse
s@ListPartsResponse' {} Maybe Text
a -> ListPartsResponse
s {$sel:marker:ListPartsResponse' :: Maybe Text
marker = Maybe Text
a} :: ListPartsResponse)

-- | The UTC time at which the multipart upload was initiated.
listPartsResponse_creationDate :: Lens.Lens' ListPartsResponse (Prelude.Maybe Prelude.Text)
listPartsResponse_creationDate :: (Maybe Text -> f (Maybe Text))
-> ListPartsResponse -> f ListPartsResponse
listPartsResponse_creationDate = (ListPartsResponse -> Maybe Text)
-> (ListPartsResponse -> Maybe Text -> ListPartsResponse)
-> Lens' ListPartsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Maybe Text
creationDate :: Maybe Text
$sel:creationDate:ListPartsResponse' :: ListPartsResponse -> Maybe Text
creationDate} -> Maybe Text
creationDate) (\s :: ListPartsResponse
s@ListPartsResponse' {} Maybe Text
a -> ListPartsResponse
s {$sel:creationDate:ListPartsResponse' :: Maybe Text
creationDate = Maybe Text
a} :: ListPartsResponse)

-- | The response's http status code.
listPartsResponse_httpStatus :: Lens.Lens' ListPartsResponse Prelude.Int
listPartsResponse_httpStatus :: (Int -> f Int) -> ListPartsResponse -> f ListPartsResponse
listPartsResponse_httpStatus = (ListPartsResponse -> Int)
-> (ListPartsResponse -> Int -> ListPartsResponse)
-> Lens ListPartsResponse ListPartsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListPartsResponse' :: ListPartsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListPartsResponse
s@ListPartsResponse' {} Int
a -> ListPartsResponse
s {$sel:httpStatus:ListPartsResponse' :: Int
httpStatus = Int
a} :: ListPartsResponse)

instance Prelude.NFData ListPartsResponse