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

-- | Contains all the possible checksum or digest values for an object.
--
-- /See:/ 'newChecksum' smart constructor.
data Checksum = Checksum'
  { -- | The base64-encoded, 32-bit CRC32 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/.
    Checksum -> 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/.
    Checksum -> 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/.
    Checksum -> 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/.
    Checksum -> Maybe Text
checksumSHA256 :: Prelude.Maybe Prelude.Text
  }
  deriving (Checksum -> Checksum -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Checksum -> Checksum -> Bool
$c/= :: Checksum -> Checksum -> Bool
== :: Checksum -> Checksum -> Bool
$c== :: Checksum -> Checksum -> Bool
Prelude.Eq, ReadPrec [Checksum]
ReadPrec Checksum
Int -> ReadS Checksum
ReadS [Checksum]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Checksum]
$creadListPrec :: ReadPrec [Checksum]
readPrec :: ReadPrec Checksum
$creadPrec :: ReadPrec Checksum
readList :: ReadS [Checksum]
$creadList :: ReadS [Checksum]
readsPrec :: Int -> ReadS Checksum
$creadsPrec :: Int -> ReadS Checksum
Prelude.Read, Int -> Checksum -> ShowS
[Checksum] -> ShowS
Checksum -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Checksum] -> ShowS
$cshowList :: [Checksum] -> ShowS
show :: Checksum -> String
$cshow :: Checksum -> String
showsPrec :: Int -> Checksum -> ShowS
$cshowsPrec :: Int -> Checksum -> ShowS
Prelude.Show, forall x. Rep Checksum x -> Checksum
forall x. Checksum -> Rep Checksum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Checksum x -> Checksum
$cfrom :: forall x. Checksum -> Rep Checksum x
Prelude.Generic)

-- |
-- Create a value of 'Checksum' 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', 'checksum_checksumCRC32' - The base64-encoded, 32-bit CRC32 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/.
--
-- 'checksumCRC32C', 'checksum_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', 'checksum_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', 'checksum_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/.
newChecksum ::
  Checksum
newChecksum :: Checksum
newChecksum =
  Checksum'
    { $sel:checksumCRC32:Checksum' :: Maybe Text
checksumCRC32 = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumCRC32C:Checksum' :: Maybe Text
checksumCRC32C = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumSHA1:Checksum' :: Maybe Text
checksumSHA1 = forall a. Maybe a
Prelude.Nothing,
      $sel:checksumSHA256:Checksum' :: Maybe Text
checksumSHA256 = forall a. Maybe a
Prelude.Nothing
    }

-- | The base64-encoded, 32-bit CRC32 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/.
checksum_checksumCRC32 :: Lens.Lens' Checksum (Prelude.Maybe Prelude.Text)
checksum_checksumCRC32 :: Lens' Checksum (Maybe Text)
checksum_checksumCRC32 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Checksum' {Maybe Text
checksumCRC32 :: Maybe Text
$sel:checksumCRC32:Checksum' :: Checksum -> Maybe Text
checksumCRC32} -> Maybe Text
checksumCRC32) (\s :: Checksum
s@Checksum' {} Maybe Text
a -> Checksum
s {$sel:checksumCRC32:Checksum' :: Maybe Text
checksumCRC32 = Maybe Text
a} :: Checksum)

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

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

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

instance Data.FromXML Checksum where
  parseXML :: [Node] -> Either String Checksum
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Checksum
Checksum'
      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")

instance Prelude.Hashable Checksum where
  hashWithSalt :: Int -> Checksum -> Int
hashWithSalt Int
_salt Checksum' {Maybe Text
checksumSHA256 :: Maybe Text
checksumSHA1 :: Maybe Text
checksumCRC32C :: Maybe Text
checksumCRC32 :: Maybe Text
$sel:checksumSHA256:Checksum' :: Checksum -> Maybe Text
$sel:checksumSHA1:Checksum' :: Checksum -> Maybe Text
$sel:checksumCRC32C:Checksum' :: Checksum -> Maybe Text
$sel:checksumCRC32:Checksum' :: Checksum -> 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

instance Prelude.NFData Checksum where
  rnf :: Checksum -> ()
rnf Checksum' {Maybe Text
checksumSHA256 :: Maybe Text
checksumSHA1 :: Maybe Text
checksumCRC32C :: Maybe Text
checksumCRC32 :: Maybe Text
$sel:checksumSHA256:Checksum' :: Checksum -> Maybe Text
$sel:checksumSHA1:Checksum' :: Checksum -> Maybe Text
$sel:checksumCRC32C:Checksum' :: Checksum -> Maybe Text
$sel:checksumCRC32:Checksum' :: Checksum -> 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