{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.S3.Types.Part
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.S3.Types.Part where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal

-- | Container for elements related to a part.
--
-- /See:/ 'newPart' smart constructor.
data Part = Part'
  { -- | This header can be used as a data integrity check to verify that the
    -- data received is the same data that was originally sent. This header
    -- specifies the base64-encoded, 32-bit CRC32 checksum of the object. For
    -- more information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html Checking object integrity>
    -- in the /Amazon S3 User Guide/.
    Part -> Maybe Text
checksumCRC32 :: Prelude.Maybe Prelude.Text,
    -- | The base64-encoded, 32-bit CRC32C checksum of the object. This will only
    -- be present if it was uploaded with the object. With multipart uploads,
    -- this may not be a checksum value of the object. For more information
    -- about how checksums are calculated with multipart uploads, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums Checking object integrity>
    -- in the /Amazon S3 User Guide/.
    Part -> Maybe Text
checksumCRC32C :: Prelude.Maybe Prelude.Text,
    -- | The base64-encoded, 160-bit SHA-1 digest of the object. This will only
    -- be present if it was uploaded with the object. With multipart uploads,
    -- this may not be a checksum value of the object. For more information
    -- about how checksums are calculated with multipart uploads, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums Checking object integrity>
    -- in the /Amazon S3 User Guide/.
    Part -> Maybe Text
checksumSHA1 :: Prelude.Maybe Prelude.Text,
    -- | This header can be used as a data integrity check to verify that the
    -- data received is the same data that was originally sent. This header
    -- specifies the base64-encoded, 256-bit SHA-256 digest of the object. For
    -- more information, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html Checking object integrity>
    -- in the /Amazon S3 User Guide/.
    Part -> Maybe Text
checksumSHA256 :: Prelude.Maybe Prelude.Text,
    -- | Entity tag returned when the part was uploaded.
    Part -> Maybe ETag
eTag :: Prelude.Maybe ETag,
    -- | Date and time at which the part was uploaded.
    Part -> Maybe RFC822
lastModified :: Prelude.Maybe Data.RFC822,
    -- | Part number identifying the part. This is a positive integer between 1
    -- and 10,000.
    Part -> Maybe Int
partNumber :: Prelude.Maybe Prelude.Int,
    -- | Size in bytes of the uploaded part data.
    Part -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer
  }
  deriving (Part -> Part -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Part -> Part -> Bool
$c/= :: Part -> Part -> Bool
== :: Part -> Part -> Bool
$c== :: Part -> Part -> Bool
Prelude.Eq, ReadPrec [Part]
ReadPrec Part
Int -> ReadS Part
ReadS [Part]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Part]
$creadListPrec :: ReadPrec [Part]
readPrec :: ReadPrec Part
$creadPrec :: ReadPrec Part
readList :: ReadS [Part]
$creadList :: ReadS [Part]
readsPrec :: Int -> ReadS Part
$creadsPrec :: Int -> ReadS Part
Prelude.Read, Int -> Part -> ShowS
[Part] -> ShowS
Part -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Part] -> ShowS
$cshowList :: [Part] -> ShowS
show :: Part -> String
$cshow :: Part -> String
showsPrec :: Int -> Part -> ShowS
$cshowsPrec :: Int -> Part -> ShowS
Prelude.Show, forall x. Rep Part x -> Part
forall x. Part -> Rep Part x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Part x -> Part
$cfrom :: forall x. Part -> Rep Part x
Prelude.Generic)

-- |
-- Create a value of 'Part' 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:
--
-- 'checksumCRC32', 'part_checksumCRC32' - This header can be used as a data integrity check to verify that the
-- data received is the same data that was originally sent. This header
-- specifies the base64-encoded, 32-bit CRC32 checksum of the object. For
-- more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html Checking object integrity>
-- in the /Amazon S3 User Guide/.
--
-- 'checksumCRC32C', 'part_checksumCRC32C' - The base64-encoded, 32-bit CRC32C checksum of the object. This will only
-- be present if it was uploaded with the object. With multipart uploads,
-- this may not be a checksum value of the object. For more information
-- about how checksums are calculated with multipart uploads, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums Checking object integrity>
-- in the /Amazon S3 User Guide/.
--
-- 'checksumSHA1', 'part_checksumSHA1' - The base64-encoded, 160-bit SHA-1 digest of the object. This will only
-- be present if it was uploaded with the object. With multipart uploads,
-- this may not be a checksum value of the object. For more information
-- about how checksums are calculated with multipart uploads, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums Checking object integrity>
-- in the /Amazon S3 User Guide/.
--
-- 'checksumSHA256', 'part_checksumSHA256' - This header can be used as a data integrity check to verify that the
-- data received is the same data that was originally sent. This header
-- specifies the base64-encoded, 256-bit SHA-256 digest of the object. For
-- more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html Checking object integrity>
-- in the /Amazon S3 User Guide/.
--
-- 'eTag', 'part_eTag' - Entity tag returned when the part was uploaded.
--
-- 'lastModified', 'part_lastModified' - Date and time at which the part was uploaded.
--
-- 'partNumber', 'part_partNumber' - Part number identifying the part. This is a positive integer between 1
-- and 10,000.
--
-- 'size', 'part_size' - Size in bytes of the uploaded part data.
newPart ::
  Part
newPart :: Part
newPart =
  Part'
    { $sel:checksumCRC32:Part' :: Maybe Text
checksumCRC32 = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumCRC32C:Part' :: Maybe Text
checksumCRC32C = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumSHA1:Part' :: Maybe Text
checksumSHA1 = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumSHA256:Part' :: Maybe Text
checksumSHA256 = forall a. Maybe a
Prelude.Nothing,
      $sel:eTag:Part' :: Maybe ETag
eTag = forall a. Maybe a
Prelude.Nothing,
      $sel:lastModified:Part' :: Maybe RFC822
lastModified = forall a. Maybe a
Prelude.Nothing,
      $sel:partNumber:Part' :: Maybe Int
partNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:size:Part' :: Maybe Integer
size = forall a. Maybe a
Prelude.Nothing
    }

-- | This header can be used as a data integrity check to verify that the
-- data received is the same data that was originally sent. This header
-- specifies the base64-encoded, 32-bit CRC32 checksum of the object. For
-- more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html Checking object integrity>
-- in the /Amazon S3 User Guide/.
part_checksumCRC32 :: Lens.Lens' Part (Prelude.Maybe Prelude.Text)
part_checksumCRC32 :: Lens' Part (Maybe Text)
part_checksumCRC32 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe Text
checksumCRC32 :: Maybe Text
$sel:checksumCRC32:Part' :: Part -> Maybe Text
checksumCRC32} -> Maybe Text
checksumCRC32) (\s :: Part
s@Part' {} Maybe Text
a -> Part
s {$sel:checksumCRC32:Part' :: Maybe Text
checksumCRC32 = Maybe Text
a} :: Part)

-- | The base64-encoded, 32-bit CRC32C checksum of the object. This will only
-- be present if it was uploaded with the object. With multipart uploads,
-- this may not be a checksum value of the object. For more information
-- about how checksums are calculated with multipart uploads, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums Checking object integrity>
-- in the /Amazon S3 User Guide/.
part_checksumCRC32C :: Lens.Lens' Part (Prelude.Maybe Prelude.Text)
part_checksumCRC32C :: Lens' Part (Maybe Text)
part_checksumCRC32C = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe Text
checksumCRC32C :: Maybe Text
$sel:checksumCRC32C:Part' :: Part -> Maybe Text
checksumCRC32C} -> Maybe Text
checksumCRC32C) (\s :: Part
s@Part' {} Maybe Text
a -> Part
s {$sel:checksumCRC32C:Part' :: Maybe Text
checksumCRC32C = Maybe Text
a} :: Part)

-- | The base64-encoded, 160-bit SHA-1 digest of the object. This will only
-- be present if it was uploaded with the object. With multipart uploads,
-- this may not be a checksum value of the object. For more information
-- about how checksums are calculated with multipart uploads, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html#large-object-checksums Checking object integrity>
-- in the /Amazon S3 User Guide/.
part_checksumSHA1 :: Lens.Lens' Part (Prelude.Maybe Prelude.Text)
part_checksumSHA1 :: Lens' Part (Maybe Text)
part_checksumSHA1 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe Text
checksumSHA1 :: Maybe Text
$sel:checksumSHA1:Part' :: Part -> Maybe Text
checksumSHA1} -> Maybe Text
checksumSHA1) (\s :: Part
s@Part' {} Maybe Text
a -> Part
s {$sel:checksumSHA1:Part' :: Maybe Text
checksumSHA1 = Maybe Text
a} :: Part)

-- | This header can be used as a data integrity check to verify that the
-- data received is the same data that was originally sent. This header
-- specifies the base64-encoded, 256-bit SHA-256 digest of the object. For
-- more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/checking-object-integrity.html Checking object integrity>
-- in the /Amazon S3 User Guide/.
part_checksumSHA256 :: Lens.Lens' Part (Prelude.Maybe Prelude.Text)
part_checksumSHA256 :: Lens' Part (Maybe Text)
part_checksumSHA256 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe Text
checksumSHA256 :: Maybe Text
$sel:checksumSHA256:Part' :: Part -> Maybe Text
checksumSHA256} -> Maybe Text
checksumSHA256) (\s :: Part
s@Part' {} Maybe Text
a -> Part
s {$sel:checksumSHA256:Part' :: Maybe Text
checksumSHA256 = Maybe Text
a} :: Part)

-- | Entity tag returned when the part was uploaded.
part_eTag :: Lens.Lens' Part (Prelude.Maybe ETag)
part_eTag :: Lens' Part (Maybe ETag)
part_eTag = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe ETag
eTag :: Maybe ETag
$sel:eTag:Part' :: Part -> Maybe ETag
eTag} -> Maybe ETag
eTag) (\s :: Part
s@Part' {} Maybe ETag
a -> Part
s {$sel:eTag:Part' :: Maybe ETag
eTag = Maybe ETag
a} :: Part)

-- | Date and time at which the part was uploaded.
part_lastModified :: Lens.Lens' Part (Prelude.Maybe Prelude.UTCTime)
part_lastModified :: Lens' Part (Maybe UTCTime)
part_lastModified = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe RFC822
lastModified :: Maybe RFC822
$sel:lastModified:Part' :: Part -> Maybe RFC822
lastModified} -> Maybe RFC822
lastModified) (\s :: Part
s@Part' {} Maybe RFC822
a -> Part
s {$sel:lastModified:Part' :: Maybe RFC822
lastModified = Maybe RFC822
a} :: Part) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | Part number identifying the part. This is a positive integer between 1
-- and 10,000.
part_partNumber :: Lens.Lens' Part (Prelude.Maybe Prelude.Int)
part_partNumber :: Lens' Part (Maybe Int)
part_partNumber = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe Int
partNumber :: Maybe Int
$sel:partNumber:Part' :: Part -> Maybe Int
partNumber} -> Maybe Int
partNumber) (\s :: Part
s@Part' {} Maybe Int
a -> Part
s {$sel:partNumber:Part' :: Maybe Int
partNumber = Maybe Int
a} :: Part)

-- | Size in bytes of the uploaded part data.
part_size :: Lens.Lens' Part (Prelude.Maybe Prelude.Integer)
part_size :: Lens' Part (Maybe Integer)
part_size = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Part' {Maybe Integer
size :: Maybe Integer
$sel:size:Part' :: Part -> Maybe Integer
size} -> Maybe Integer
size) (\s :: Part
s@Part' {} Maybe Integer
a -> Part
s {$sel:size:Part' :: Maybe Integer
size = Maybe Integer
a} :: Part)

instance Data.FromXML Part where
  parseXML :: [Node] -> Either String Part
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ETag
-> Maybe RFC822
-> Maybe Int
-> Maybe Integer
-> Part
Part'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ChecksumCRC32")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ChecksumCRC32C")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ChecksumSHA1")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ChecksumSHA256")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ETag")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"LastModified")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"PartNumber")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Size")

instance Prelude.Hashable Part where
  hashWithSalt :: Int -> Part -> Int
hashWithSalt Int
_salt Part' {Maybe Int
Maybe Integer
Maybe Text
Maybe RFC822
Maybe ETag
size :: Maybe Integer
partNumber :: Maybe Int
lastModified :: Maybe RFC822
eTag :: Maybe ETag
checksumSHA256 :: Maybe Text
checksumSHA1 :: Maybe Text
checksumCRC32C :: Maybe Text
checksumCRC32 :: Maybe Text
$sel:size:Part' :: Part -> Maybe Integer
$sel:partNumber:Part' :: Part -> Maybe Int
$sel:lastModified:Part' :: Part -> Maybe RFC822
$sel:eTag:Part' :: Part -> Maybe ETag
$sel:checksumSHA256:Part' :: Part -> Maybe Text
$sel:checksumSHA1:Part' :: Part -> Maybe Text
$sel:checksumCRC32C:Part' :: Part -> Maybe Text
$sel:checksumCRC32:Part' :: Part -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
checksumCRC32
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
checksumCRC32C
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
checksumSHA1
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
checksumSHA256
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ETag
eTag
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RFC822
lastModified
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
partNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
size

instance Prelude.NFData Part where
  rnf :: Part -> ()
rnf Part' {Maybe Int
Maybe Integer
Maybe Text
Maybe RFC822
Maybe ETag
size :: Maybe Integer
partNumber :: Maybe Int
lastModified :: Maybe RFC822
eTag :: Maybe ETag
checksumSHA256 :: Maybe Text
checksumSHA1 :: Maybe Text
checksumCRC32C :: Maybe Text
checksumCRC32 :: Maybe Text
$sel:size:Part' :: Part -> Maybe Integer
$sel:partNumber:Part' :: Part -> Maybe Int
$sel:lastModified:Part' :: Part -> Maybe RFC822
$sel:eTag:Part' :: Part -> Maybe ETag
$sel:checksumSHA256:Part' :: Part -> Maybe Text
$sel:checksumSHA1:Part' :: Part -> Maybe Text
$sel:checksumCRC32C:Part' :: Part -> Maybe Text
$sel:checksumCRC32:Part' :: Part -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
checksumCRC32
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
checksumCRC32C
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
checksumSHA1
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
checksumSHA256
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ETag
eTag
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RFC822
lastModified
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
partNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
size