{-# 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.MultipartUpload
-- 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.MultipartUpload where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.Initiator
import Amazonka.S3.Types.Owner
import Amazonka.S3.Types.StorageClass

-- | Container for the @MultipartUpload@ for the Amazon S3 object.
--
-- /See:/ 'newMultipartUpload' smart constructor.
data MultipartUpload = MultipartUpload'
  { -- | Date and time at which the multipart upload was initiated.
    MultipartUpload -> Maybe ISO8601
initiated :: Prelude.Maybe Core.ISO8601,
    -- | Identifies who initiated the multipart upload.
    MultipartUpload -> Maybe Initiator
initiator :: Prelude.Maybe Initiator,
    -- | Specifies the owner of the object that is part of the multipart upload.
    MultipartUpload -> Maybe Owner
owner :: Prelude.Maybe Owner,
    -- | Key of the object for which the multipart upload was initiated.
    MultipartUpload -> Maybe ObjectKey
key :: Prelude.Maybe ObjectKey,
    -- | The class of storage used to store the object.
    MultipartUpload -> Maybe StorageClass
storageClass :: Prelude.Maybe StorageClass,
    -- | Upload ID that identifies the multipart upload.
    MultipartUpload -> Maybe Text
uploadId :: Prelude.Maybe Prelude.Text
  }
  deriving (MultipartUpload -> MultipartUpload -> Bool
(MultipartUpload -> MultipartUpload -> Bool)
-> (MultipartUpload -> MultipartUpload -> Bool)
-> Eq MultipartUpload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MultipartUpload -> MultipartUpload -> Bool
$c/= :: MultipartUpload -> MultipartUpload -> Bool
== :: MultipartUpload -> MultipartUpload -> Bool
$c== :: MultipartUpload -> MultipartUpload -> Bool
Prelude.Eq, ReadPrec [MultipartUpload]
ReadPrec MultipartUpload
Int -> ReadS MultipartUpload
ReadS [MultipartUpload]
(Int -> ReadS MultipartUpload)
-> ReadS [MultipartUpload]
-> ReadPrec MultipartUpload
-> ReadPrec [MultipartUpload]
-> Read MultipartUpload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MultipartUpload]
$creadListPrec :: ReadPrec [MultipartUpload]
readPrec :: ReadPrec MultipartUpload
$creadPrec :: ReadPrec MultipartUpload
readList :: ReadS [MultipartUpload]
$creadList :: ReadS [MultipartUpload]
readsPrec :: Int -> ReadS MultipartUpload
$creadsPrec :: Int -> ReadS MultipartUpload
Prelude.Read, Int -> MultipartUpload -> ShowS
[MultipartUpload] -> ShowS
MultipartUpload -> String
(Int -> MultipartUpload -> ShowS)
-> (MultipartUpload -> String)
-> ([MultipartUpload] -> ShowS)
-> Show MultipartUpload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MultipartUpload] -> ShowS
$cshowList :: [MultipartUpload] -> ShowS
show :: MultipartUpload -> String
$cshow :: MultipartUpload -> String
showsPrec :: Int -> MultipartUpload -> ShowS
$cshowsPrec :: Int -> MultipartUpload -> ShowS
Prelude.Show, (forall x. MultipartUpload -> Rep MultipartUpload x)
-> (forall x. Rep MultipartUpload x -> MultipartUpload)
-> Generic MultipartUpload
forall x. Rep MultipartUpload x -> MultipartUpload
forall x. MultipartUpload -> Rep MultipartUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MultipartUpload x -> MultipartUpload
$cfrom :: forall x. MultipartUpload -> Rep MultipartUpload x
Prelude.Generic)

-- |
-- Create a value of 'MultipartUpload' 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:
--
-- 'initiated', 'multipartUpload_initiated' - Date and time at which the multipart upload was initiated.
--
-- 'initiator', 'multipartUpload_initiator' - Identifies who initiated the multipart upload.
--
-- 'owner', 'multipartUpload_owner' - Specifies the owner of the object that is part of the multipart upload.
--
-- 'key', 'multipartUpload_key' - Key of the object for which the multipart upload was initiated.
--
-- 'storageClass', 'multipartUpload_storageClass' - The class of storage used to store the object.
--
-- 'uploadId', 'multipartUpload_uploadId' - Upload ID that identifies the multipart upload.
newMultipartUpload ::
  MultipartUpload
newMultipartUpload :: MultipartUpload
newMultipartUpload =
  MultipartUpload' :: Maybe ISO8601
-> Maybe Initiator
-> Maybe Owner
-> Maybe ObjectKey
-> Maybe StorageClass
-> Maybe Text
-> MultipartUpload
MultipartUpload'
    { $sel:initiated:MultipartUpload' :: Maybe ISO8601
initiated = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing,
      $sel:initiator:MultipartUpload' :: Maybe Initiator
initiator = Maybe Initiator
forall a. Maybe a
Prelude.Nothing,
      $sel:owner:MultipartUpload' :: Maybe Owner
owner = Maybe Owner
forall a. Maybe a
Prelude.Nothing,
      $sel:key:MultipartUpload' :: Maybe ObjectKey
key = Maybe ObjectKey
forall a. Maybe a
Prelude.Nothing,
      $sel:storageClass:MultipartUpload' :: Maybe StorageClass
storageClass = Maybe StorageClass
forall a. Maybe a
Prelude.Nothing,
      $sel:uploadId:MultipartUpload' :: Maybe Text
uploadId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Date and time at which the multipart upload was initiated.
multipartUpload_initiated :: Lens.Lens' MultipartUpload (Prelude.Maybe Prelude.UTCTime)
multipartUpload_initiated :: (Maybe UTCTime -> f (Maybe UTCTime))
-> MultipartUpload -> f MultipartUpload
multipartUpload_initiated = (MultipartUpload -> Maybe ISO8601)
-> (MultipartUpload -> Maybe ISO8601 -> MultipartUpload)
-> Lens
     MultipartUpload MultipartUpload (Maybe ISO8601) (Maybe ISO8601)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultipartUpload' {Maybe ISO8601
initiated :: Maybe ISO8601
$sel:initiated:MultipartUpload' :: MultipartUpload -> Maybe ISO8601
initiated} -> Maybe ISO8601
initiated) (\s :: MultipartUpload
s@MultipartUpload' {} Maybe ISO8601
a -> MultipartUpload
s {$sel:initiated:MultipartUpload' :: Maybe ISO8601
initiated = Maybe ISO8601
a} :: MultipartUpload) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> MultipartUpload -> f MultipartUpload)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> MultipartUpload
-> f MultipartUpload
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

-- | Identifies who initiated the multipart upload.
multipartUpload_initiator :: Lens.Lens' MultipartUpload (Prelude.Maybe Initiator)
multipartUpload_initiator :: (Maybe Initiator -> f (Maybe Initiator))
-> MultipartUpload -> f MultipartUpload
multipartUpload_initiator = (MultipartUpload -> Maybe Initiator)
-> (MultipartUpload -> Maybe Initiator -> MultipartUpload)
-> Lens
     MultipartUpload MultipartUpload (Maybe Initiator) (Maybe Initiator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultipartUpload' {Maybe Initiator
initiator :: Maybe Initiator
$sel:initiator:MultipartUpload' :: MultipartUpload -> Maybe Initiator
initiator} -> Maybe Initiator
initiator) (\s :: MultipartUpload
s@MultipartUpload' {} Maybe Initiator
a -> MultipartUpload
s {$sel:initiator:MultipartUpload' :: Maybe Initiator
initiator = Maybe Initiator
a} :: MultipartUpload)

-- | Specifies the owner of the object that is part of the multipart upload.
multipartUpload_owner :: Lens.Lens' MultipartUpload (Prelude.Maybe Owner)
multipartUpload_owner :: (Maybe Owner -> f (Maybe Owner))
-> MultipartUpload -> f MultipartUpload
multipartUpload_owner = (MultipartUpload -> Maybe Owner)
-> (MultipartUpload -> Maybe Owner -> MultipartUpload)
-> Lens MultipartUpload MultipartUpload (Maybe Owner) (Maybe Owner)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultipartUpload' {Maybe Owner
owner :: Maybe Owner
$sel:owner:MultipartUpload' :: MultipartUpload -> Maybe Owner
owner} -> Maybe Owner
owner) (\s :: MultipartUpload
s@MultipartUpload' {} Maybe Owner
a -> MultipartUpload
s {$sel:owner:MultipartUpload' :: Maybe Owner
owner = Maybe Owner
a} :: MultipartUpload)

-- | Key of the object for which the multipart upload was initiated.
multipartUpload_key :: Lens.Lens' MultipartUpload (Prelude.Maybe ObjectKey)
multipartUpload_key :: (Maybe ObjectKey -> f (Maybe ObjectKey))
-> MultipartUpload -> f MultipartUpload
multipartUpload_key = (MultipartUpload -> Maybe ObjectKey)
-> (MultipartUpload -> Maybe ObjectKey -> MultipartUpload)
-> Lens
     MultipartUpload MultipartUpload (Maybe ObjectKey) (Maybe ObjectKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultipartUpload' {Maybe ObjectKey
key :: Maybe ObjectKey
$sel:key:MultipartUpload' :: MultipartUpload -> Maybe ObjectKey
key} -> Maybe ObjectKey
key) (\s :: MultipartUpload
s@MultipartUpload' {} Maybe ObjectKey
a -> MultipartUpload
s {$sel:key:MultipartUpload' :: Maybe ObjectKey
key = Maybe ObjectKey
a} :: MultipartUpload)

-- | The class of storage used to store the object.
multipartUpload_storageClass :: Lens.Lens' MultipartUpload (Prelude.Maybe StorageClass)
multipartUpload_storageClass :: (Maybe StorageClass -> f (Maybe StorageClass))
-> MultipartUpload -> f MultipartUpload
multipartUpload_storageClass = (MultipartUpload -> Maybe StorageClass)
-> (MultipartUpload -> Maybe StorageClass -> MultipartUpload)
-> Lens
     MultipartUpload
     MultipartUpload
     (Maybe StorageClass)
     (Maybe StorageClass)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultipartUpload' {Maybe StorageClass
storageClass :: Maybe StorageClass
$sel:storageClass:MultipartUpload' :: MultipartUpload -> Maybe StorageClass
storageClass} -> Maybe StorageClass
storageClass) (\s :: MultipartUpload
s@MultipartUpload' {} Maybe StorageClass
a -> MultipartUpload
s {$sel:storageClass:MultipartUpload' :: Maybe StorageClass
storageClass = Maybe StorageClass
a} :: MultipartUpload)

-- | Upload ID that identifies the multipart upload.
multipartUpload_uploadId :: Lens.Lens' MultipartUpload (Prelude.Maybe Prelude.Text)
multipartUpload_uploadId :: (Maybe Text -> f (Maybe Text))
-> MultipartUpload -> f MultipartUpload
multipartUpload_uploadId = (MultipartUpload -> Maybe Text)
-> (MultipartUpload -> Maybe Text -> MultipartUpload)
-> Lens MultipartUpload MultipartUpload (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MultipartUpload' {Maybe Text
uploadId :: Maybe Text
$sel:uploadId:MultipartUpload' :: MultipartUpload -> Maybe Text
uploadId} -> Maybe Text
uploadId) (\s :: MultipartUpload
s@MultipartUpload' {} Maybe Text
a -> MultipartUpload
s {$sel:uploadId:MultipartUpload' :: Maybe Text
uploadId = Maybe Text
a} :: MultipartUpload)

instance Core.FromXML MultipartUpload where
  parseXML :: [Node] -> Either String MultipartUpload
parseXML [Node]
x =
    Maybe ISO8601
-> Maybe Initiator
-> Maybe Owner
-> Maybe ObjectKey
-> Maybe StorageClass
-> Maybe Text
-> MultipartUpload
MultipartUpload'
      (Maybe ISO8601
 -> Maybe Initiator
 -> Maybe Owner
 -> Maybe ObjectKey
 -> Maybe StorageClass
 -> Maybe Text
 -> MultipartUpload)
-> Either String (Maybe ISO8601)
-> Either
     String
     (Maybe Initiator
      -> Maybe Owner
      -> Maybe ObjectKey
      -> Maybe StorageClass
      -> Maybe Text
      -> MultipartUpload)
forall (f :: * -> *) a b. Functor 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
"Initiated")
      Either
  String
  (Maybe Initiator
   -> Maybe Owner
   -> Maybe ObjectKey
   -> Maybe StorageClass
   -> Maybe Text
   -> MultipartUpload)
-> Either String (Maybe Initiator)
-> Either
     String
     (Maybe Owner
      -> Maybe ObjectKey
      -> Maybe StorageClass
      -> Maybe Text
      -> MultipartUpload)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Initiator)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Initiator")
      Either
  String
  (Maybe Owner
   -> Maybe ObjectKey
   -> Maybe StorageClass
   -> Maybe Text
   -> MultipartUpload)
-> Either String (Maybe Owner)
-> Either
     String
     (Maybe ObjectKey
      -> Maybe StorageClass -> Maybe Text -> MultipartUpload)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Owner)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Owner")
      Either
  String
  (Maybe ObjectKey
   -> Maybe StorageClass -> Maybe Text -> MultipartUpload)
-> Either String (Maybe ObjectKey)
-> Either
     String (Maybe StorageClass -> Maybe Text -> MultipartUpload)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe ObjectKey)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Key")
      Either String (Maybe StorageClass -> Maybe Text -> MultipartUpload)
-> Either String (Maybe StorageClass)
-> Either String (Maybe Text -> MultipartUpload)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe StorageClass)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"StorageClass")
      Either String (Maybe Text -> MultipartUpload)
-> Either String (Maybe Text) -> Either String MultipartUpload
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"UploadId")

instance Prelude.Hashable MultipartUpload

instance Prelude.NFData MultipartUpload