{-# 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.CompletedMultipartUpload
-- 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.CompletedMultipartUpload 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.CompletedPart

-- | The container for the completed multipart upload details.
--
-- /See:/ 'newCompletedMultipartUpload' smart constructor.
data CompletedMultipartUpload = CompletedMultipartUpload'
  { -- | Array of CompletedPart data types.
    CompletedMultipartUpload -> Maybe (NonEmpty CompletedPart)
parts :: Prelude.Maybe (Prelude.NonEmpty CompletedPart)
  }
  deriving (CompletedMultipartUpload -> CompletedMultipartUpload -> Bool
(CompletedMultipartUpload -> CompletedMultipartUpload -> Bool)
-> (CompletedMultipartUpload -> CompletedMultipartUpload -> Bool)
-> Eq CompletedMultipartUpload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompletedMultipartUpload -> CompletedMultipartUpload -> Bool
$c/= :: CompletedMultipartUpload -> CompletedMultipartUpload -> Bool
== :: CompletedMultipartUpload -> CompletedMultipartUpload -> Bool
$c== :: CompletedMultipartUpload -> CompletedMultipartUpload -> Bool
Prelude.Eq, ReadPrec [CompletedMultipartUpload]
ReadPrec CompletedMultipartUpload
Int -> ReadS CompletedMultipartUpload
ReadS [CompletedMultipartUpload]
(Int -> ReadS CompletedMultipartUpload)
-> ReadS [CompletedMultipartUpload]
-> ReadPrec CompletedMultipartUpload
-> ReadPrec [CompletedMultipartUpload]
-> Read CompletedMultipartUpload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CompletedMultipartUpload]
$creadListPrec :: ReadPrec [CompletedMultipartUpload]
readPrec :: ReadPrec CompletedMultipartUpload
$creadPrec :: ReadPrec CompletedMultipartUpload
readList :: ReadS [CompletedMultipartUpload]
$creadList :: ReadS [CompletedMultipartUpload]
readsPrec :: Int -> ReadS CompletedMultipartUpload
$creadsPrec :: Int -> ReadS CompletedMultipartUpload
Prelude.Read, Int -> CompletedMultipartUpload -> ShowS
[CompletedMultipartUpload] -> ShowS
CompletedMultipartUpload -> String
(Int -> CompletedMultipartUpload -> ShowS)
-> (CompletedMultipartUpload -> String)
-> ([CompletedMultipartUpload] -> ShowS)
-> Show CompletedMultipartUpload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompletedMultipartUpload] -> ShowS
$cshowList :: [CompletedMultipartUpload] -> ShowS
show :: CompletedMultipartUpload -> String
$cshow :: CompletedMultipartUpload -> String
showsPrec :: Int -> CompletedMultipartUpload -> ShowS
$cshowsPrec :: Int -> CompletedMultipartUpload -> ShowS
Prelude.Show, (forall x.
 CompletedMultipartUpload -> Rep CompletedMultipartUpload x)
-> (forall x.
    Rep CompletedMultipartUpload x -> CompletedMultipartUpload)
-> Generic CompletedMultipartUpload
forall x.
Rep CompletedMultipartUpload x -> CompletedMultipartUpload
forall x.
CompletedMultipartUpload -> Rep CompletedMultipartUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CompletedMultipartUpload x -> CompletedMultipartUpload
$cfrom :: forall x.
CompletedMultipartUpload -> Rep CompletedMultipartUpload x
Prelude.Generic)

-- |
-- Create a value of 'CompletedMultipartUpload' 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:
--
-- 'parts', 'completedMultipartUpload_parts' - Array of CompletedPart data types.
newCompletedMultipartUpload ::
  CompletedMultipartUpload
newCompletedMultipartUpload :: CompletedMultipartUpload
newCompletedMultipartUpload =
  CompletedMultipartUpload' :: Maybe (NonEmpty CompletedPart) -> CompletedMultipartUpload
CompletedMultipartUpload' {$sel:parts:CompletedMultipartUpload' :: Maybe (NonEmpty CompletedPart)
parts = Maybe (NonEmpty CompletedPart)
forall a. Maybe a
Prelude.Nothing}

-- | Array of CompletedPart data types.
completedMultipartUpload_parts :: Lens.Lens' CompletedMultipartUpload (Prelude.Maybe (Prelude.NonEmpty CompletedPart))
completedMultipartUpload_parts :: (Maybe (NonEmpty CompletedPart)
 -> f (Maybe (NonEmpty CompletedPart)))
-> CompletedMultipartUpload -> f CompletedMultipartUpload
completedMultipartUpload_parts = (CompletedMultipartUpload -> Maybe (NonEmpty CompletedPart))
-> (CompletedMultipartUpload
    -> Maybe (NonEmpty CompletedPart) -> CompletedMultipartUpload)
-> Lens
     CompletedMultipartUpload
     CompletedMultipartUpload
     (Maybe (NonEmpty CompletedPart))
     (Maybe (NonEmpty CompletedPart))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CompletedMultipartUpload' {Maybe (NonEmpty CompletedPart)
parts :: Maybe (NonEmpty CompletedPart)
$sel:parts:CompletedMultipartUpload' :: CompletedMultipartUpload -> Maybe (NonEmpty CompletedPart)
parts} -> Maybe (NonEmpty CompletedPart)
parts) (\s :: CompletedMultipartUpload
s@CompletedMultipartUpload' {} Maybe (NonEmpty CompletedPart)
a -> CompletedMultipartUpload
s {$sel:parts:CompletedMultipartUpload' :: Maybe (NonEmpty CompletedPart)
parts = Maybe (NonEmpty CompletedPart)
a} :: CompletedMultipartUpload) ((Maybe (NonEmpty CompletedPart)
  -> f (Maybe (NonEmpty CompletedPart)))
 -> CompletedMultipartUpload -> f CompletedMultipartUpload)
-> ((Maybe (NonEmpty CompletedPart)
     -> f (Maybe (NonEmpty CompletedPart)))
    -> Maybe (NonEmpty CompletedPart)
    -> f (Maybe (NonEmpty CompletedPart)))
-> (Maybe (NonEmpty CompletedPart)
    -> f (Maybe (NonEmpty CompletedPart)))
-> CompletedMultipartUpload
-> f CompletedMultipartUpload
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty CompletedPart)
  (NonEmpty CompletedPart)
  (NonEmpty CompletedPart)
  (NonEmpty CompletedPart)
-> Iso
     (Maybe (NonEmpty CompletedPart))
     (Maybe (NonEmpty CompletedPart))
     (Maybe (NonEmpty CompletedPart))
     (Maybe (NonEmpty CompletedPart))
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
  (NonEmpty CompletedPart)
  (NonEmpty CompletedPart)
  (NonEmpty CompletedPart)
  (NonEmpty CompletedPart)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable CompletedMultipartUpload

instance Prelude.NFData CompletedMultipartUpload

instance Core.ToXML CompletedMultipartUpload where
  toXML :: CompletedMultipartUpload -> XML
toXML CompletedMultipartUpload' {Maybe (NonEmpty CompletedPart)
parts :: Maybe (NonEmpty CompletedPart)
$sel:parts:CompletedMultipartUpload' :: CompletedMultipartUpload -> Maybe (NonEmpty CompletedPart)
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Maybe XML -> XML
forall a. ToXML a => a -> XML
Core.toXML
          (Name -> NonEmpty CompletedPart -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Part" (NonEmpty CompletedPart -> XML)
-> Maybe (NonEmpty CompletedPart) -> Maybe XML
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty CompletedPart)
parts)
      ]