{-# 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.BucketLifecycleConfiguration
-- 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.BucketLifecycleConfiguration 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.LifecycleRule

-- | Specifies the lifecycle configuration for objects in an Amazon S3
-- bucket. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html Object Lifecycle Management>
-- in the /Amazon S3 User Guide/.
--
-- /See:/ 'newBucketLifecycleConfiguration' smart constructor.
data BucketLifecycleConfiguration = BucketLifecycleConfiguration'
  { -- | A lifecycle rule for individual objects in an Amazon S3 bucket.
    BucketLifecycleConfiguration -> [LifecycleRule]
rules :: [LifecycleRule]
  }
  deriving (BucketLifecycleConfiguration
-> BucketLifecycleConfiguration -> Bool
(BucketLifecycleConfiguration
 -> BucketLifecycleConfiguration -> Bool)
-> (BucketLifecycleConfiguration
    -> BucketLifecycleConfiguration -> Bool)
-> Eq BucketLifecycleConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketLifecycleConfiguration
-> BucketLifecycleConfiguration -> Bool
$c/= :: BucketLifecycleConfiguration
-> BucketLifecycleConfiguration -> Bool
== :: BucketLifecycleConfiguration
-> BucketLifecycleConfiguration -> Bool
$c== :: BucketLifecycleConfiguration
-> BucketLifecycleConfiguration -> Bool
Prelude.Eq, ReadPrec [BucketLifecycleConfiguration]
ReadPrec BucketLifecycleConfiguration
Int -> ReadS BucketLifecycleConfiguration
ReadS [BucketLifecycleConfiguration]
(Int -> ReadS BucketLifecycleConfiguration)
-> ReadS [BucketLifecycleConfiguration]
-> ReadPrec BucketLifecycleConfiguration
-> ReadPrec [BucketLifecycleConfiguration]
-> Read BucketLifecycleConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketLifecycleConfiguration]
$creadListPrec :: ReadPrec [BucketLifecycleConfiguration]
readPrec :: ReadPrec BucketLifecycleConfiguration
$creadPrec :: ReadPrec BucketLifecycleConfiguration
readList :: ReadS [BucketLifecycleConfiguration]
$creadList :: ReadS [BucketLifecycleConfiguration]
readsPrec :: Int -> ReadS BucketLifecycleConfiguration
$creadsPrec :: Int -> ReadS BucketLifecycleConfiguration
Prelude.Read, Int -> BucketLifecycleConfiguration -> ShowS
[BucketLifecycleConfiguration] -> ShowS
BucketLifecycleConfiguration -> String
(Int -> BucketLifecycleConfiguration -> ShowS)
-> (BucketLifecycleConfiguration -> String)
-> ([BucketLifecycleConfiguration] -> ShowS)
-> Show BucketLifecycleConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketLifecycleConfiguration] -> ShowS
$cshowList :: [BucketLifecycleConfiguration] -> ShowS
show :: BucketLifecycleConfiguration -> String
$cshow :: BucketLifecycleConfiguration -> String
showsPrec :: Int -> BucketLifecycleConfiguration -> ShowS
$cshowsPrec :: Int -> BucketLifecycleConfiguration -> ShowS
Prelude.Show, (forall x.
 BucketLifecycleConfiguration -> Rep BucketLifecycleConfiguration x)
-> (forall x.
    Rep BucketLifecycleConfiguration x -> BucketLifecycleConfiguration)
-> Generic BucketLifecycleConfiguration
forall x.
Rep BucketLifecycleConfiguration x -> BucketLifecycleConfiguration
forall x.
BucketLifecycleConfiguration -> Rep BucketLifecycleConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BucketLifecycleConfiguration x -> BucketLifecycleConfiguration
$cfrom :: forall x.
BucketLifecycleConfiguration -> Rep BucketLifecycleConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'BucketLifecycleConfiguration' 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:
--
-- 'rules', 'bucketLifecycleConfiguration_rules' - A lifecycle rule for individual objects in an Amazon S3 bucket.
newBucketLifecycleConfiguration ::
  BucketLifecycleConfiguration
newBucketLifecycleConfiguration :: BucketLifecycleConfiguration
newBucketLifecycleConfiguration =
  BucketLifecycleConfiguration' :: [LifecycleRule] -> BucketLifecycleConfiguration
BucketLifecycleConfiguration'
    { $sel:rules:BucketLifecycleConfiguration' :: [LifecycleRule]
rules =
        [LifecycleRule]
forall a. Monoid a => a
Prelude.mempty
    }

-- | A lifecycle rule for individual objects in an Amazon S3 bucket.
bucketLifecycleConfiguration_rules :: Lens.Lens' BucketLifecycleConfiguration [LifecycleRule]
bucketLifecycleConfiguration_rules :: ([LifecycleRule] -> f [LifecycleRule])
-> BucketLifecycleConfiguration -> f BucketLifecycleConfiguration
bucketLifecycleConfiguration_rules = (BucketLifecycleConfiguration -> [LifecycleRule])
-> (BucketLifecycleConfiguration
    -> [LifecycleRule] -> BucketLifecycleConfiguration)
-> Lens
     BucketLifecycleConfiguration
     BucketLifecycleConfiguration
     [LifecycleRule]
     [LifecycleRule]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketLifecycleConfiguration' {[LifecycleRule]
rules :: [LifecycleRule]
$sel:rules:BucketLifecycleConfiguration' :: BucketLifecycleConfiguration -> [LifecycleRule]
rules} -> [LifecycleRule]
rules) (\s :: BucketLifecycleConfiguration
s@BucketLifecycleConfiguration' {} [LifecycleRule]
a -> BucketLifecycleConfiguration
s {$sel:rules:BucketLifecycleConfiguration' :: [LifecycleRule]
rules = [LifecycleRule]
a} :: BucketLifecycleConfiguration) (([LifecycleRule] -> f [LifecycleRule])
 -> BucketLifecycleConfiguration -> f BucketLifecycleConfiguration)
-> (([LifecycleRule] -> f [LifecycleRule])
    -> [LifecycleRule] -> f [LifecycleRule])
-> ([LifecycleRule] -> f [LifecycleRule])
-> BucketLifecycleConfiguration
-> f BucketLifecycleConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([LifecycleRule] -> f [LifecycleRule])
-> [LifecycleRule] -> f [LifecycleRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.Hashable
    BucketLifecycleConfiguration

instance Prelude.NFData BucketLifecycleConfiguration

instance Core.ToXML BucketLifecycleConfiguration where
  toXML :: BucketLifecycleConfiguration -> XML
toXML BucketLifecycleConfiguration' {[LifecycleRule]
rules :: [LifecycleRule]
$sel:rules:BucketLifecycleConfiguration' :: BucketLifecycleConfiguration -> [LifecycleRule]
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat [Name -> [LifecycleRule] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Rule" [LifecycleRule]
rules]