{-# 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-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.MacieV2.Types.BucketPermissionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 bucket-level permissions settings for the bucket.
    BucketPermissionConfiguration -> Maybe BucketLevelPermissions
bucketLevelPermissions :: Prelude.Maybe BucketLevelPermissions,
    -- | The account-level permissions settings that apply to the bucket.
    BucketPermissionConfiguration -> Maybe AccountLevelPermissions
accountLevelPermissions :: Prelude.Maybe AccountLevelPermissions
  }
  deriving (BucketPermissionConfiguration
-> BucketPermissionConfiguration -> Bool
(BucketPermissionConfiguration
 -> BucketPermissionConfiguration -> Bool)
-> (BucketPermissionConfiguration
    -> BucketPermissionConfiguration -> Bool)
-> Eq BucketPermissionConfiguration
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]
(Int -> ReadS BucketPermissionConfiguration)
-> ReadS [BucketPermissionConfiguration]
-> ReadPrec BucketPermissionConfiguration
-> ReadPrec [BucketPermissionConfiguration]
-> Read 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
(Int -> BucketPermissionConfiguration -> ShowS)
-> (BucketPermissionConfiguration -> String)
-> ([BucketPermissionConfiguration] -> ShowS)
-> Show BucketPermissionConfiguration
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.
 BucketPermissionConfiguration
 -> Rep BucketPermissionConfiguration x)
-> (forall x.
    Rep BucketPermissionConfiguration x
    -> BucketPermissionConfiguration)
-> Generic BucketPermissionConfiguration
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:
--
-- 'bucketLevelPermissions', 'bucketPermissionConfiguration_bucketLevelPermissions' - The bucket-level permissions settings for the bucket.
--
-- 'accountLevelPermissions', 'bucketPermissionConfiguration_accountLevelPermissions' - The account-level permissions settings that apply to the bucket.
newBucketPermissionConfiguration ::
  BucketPermissionConfiguration
newBucketPermissionConfiguration :: BucketPermissionConfiguration
newBucketPermissionConfiguration =
  BucketPermissionConfiguration' :: Maybe BucketLevelPermissions
-> Maybe AccountLevelPermissions -> BucketPermissionConfiguration
BucketPermissionConfiguration'
    { $sel:bucketLevelPermissions:BucketPermissionConfiguration' :: Maybe BucketLevelPermissions
bucketLevelPermissions =
        Maybe BucketLevelPermissions
forall a. Maybe a
Prelude.Nothing,
      $sel:accountLevelPermissions:BucketPermissionConfiguration' :: Maybe AccountLevelPermissions
accountLevelPermissions = Maybe AccountLevelPermissions
forall a. Maybe a
Prelude.Nothing
    }

-- | The bucket-level permissions settings for the bucket.
bucketPermissionConfiguration_bucketLevelPermissions :: Lens.Lens' BucketPermissionConfiguration (Prelude.Maybe BucketLevelPermissions)
bucketPermissionConfiguration_bucketLevelPermissions :: (Maybe BucketLevelPermissions -> f (Maybe BucketLevelPermissions))
-> BucketPermissionConfiguration -> f BucketPermissionConfiguration
bucketPermissionConfiguration_bucketLevelPermissions = (BucketPermissionConfiguration -> Maybe BucketLevelPermissions)
-> (BucketPermissionConfiguration
    -> Maybe BucketLevelPermissions -> BucketPermissionConfiguration)
-> Lens
     BucketPermissionConfiguration
     BucketPermissionConfiguration
     (Maybe BucketLevelPermissions)
     (Maybe 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)

-- | The account-level permissions settings that apply to the bucket.
bucketPermissionConfiguration_accountLevelPermissions :: Lens.Lens' BucketPermissionConfiguration (Prelude.Maybe AccountLevelPermissions)
bucketPermissionConfiguration_accountLevelPermissions :: (Maybe AccountLevelPermissions
 -> f (Maybe AccountLevelPermissions))
-> BucketPermissionConfiguration -> f BucketPermissionConfiguration
bucketPermissionConfiguration_accountLevelPermissions = (BucketPermissionConfiguration -> Maybe AccountLevelPermissions)
-> (BucketPermissionConfiguration
    -> Maybe AccountLevelPermissions -> BucketPermissionConfiguration)
-> Lens
     BucketPermissionConfiguration
     BucketPermissionConfiguration
     (Maybe AccountLevelPermissions)
     (Maybe 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)

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

instance
  Prelude.Hashable
    BucketPermissionConfiguration

instance Prelude.NFData BucketPermissionConfiguration