{-# 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.ObjectPart
-- 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.ObjectPart 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

-- | A container for elements related to an individual part.
--
-- /See:/ 'newObjectPart' smart constructor.
data ObjectPart = ObjectPart'
  { -- | 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/.
    ObjectPart -> 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/.
    ObjectPart -> 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/.
    ObjectPart -> Maybe Text
checksumSHA1 :: Prelude.Maybe Prelude.Text,
    -- | The base64-encoded, 256-bit SHA-256 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/.
    ObjectPart -> Maybe Text
checksumSHA256 :: Prelude.Maybe Prelude.Text,
    -- | The part number identifying the part. This value is a positive integer
    -- between 1 and 10,000.
    ObjectPart -> Maybe Int
partNumber :: Prelude.Maybe Prelude.Int,
    -- | The size of the uploaded part in bytes.
    ObjectPart -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer
  }
  deriving (ObjectPart -> ObjectPart -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectPart -> ObjectPart -> Bool
$c/= :: ObjectPart -> ObjectPart -> Bool
== :: ObjectPart -> ObjectPart -> Bool
$c== :: ObjectPart -> ObjectPart -> Bool
Prelude.Eq, ReadPrec [ObjectPart]
ReadPrec ObjectPart
Int -> ReadS ObjectPart
ReadS [ObjectPart]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ObjectPart]
$creadListPrec :: ReadPrec [ObjectPart]
readPrec :: ReadPrec ObjectPart
$creadPrec :: ReadPrec ObjectPart
readList :: ReadS [ObjectPart]
$creadList :: ReadS [ObjectPart]
readsPrec :: Int -> ReadS ObjectPart
$creadsPrec :: Int -> ReadS ObjectPart
Prelude.Read, Int -> ObjectPart -> ShowS
[ObjectPart] -> ShowS
ObjectPart -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectPart] -> ShowS
$cshowList :: [ObjectPart] -> ShowS
show :: ObjectPart -> String
$cshow :: ObjectPart -> String
showsPrec :: Int -> ObjectPart -> ShowS
$cshowsPrec :: Int -> ObjectPart -> ShowS
Prelude.Show, forall x. Rep ObjectPart x -> ObjectPart
forall x. ObjectPart -> Rep ObjectPart x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ObjectPart x -> ObjectPart
$cfrom :: forall x. ObjectPart -> Rep ObjectPart x
Prelude.Generic)

-- |
-- Create a value of 'ObjectPart' 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', 'objectPart_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', 'objectPart_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', 'objectPart_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', 'objectPart_checksumSHA256' - The base64-encoded, 256-bit SHA-256 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/.
--
-- 'partNumber', 'objectPart_partNumber' - The part number identifying the part. This value is a positive integer
-- between 1 and 10,000.
--
-- 'size', 'objectPart_size' - The size of the uploaded part in bytes.
newObjectPart ::
  ObjectPart
newObjectPart :: ObjectPart
newObjectPart =
  ObjectPart'
    { $sel:checksumCRC32:ObjectPart' :: Maybe Text
checksumCRC32 = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumCRC32C:ObjectPart' :: Maybe Text
checksumCRC32C = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumSHA1:ObjectPart' :: Maybe Text
checksumSHA1 = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumSHA256:ObjectPart' :: Maybe Text
checksumSHA256 = forall a. Maybe a
Prelude.Nothing,
      $sel:partNumber:ObjectPart' :: Maybe Int
partNumber = forall a. Maybe a
Prelude.Nothing,
      $sel:size:ObjectPart' :: 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/.
objectPart_checksumCRC32 :: Lens.Lens' ObjectPart (Prelude.Maybe Prelude.Text)
objectPart_checksumCRC32 :: Lens' ObjectPart (Maybe Text)
objectPart_checksumCRC32 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectPart' {Maybe Text
checksumCRC32 :: Maybe Text
$sel:checksumCRC32:ObjectPart' :: ObjectPart -> Maybe Text
checksumCRC32} -> Maybe Text
checksumCRC32) (\s :: ObjectPart
s@ObjectPart' {} Maybe Text
a -> ObjectPart
s {$sel:checksumCRC32:ObjectPart' :: Maybe Text
checksumCRC32 = Maybe Text
a} :: ObjectPart)

-- | 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/.
objectPart_checksumCRC32C :: Lens.Lens' ObjectPart (Prelude.Maybe Prelude.Text)
objectPart_checksumCRC32C :: Lens' ObjectPart (Maybe Text)
objectPart_checksumCRC32C = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectPart' {Maybe Text
checksumCRC32C :: Maybe Text
$sel:checksumCRC32C:ObjectPart' :: ObjectPart -> Maybe Text
checksumCRC32C} -> Maybe Text
checksumCRC32C) (\s :: ObjectPart
s@ObjectPart' {} Maybe Text
a -> ObjectPart
s {$sel:checksumCRC32C:ObjectPart' :: Maybe Text
checksumCRC32C = Maybe Text
a} :: ObjectPart)

-- | 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/.
objectPart_checksumSHA1 :: Lens.Lens' ObjectPart (Prelude.Maybe Prelude.Text)
objectPart_checksumSHA1 :: Lens' ObjectPart (Maybe Text)
objectPart_checksumSHA1 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectPart' {Maybe Text
checksumSHA1 :: Maybe Text
$sel:checksumSHA1:ObjectPart' :: ObjectPart -> Maybe Text
checksumSHA1} -> Maybe Text
checksumSHA1) (\s :: ObjectPart
s@ObjectPart' {} Maybe Text
a -> ObjectPart
s {$sel:checksumSHA1:ObjectPart' :: Maybe Text
checksumSHA1 = Maybe Text
a} :: ObjectPart)

-- | The base64-encoded, 256-bit SHA-256 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/.
objectPart_checksumSHA256 :: Lens.Lens' ObjectPart (Prelude.Maybe Prelude.Text)
objectPart_checksumSHA256 :: Lens' ObjectPart (Maybe Text)
objectPart_checksumSHA256 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectPart' {Maybe Text
checksumSHA256 :: Maybe Text
$sel:checksumSHA256:ObjectPart' :: ObjectPart -> Maybe Text
checksumSHA256} -> Maybe Text
checksumSHA256) (\s :: ObjectPart
s@ObjectPart' {} Maybe Text
a -> ObjectPart
s {$sel:checksumSHA256:ObjectPart' :: Maybe Text
checksumSHA256 = Maybe Text
a} :: ObjectPart)

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

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

instance Data.FromXML ObjectPart where
  parseXML :: [Node] -> Either String ObjectPart
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> Maybe Integer
-> ObjectPart
ObjectPart'
      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
"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 ObjectPart where
  hashWithSalt :: Int -> ObjectPart -> Int
hashWithSalt Int
_salt ObjectPart' {Maybe Int
Maybe Integer
Maybe Text
size :: Maybe Integer
partNumber :: Maybe Int
checksumSHA256 :: Maybe Text
checksumSHA1 :: Maybe Text
checksumCRC32C :: Maybe Text
checksumCRC32 :: Maybe Text
$sel:size:ObjectPart' :: ObjectPart -> Maybe Integer
$sel:partNumber:ObjectPart' :: ObjectPart -> Maybe Int
$sel:checksumSHA256:ObjectPart' :: ObjectPart -> Maybe Text
$sel:checksumSHA1:ObjectPart' :: ObjectPart -> Maybe Text
$sel:checksumCRC32C:ObjectPart' :: ObjectPart -> Maybe Text
$sel:checksumCRC32:ObjectPart' :: ObjectPart -> 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 Int
partNumber
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
size

instance Prelude.NFData ObjectPart where
  rnf :: ObjectPart -> ()
rnf ObjectPart' {Maybe Int
Maybe Integer
Maybe Text
size :: Maybe Integer
partNumber :: Maybe Int
checksumSHA256 :: Maybe Text
checksumSHA1 :: Maybe Text
checksumCRC32C :: Maybe Text
checksumCRC32 :: Maybe Text
$sel:size:ObjectPart' :: ObjectPart -> Maybe Integer
$sel:partNumber:ObjectPart' :: ObjectPart -> Maybe Int
$sel:checksumSHA256:ObjectPart' :: ObjectPart -> Maybe Text
$sel:checksumSHA1:ObjectPart' :: ObjectPart -> Maybe Text
$sel:checksumCRC32C:ObjectPart' :: ObjectPart -> Maybe Text
$sel:checksumCRC32:ObjectPart' :: ObjectPart -> 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 Int
partNumber
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
size