{-# 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-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)
module Amazonka.S3.Types.Part where

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

-- | Container for elements related to a part.
--
-- /See:/ 'newPart' smart constructor.
data Part = Part'
  { -- | Entity tag returned when the part was uploaded.
    Part -> Maybe ETag
eTag :: Prelude.Maybe ETag,
    -- | Size in bytes of the uploaded part data.
    Part -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer,
    -- | Part number identifying the part. This is a positive integer between 1
    -- and 10,000.
    Part -> Maybe Int
partNumber :: Prelude.Maybe Prelude.Int,
    -- | Date and time at which the part was uploaded.
    Part -> Maybe ISO8601
lastModified :: Prelude.Maybe Core.ISO8601
  }
  deriving (Part -> Part -> Bool
(Part -> Part -> Bool) -> (Part -> Part -> Bool) -> Eq Part
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]
(Int -> ReadS Part)
-> ReadS [Part] -> ReadPrec Part -> ReadPrec [Part] -> Read 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
(Int -> Part -> ShowS)
-> (Part -> String) -> ([Part] -> ShowS) -> Show Part
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. Part -> Rep Part x)
-> (forall x. Rep Part x -> Part) -> Generic Part
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:
--
-- 'eTag', 'part_eTag' - Entity tag returned when the part was uploaded.
--
-- 'size', 'part_size' - Size in bytes of the uploaded part data.
--
-- 'partNumber', 'part_partNumber' - Part number identifying the part. This is a positive integer between 1
-- and 10,000.
--
-- 'lastModified', 'part_lastModified' - Date and time at which the part was uploaded.
newPart ::
  Part
newPart :: Part
newPart =
  Part' :: Maybe ETag -> Maybe Integer -> Maybe Int -> Maybe ISO8601 -> Part
Part'
    { $sel:eTag:Part' :: Maybe ETag
eTag = Maybe ETag
forall a. Maybe a
Prelude.Nothing,
      $sel:size:Part' :: Maybe Integer
size = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:partNumber:Part' :: Maybe Int
partNumber = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModified:Part' :: Maybe ISO8601
lastModified = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | Entity tag returned when the part was uploaded.
part_eTag :: Lens.Lens' Part (Prelude.Maybe ETag)
part_eTag :: (Maybe ETag -> f (Maybe ETag)) -> Part -> f Part
part_eTag = (Part -> Maybe ETag)
-> (Part -> Maybe ETag -> Part)
-> Lens Part Part (Maybe ETag) (Maybe 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)

-- | Size in bytes of the uploaded part data.
part_size :: Lens.Lens' Part (Prelude.Maybe Prelude.Integer)
part_size :: (Maybe Integer -> f (Maybe Integer)) -> Part -> f Part
part_size = (Part -> Maybe Integer)
-> (Part -> Maybe Integer -> Part)
-> Lens Part Part (Maybe Integer) (Maybe Integer)
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)

-- | 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 :: (Maybe Int -> f (Maybe Int)) -> Part -> f Part
part_partNumber = (Part -> Maybe Int)
-> (Part -> Maybe Int -> Part)
-> Lens Part Part (Maybe Int) (Maybe Int)
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)

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

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

instance Prelude.Hashable Part

instance Prelude.NFData Part