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

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

-- | Specifies the days since the initiation of an incomplete multipart
-- upload that Amazon S3 will wait before permanently removing all parts of
-- the upload. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/mpuoverview.html#mpu-abort-incomplete-mpu-lifecycle-config Aborting Incomplete Multipart Uploads Using a Bucket Lifecycle Policy>
-- in the /Amazon S3 User Guide/.
--
-- /See:/ 'newAbortIncompleteMultipartUpload' smart constructor.
data AbortIncompleteMultipartUpload = AbortIncompleteMultipartUpload'
  { -- | Specifies the number of days after which Amazon S3 aborts an incomplete
    -- multipart upload.
    AbortIncompleteMultipartUpload -> Maybe Int
daysAfterInitiation :: Prelude.Maybe Prelude.Int
  }
  deriving (AbortIncompleteMultipartUpload
-> AbortIncompleteMultipartUpload -> Bool
(AbortIncompleteMultipartUpload
 -> AbortIncompleteMultipartUpload -> Bool)
-> (AbortIncompleteMultipartUpload
    -> AbortIncompleteMultipartUpload -> Bool)
-> Eq AbortIncompleteMultipartUpload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbortIncompleteMultipartUpload
-> AbortIncompleteMultipartUpload -> Bool
$c/= :: AbortIncompleteMultipartUpload
-> AbortIncompleteMultipartUpload -> Bool
== :: AbortIncompleteMultipartUpload
-> AbortIncompleteMultipartUpload -> Bool
$c== :: AbortIncompleteMultipartUpload
-> AbortIncompleteMultipartUpload -> Bool
Prelude.Eq, ReadPrec [AbortIncompleteMultipartUpload]
ReadPrec AbortIncompleteMultipartUpload
Int -> ReadS AbortIncompleteMultipartUpload
ReadS [AbortIncompleteMultipartUpload]
(Int -> ReadS AbortIncompleteMultipartUpload)
-> ReadS [AbortIncompleteMultipartUpload]
-> ReadPrec AbortIncompleteMultipartUpload
-> ReadPrec [AbortIncompleteMultipartUpload]
-> Read AbortIncompleteMultipartUpload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AbortIncompleteMultipartUpload]
$creadListPrec :: ReadPrec [AbortIncompleteMultipartUpload]
readPrec :: ReadPrec AbortIncompleteMultipartUpload
$creadPrec :: ReadPrec AbortIncompleteMultipartUpload
readList :: ReadS [AbortIncompleteMultipartUpload]
$creadList :: ReadS [AbortIncompleteMultipartUpload]
readsPrec :: Int -> ReadS AbortIncompleteMultipartUpload
$creadsPrec :: Int -> ReadS AbortIncompleteMultipartUpload
Prelude.Read, Int -> AbortIncompleteMultipartUpload -> ShowS
[AbortIncompleteMultipartUpload] -> ShowS
AbortIncompleteMultipartUpload -> String
(Int -> AbortIncompleteMultipartUpload -> ShowS)
-> (AbortIncompleteMultipartUpload -> String)
-> ([AbortIncompleteMultipartUpload] -> ShowS)
-> Show AbortIncompleteMultipartUpload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AbortIncompleteMultipartUpload] -> ShowS
$cshowList :: [AbortIncompleteMultipartUpload] -> ShowS
show :: AbortIncompleteMultipartUpload -> String
$cshow :: AbortIncompleteMultipartUpload -> String
showsPrec :: Int -> AbortIncompleteMultipartUpload -> ShowS
$cshowsPrec :: Int -> AbortIncompleteMultipartUpload -> ShowS
Prelude.Show, (forall x.
 AbortIncompleteMultipartUpload
 -> Rep AbortIncompleteMultipartUpload x)
-> (forall x.
    Rep AbortIncompleteMultipartUpload x
    -> AbortIncompleteMultipartUpload)
-> Generic AbortIncompleteMultipartUpload
forall x.
Rep AbortIncompleteMultipartUpload x
-> AbortIncompleteMultipartUpload
forall x.
AbortIncompleteMultipartUpload
-> Rep AbortIncompleteMultipartUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AbortIncompleteMultipartUpload x
-> AbortIncompleteMultipartUpload
$cfrom :: forall x.
AbortIncompleteMultipartUpload
-> Rep AbortIncompleteMultipartUpload x
Prelude.Generic)

-- |
-- Create a value of 'AbortIncompleteMultipartUpload' 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:
--
-- 'daysAfterInitiation', 'abortIncompleteMultipartUpload_daysAfterInitiation' - Specifies the number of days after which Amazon S3 aborts an incomplete
-- multipart upload.
newAbortIncompleteMultipartUpload ::
  AbortIncompleteMultipartUpload
newAbortIncompleteMultipartUpload :: AbortIncompleteMultipartUpload
newAbortIncompleteMultipartUpload =
  AbortIncompleteMultipartUpload' :: Maybe Int -> AbortIncompleteMultipartUpload
AbortIncompleteMultipartUpload'
    { $sel:daysAfterInitiation:AbortIncompleteMultipartUpload' :: Maybe Int
daysAfterInitiation =
        Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the number of days after which Amazon S3 aborts an incomplete
-- multipart upload.
abortIncompleteMultipartUpload_daysAfterInitiation :: Lens.Lens' AbortIncompleteMultipartUpload (Prelude.Maybe Prelude.Int)
abortIncompleteMultipartUpload_daysAfterInitiation :: (Maybe Int -> f (Maybe Int))
-> AbortIncompleteMultipartUpload
-> f AbortIncompleteMultipartUpload
abortIncompleteMultipartUpload_daysAfterInitiation = (AbortIncompleteMultipartUpload -> Maybe Int)
-> (AbortIncompleteMultipartUpload
    -> Maybe Int -> AbortIncompleteMultipartUpload)
-> Lens
     AbortIncompleteMultipartUpload
     AbortIncompleteMultipartUpload
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AbortIncompleteMultipartUpload' {Maybe Int
daysAfterInitiation :: Maybe Int
$sel:daysAfterInitiation:AbortIncompleteMultipartUpload' :: AbortIncompleteMultipartUpload -> Maybe Int
daysAfterInitiation} -> Maybe Int
daysAfterInitiation) (\s :: AbortIncompleteMultipartUpload
s@AbortIncompleteMultipartUpload' {} Maybe Int
a -> AbortIncompleteMultipartUpload
s {$sel:daysAfterInitiation:AbortIncompleteMultipartUpload' :: Maybe Int
daysAfterInitiation = Maybe Int
a} :: AbortIncompleteMultipartUpload)

instance Core.FromXML AbortIncompleteMultipartUpload where
  parseXML :: [Node] -> Either String AbortIncompleteMultipartUpload
parseXML [Node]
x =
    Maybe Int -> AbortIncompleteMultipartUpload
AbortIncompleteMultipartUpload'
      (Maybe Int -> AbortIncompleteMultipartUpload)
-> Either String (Maybe Int)
-> Either String AbortIncompleteMultipartUpload
forall (f :: * -> *) a b. Functor 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
"DaysAfterInitiation")

instance
  Prelude.Hashable
    AbortIncompleteMultipartUpload

instance
  Prelude.NFData
    AbortIncompleteMultipartUpload

instance Core.ToXML AbortIncompleteMultipartUpload where
  toXML :: AbortIncompleteMultipartUpload -> XML
toXML AbortIncompleteMultipartUpload' {Maybe Int
daysAfterInitiation :: Maybe Int
$sel:daysAfterInitiation:AbortIncompleteMultipartUpload' :: AbortIncompleteMultipartUpload -> Maybe Int
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"DaysAfterInitiation" Name -> Maybe Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Int
daysAfterInitiation]