{-# 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.MacieV2.Types.BucketPermissionConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MacieV2.Types.BucketPermissionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MacieV2.Types.AccountLevelPermissions
import Amazonka.MacieV2.Types.BucketLevelPermissions
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the account-level and bucket-level
-- permissions settings for an S3 bucket.
--
-- /See:/ 'newBucketPermissionConfiguration' smart constructor.
data BucketPermissionConfiguration = BucketPermissionConfiguration'
  { -- | The account-level permissions settings that apply to the bucket.
    BucketPermissionConfiguration -> Maybe AccountLevelPermissions
accountLevelPermissions :: Prelude.Maybe AccountLevelPermissions,
    -- | The bucket-level permissions settings for the bucket.
    BucketPermissionConfiguration -> Maybe BucketLevelPermissions
bucketLevelPermissions :: Prelude.Maybe BucketLevelPermissions
  }
  deriving (BucketPermissionConfiguration
-> BucketPermissionConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketPermissionConfiguration
-> BucketPermissionConfiguration -> Bool
$c/= :: BucketPermissionConfiguration
-> BucketPermissionConfiguration -> Bool
== :: BucketPermissionConfiguration
-> BucketPermissionConfiguration -> Bool
$c== :: BucketPermissionConfiguration
-> BucketPermissionConfiguration -> Bool
Prelude.Eq, ReadPrec [BucketPermissionConfiguration]
ReadPrec BucketPermissionConfiguration
Int -> ReadS BucketPermissionConfiguration
ReadS [BucketPermissionConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketPermissionConfiguration]
$creadListPrec :: ReadPrec [BucketPermissionConfiguration]
readPrec :: ReadPrec BucketPermissionConfiguration
$creadPrec :: ReadPrec BucketPermissionConfiguration
readList :: ReadS [BucketPermissionConfiguration]
$creadList :: ReadS [BucketPermissionConfiguration]
readsPrec :: Int -> ReadS BucketPermissionConfiguration
$creadsPrec :: Int -> ReadS BucketPermissionConfiguration
Prelude.Read, Int -> BucketPermissionConfiguration -> ShowS
[BucketPermissionConfiguration] -> ShowS
BucketPermissionConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketPermissionConfiguration] -> ShowS
$cshowList :: [BucketPermissionConfiguration] -> ShowS
show :: BucketPermissionConfiguration -> String
$cshow :: BucketPermissionConfiguration -> String
showsPrec :: Int -> BucketPermissionConfiguration -> ShowS
$cshowsPrec :: Int -> BucketPermissionConfiguration -> ShowS
Prelude.Show, forall x.
Rep BucketPermissionConfiguration x
-> BucketPermissionConfiguration
forall x.
BucketPermissionConfiguration
-> Rep BucketPermissionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BucketPermissionConfiguration x
-> BucketPermissionConfiguration
$cfrom :: forall x.
BucketPermissionConfiguration
-> Rep BucketPermissionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'BucketPermissionConfiguration' 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:
--
-- 'accountLevelPermissions', 'bucketPermissionConfiguration_accountLevelPermissions' - The account-level permissions settings that apply to the bucket.
--
-- 'bucketLevelPermissions', 'bucketPermissionConfiguration_bucketLevelPermissions' - The bucket-level permissions settings for the bucket.
newBucketPermissionConfiguration ::
  BucketPermissionConfiguration
newBucketPermissionConfiguration :: BucketPermissionConfiguration
newBucketPermissionConfiguration =
  BucketPermissionConfiguration'
    { $sel:accountLevelPermissions:BucketPermissionConfiguration' :: Maybe AccountLevelPermissions
accountLevelPermissions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:bucketLevelPermissions:BucketPermissionConfiguration' :: Maybe BucketLevelPermissions
bucketLevelPermissions = forall a. Maybe a
Prelude.Nothing
    }

-- | The account-level permissions settings that apply to the bucket.
bucketPermissionConfiguration_accountLevelPermissions :: Lens.Lens' BucketPermissionConfiguration (Prelude.Maybe AccountLevelPermissions)
bucketPermissionConfiguration_accountLevelPermissions :: Lens' BucketPermissionConfiguration (Maybe AccountLevelPermissions)
bucketPermissionConfiguration_accountLevelPermissions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketPermissionConfiguration' {Maybe AccountLevelPermissions
accountLevelPermissions :: Maybe AccountLevelPermissions
$sel:accountLevelPermissions:BucketPermissionConfiguration' :: BucketPermissionConfiguration -> Maybe AccountLevelPermissions
accountLevelPermissions} -> Maybe AccountLevelPermissions
accountLevelPermissions) (\s :: BucketPermissionConfiguration
s@BucketPermissionConfiguration' {} Maybe AccountLevelPermissions
a -> BucketPermissionConfiguration
s {$sel:accountLevelPermissions:BucketPermissionConfiguration' :: Maybe AccountLevelPermissions
accountLevelPermissions = Maybe AccountLevelPermissions
a} :: BucketPermissionConfiguration)

-- | The bucket-level permissions settings for the bucket.
bucketPermissionConfiguration_bucketLevelPermissions :: Lens.Lens' BucketPermissionConfiguration (Prelude.Maybe BucketLevelPermissions)
bucketPermissionConfiguration_bucketLevelPermissions :: Lens' BucketPermissionConfiguration (Maybe BucketLevelPermissions)
bucketPermissionConfiguration_bucketLevelPermissions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketPermissionConfiguration' {Maybe BucketLevelPermissions
bucketLevelPermissions :: Maybe BucketLevelPermissions
$sel:bucketLevelPermissions:BucketPermissionConfiguration' :: BucketPermissionConfiguration -> Maybe BucketLevelPermissions
bucketLevelPermissions} -> Maybe BucketLevelPermissions
bucketLevelPermissions) (\s :: BucketPermissionConfiguration
s@BucketPermissionConfiguration' {} Maybe BucketLevelPermissions
a -> BucketPermissionConfiguration
s {$sel:bucketLevelPermissions:BucketPermissionConfiguration' :: Maybe BucketLevelPermissions
bucketLevelPermissions = Maybe BucketLevelPermissions
a} :: BucketPermissionConfiguration)

instance Data.FromJSON BucketPermissionConfiguration where
  parseJSON :: Value -> Parser BucketPermissionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BucketPermissionConfiguration"
      ( \Object
x ->
          Maybe AccountLevelPermissions
-> Maybe BucketLevelPermissions -> BucketPermissionConfiguration
BucketPermissionConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"accountLevelPermissions")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"bucketLevelPermissions")
      )

instance
  Prelude.Hashable
    BucketPermissionConfiguration
  where
  hashWithSalt :: Int -> BucketPermissionConfiguration -> Int
hashWithSalt Int
_salt BucketPermissionConfiguration' {Maybe AccountLevelPermissions
Maybe BucketLevelPermissions
bucketLevelPermissions :: Maybe BucketLevelPermissions
accountLevelPermissions :: Maybe AccountLevelPermissions
$sel:bucketLevelPermissions:BucketPermissionConfiguration' :: BucketPermissionConfiguration -> Maybe BucketLevelPermissions
$sel:accountLevelPermissions:BucketPermissionConfiguration' :: BucketPermissionConfiguration -> Maybe AccountLevelPermissions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccountLevelPermissions
accountLevelPermissions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BucketLevelPermissions
bucketLevelPermissions

instance Prelude.NFData BucketPermissionConfiguration where
  rnf :: BucketPermissionConfiguration -> ()
rnf BucketPermissionConfiguration' {Maybe AccountLevelPermissions
Maybe BucketLevelPermissions
bucketLevelPermissions :: Maybe BucketLevelPermissions
accountLevelPermissions :: Maybe AccountLevelPermissions
$sel:bucketLevelPermissions:BucketPermissionConfiguration' :: BucketPermissionConfiguration -> Maybe BucketLevelPermissions
$sel:accountLevelPermissions:BucketPermissionConfiguration' :: BucketPermissionConfiguration -> Maybe AccountLevelPermissions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AccountLevelPermissions
accountLevelPermissions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BucketLevelPermissions
bucketLevelPermissions