{-# 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.VersioningConfiguration
-- 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.VersioningConfiguration 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.BucketVersioningStatus
import Amazonka.S3.Types.MFADelete

-- | Describes the versioning state of an Amazon S3 bucket. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTVersioningStatus.html PUT Bucket versioning>
-- in the /Amazon S3 API Reference/.
--
-- /See:/ 'newVersioningConfiguration' smart constructor.
data VersioningConfiguration = VersioningConfiguration'
  { -- | The versioning state of the bucket.
    VersioningConfiguration -> Maybe BucketVersioningStatus
status :: Prelude.Maybe BucketVersioningStatus,
    -- | Specifies whether MFA delete is enabled in the bucket versioning
    -- configuration. This element is only returned if the bucket has been
    -- configured with MFA delete. If the bucket has never been so configured,
    -- this element is not returned.
    VersioningConfiguration -> Maybe MFADelete
mfaDelete :: Prelude.Maybe MFADelete
  }
  deriving (VersioningConfiguration -> VersioningConfiguration -> Bool
(VersioningConfiguration -> VersioningConfiguration -> Bool)
-> (VersioningConfiguration -> VersioningConfiguration -> Bool)
-> Eq VersioningConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VersioningConfiguration -> VersioningConfiguration -> Bool
$c/= :: VersioningConfiguration -> VersioningConfiguration -> Bool
== :: VersioningConfiguration -> VersioningConfiguration -> Bool
$c== :: VersioningConfiguration -> VersioningConfiguration -> Bool
Prelude.Eq, ReadPrec [VersioningConfiguration]
ReadPrec VersioningConfiguration
Int -> ReadS VersioningConfiguration
ReadS [VersioningConfiguration]
(Int -> ReadS VersioningConfiguration)
-> ReadS [VersioningConfiguration]
-> ReadPrec VersioningConfiguration
-> ReadPrec [VersioningConfiguration]
-> Read VersioningConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VersioningConfiguration]
$creadListPrec :: ReadPrec [VersioningConfiguration]
readPrec :: ReadPrec VersioningConfiguration
$creadPrec :: ReadPrec VersioningConfiguration
readList :: ReadS [VersioningConfiguration]
$creadList :: ReadS [VersioningConfiguration]
readsPrec :: Int -> ReadS VersioningConfiguration
$creadsPrec :: Int -> ReadS VersioningConfiguration
Prelude.Read, Int -> VersioningConfiguration -> ShowS
[VersioningConfiguration] -> ShowS
VersioningConfiguration -> String
(Int -> VersioningConfiguration -> ShowS)
-> (VersioningConfiguration -> String)
-> ([VersioningConfiguration] -> ShowS)
-> Show VersioningConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VersioningConfiguration] -> ShowS
$cshowList :: [VersioningConfiguration] -> ShowS
show :: VersioningConfiguration -> String
$cshow :: VersioningConfiguration -> String
showsPrec :: Int -> VersioningConfiguration -> ShowS
$cshowsPrec :: Int -> VersioningConfiguration -> ShowS
Prelude.Show, (forall x.
 VersioningConfiguration -> Rep VersioningConfiguration x)
-> (forall x.
    Rep VersioningConfiguration x -> VersioningConfiguration)
-> Generic VersioningConfiguration
forall x. Rep VersioningConfiguration x -> VersioningConfiguration
forall x. VersioningConfiguration -> Rep VersioningConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VersioningConfiguration x -> VersioningConfiguration
$cfrom :: forall x. VersioningConfiguration -> Rep VersioningConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'VersioningConfiguration' 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:
--
-- 'status', 'versioningConfiguration_status' - The versioning state of the bucket.
--
-- 'mfaDelete', 'versioningConfiguration_mfaDelete' - Specifies whether MFA delete is enabled in the bucket versioning
-- configuration. This element is only returned if the bucket has been
-- configured with MFA delete. If the bucket has never been so configured,
-- this element is not returned.
newVersioningConfiguration ::
  VersioningConfiguration
newVersioningConfiguration :: VersioningConfiguration
newVersioningConfiguration =
  VersioningConfiguration' :: Maybe BucketVersioningStatus
-> Maybe MFADelete -> VersioningConfiguration
VersioningConfiguration'
    { $sel:status:VersioningConfiguration' :: Maybe BucketVersioningStatus
status = Maybe BucketVersioningStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:mfaDelete:VersioningConfiguration' :: Maybe MFADelete
mfaDelete = Maybe MFADelete
forall a. Maybe a
Prelude.Nothing
    }

-- | The versioning state of the bucket.
versioningConfiguration_status :: Lens.Lens' VersioningConfiguration (Prelude.Maybe BucketVersioningStatus)
versioningConfiguration_status :: (Maybe BucketVersioningStatus -> f (Maybe BucketVersioningStatus))
-> VersioningConfiguration -> f VersioningConfiguration
versioningConfiguration_status = (VersioningConfiguration -> Maybe BucketVersioningStatus)
-> (VersioningConfiguration
    -> Maybe BucketVersioningStatus -> VersioningConfiguration)
-> Lens
     VersioningConfiguration
     VersioningConfiguration
     (Maybe BucketVersioningStatus)
     (Maybe BucketVersioningStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VersioningConfiguration' {Maybe BucketVersioningStatus
status :: Maybe BucketVersioningStatus
$sel:status:VersioningConfiguration' :: VersioningConfiguration -> Maybe BucketVersioningStatus
status} -> Maybe BucketVersioningStatus
status) (\s :: VersioningConfiguration
s@VersioningConfiguration' {} Maybe BucketVersioningStatus
a -> VersioningConfiguration
s {$sel:status:VersioningConfiguration' :: Maybe BucketVersioningStatus
status = Maybe BucketVersioningStatus
a} :: VersioningConfiguration)

-- | Specifies whether MFA delete is enabled in the bucket versioning
-- configuration. This element is only returned if the bucket has been
-- configured with MFA delete. If the bucket has never been so configured,
-- this element is not returned.
versioningConfiguration_mfaDelete :: Lens.Lens' VersioningConfiguration (Prelude.Maybe MFADelete)
versioningConfiguration_mfaDelete :: (Maybe MFADelete -> f (Maybe MFADelete))
-> VersioningConfiguration -> f VersioningConfiguration
versioningConfiguration_mfaDelete = (VersioningConfiguration -> Maybe MFADelete)
-> (VersioningConfiguration
    -> Maybe MFADelete -> VersioningConfiguration)
-> Lens
     VersioningConfiguration
     VersioningConfiguration
     (Maybe MFADelete)
     (Maybe MFADelete)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VersioningConfiguration' {Maybe MFADelete
mfaDelete :: Maybe MFADelete
$sel:mfaDelete:VersioningConfiguration' :: VersioningConfiguration -> Maybe MFADelete
mfaDelete} -> Maybe MFADelete
mfaDelete) (\s :: VersioningConfiguration
s@VersioningConfiguration' {} Maybe MFADelete
a -> VersioningConfiguration
s {$sel:mfaDelete:VersioningConfiguration' :: Maybe MFADelete
mfaDelete = Maybe MFADelete
a} :: VersioningConfiguration)

instance Prelude.Hashable VersioningConfiguration

instance Prelude.NFData VersioningConfiguration

instance Core.ToXML VersioningConfiguration where
  toXML :: VersioningConfiguration -> XML
toXML VersioningConfiguration' {Maybe BucketVersioningStatus
Maybe MFADelete
mfaDelete :: Maybe MFADelete
status :: Maybe BucketVersioningStatus
$sel:mfaDelete:VersioningConfiguration' :: VersioningConfiguration -> Maybe MFADelete
$sel:status:VersioningConfiguration' :: VersioningConfiguration -> Maybe BucketVersioningStatus
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Status" Name -> Maybe BucketVersioningStatus -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe BucketVersioningStatus
status,
        Name
"MfaDelete" Name -> Maybe MFADelete -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe MFADelete
mfaDelete
      ]