{-# 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.GuardDuty.Types.BucketLevelPermissions
-- 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.GuardDuty.Types.BucketLevelPermissions where

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types.AccessControlList
import Amazonka.GuardDuty.Types.BlockPublicAccess
import Amazonka.GuardDuty.Types.BucketPolicy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the bucket level permissions for the S3
-- bucket.
--
-- /See:/ 'newBucketLevelPermissions' smart constructor.
data BucketLevelPermissions = BucketLevelPermissions'
  { -- | Contains information on how Access Control Policies are applied to the
    -- bucket.
    BucketLevelPermissions -> Maybe AccessControlList
accessControlList :: Prelude.Maybe AccessControlList,
    -- | Contains information on which account level S3 Block Public Access
    -- settings are applied to the S3 bucket.
    BucketLevelPermissions -> Maybe BlockPublicAccess
blockPublicAccess :: Prelude.Maybe BlockPublicAccess,
    -- | Contains information on the bucket policies for the S3 bucket.
    BucketLevelPermissions -> Maybe BucketPolicy
bucketPolicy :: Prelude.Maybe BucketPolicy
  }
  deriving (BucketLevelPermissions -> BucketLevelPermissions -> Bool
(BucketLevelPermissions -> BucketLevelPermissions -> Bool)
-> (BucketLevelPermissions -> BucketLevelPermissions -> Bool)
-> Eq BucketLevelPermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketLevelPermissions -> BucketLevelPermissions -> Bool
$c/= :: BucketLevelPermissions -> BucketLevelPermissions -> Bool
== :: BucketLevelPermissions -> BucketLevelPermissions -> Bool
$c== :: BucketLevelPermissions -> BucketLevelPermissions -> Bool
Prelude.Eq, ReadPrec [BucketLevelPermissions]
ReadPrec BucketLevelPermissions
Int -> ReadS BucketLevelPermissions
ReadS [BucketLevelPermissions]
(Int -> ReadS BucketLevelPermissions)
-> ReadS [BucketLevelPermissions]
-> ReadPrec BucketLevelPermissions
-> ReadPrec [BucketLevelPermissions]
-> Read BucketLevelPermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketLevelPermissions]
$creadListPrec :: ReadPrec [BucketLevelPermissions]
readPrec :: ReadPrec BucketLevelPermissions
$creadPrec :: ReadPrec BucketLevelPermissions
readList :: ReadS [BucketLevelPermissions]
$creadList :: ReadS [BucketLevelPermissions]
readsPrec :: Int -> ReadS BucketLevelPermissions
$creadsPrec :: Int -> ReadS BucketLevelPermissions
Prelude.Read, Int -> BucketLevelPermissions -> ShowS
[BucketLevelPermissions] -> ShowS
BucketLevelPermissions -> String
(Int -> BucketLevelPermissions -> ShowS)
-> (BucketLevelPermissions -> String)
-> ([BucketLevelPermissions] -> ShowS)
-> Show BucketLevelPermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketLevelPermissions] -> ShowS
$cshowList :: [BucketLevelPermissions] -> ShowS
show :: BucketLevelPermissions -> String
$cshow :: BucketLevelPermissions -> String
showsPrec :: Int -> BucketLevelPermissions -> ShowS
$cshowsPrec :: Int -> BucketLevelPermissions -> ShowS
Prelude.Show, (forall x. BucketLevelPermissions -> Rep BucketLevelPermissions x)
-> (forall x.
    Rep BucketLevelPermissions x -> BucketLevelPermissions)
-> Generic BucketLevelPermissions
forall x. Rep BucketLevelPermissions x -> BucketLevelPermissions
forall x. BucketLevelPermissions -> Rep BucketLevelPermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BucketLevelPermissions x -> BucketLevelPermissions
$cfrom :: forall x. BucketLevelPermissions -> Rep BucketLevelPermissions x
Prelude.Generic)

-- |
-- Create a value of 'BucketLevelPermissions' 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:
--
-- 'accessControlList', 'bucketLevelPermissions_accessControlList' - Contains information on how Access Control Policies are applied to the
-- bucket.
--
-- 'blockPublicAccess', 'bucketLevelPermissions_blockPublicAccess' - Contains information on which account level S3 Block Public Access
-- settings are applied to the S3 bucket.
--
-- 'bucketPolicy', 'bucketLevelPermissions_bucketPolicy' - Contains information on the bucket policies for the S3 bucket.
newBucketLevelPermissions ::
  BucketLevelPermissions
newBucketLevelPermissions :: BucketLevelPermissions
newBucketLevelPermissions =
  BucketLevelPermissions' :: Maybe AccessControlList
-> Maybe BlockPublicAccess
-> Maybe BucketPolicy
-> BucketLevelPermissions
BucketLevelPermissions'
    { $sel:accessControlList:BucketLevelPermissions' :: Maybe AccessControlList
accessControlList =
        Maybe AccessControlList
forall a. Maybe a
Prelude.Nothing,
      $sel:blockPublicAccess:BucketLevelPermissions' :: Maybe BlockPublicAccess
blockPublicAccess = Maybe BlockPublicAccess
forall a. Maybe a
Prelude.Nothing,
      $sel:bucketPolicy:BucketLevelPermissions' :: Maybe BucketPolicy
bucketPolicy = Maybe BucketPolicy
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains information on how Access Control Policies are applied to the
-- bucket.
bucketLevelPermissions_accessControlList :: Lens.Lens' BucketLevelPermissions (Prelude.Maybe AccessControlList)
bucketLevelPermissions_accessControlList :: (Maybe AccessControlList -> f (Maybe AccessControlList))
-> BucketLevelPermissions -> f BucketLevelPermissions
bucketLevelPermissions_accessControlList = (BucketLevelPermissions -> Maybe AccessControlList)
-> (BucketLevelPermissions
    -> Maybe AccessControlList -> BucketLevelPermissions)
-> Lens
     BucketLevelPermissions
     BucketLevelPermissions
     (Maybe AccessControlList)
     (Maybe AccessControlList)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketLevelPermissions' {Maybe AccessControlList
accessControlList :: Maybe AccessControlList
$sel:accessControlList:BucketLevelPermissions' :: BucketLevelPermissions -> Maybe AccessControlList
accessControlList} -> Maybe AccessControlList
accessControlList) (\s :: BucketLevelPermissions
s@BucketLevelPermissions' {} Maybe AccessControlList
a -> BucketLevelPermissions
s {$sel:accessControlList:BucketLevelPermissions' :: Maybe AccessControlList
accessControlList = Maybe AccessControlList
a} :: BucketLevelPermissions)

-- | Contains information on which account level S3 Block Public Access
-- settings are applied to the S3 bucket.
bucketLevelPermissions_blockPublicAccess :: Lens.Lens' BucketLevelPermissions (Prelude.Maybe BlockPublicAccess)
bucketLevelPermissions_blockPublicAccess :: (Maybe BlockPublicAccess -> f (Maybe BlockPublicAccess))
-> BucketLevelPermissions -> f BucketLevelPermissions
bucketLevelPermissions_blockPublicAccess = (BucketLevelPermissions -> Maybe BlockPublicAccess)
-> (BucketLevelPermissions
    -> Maybe BlockPublicAccess -> BucketLevelPermissions)
-> Lens
     BucketLevelPermissions
     BucketLevelPermissions
     (Maybe BlockPublicAccess)
     (Maybe BlockPublicAccess)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketLevelPermissions' {Maybe BlockPublicAccess
blockPublicAccess :: Maybe BlockPublicAccess
$sel:blockPublicAccess:BucketLevelPermissions' :: BucketLevelPermissions -> Maybe BlockPublicAccess
blockPublicAccess} -> Maybe BlockPublicAccess
blockPublicAccess) (\s :: BucketLevelPermissions
s@BucketLevelPermissions' {} Maybe BlockPublicAccess
a -> BucketLevelPermissions
s {$sel:blockPublicAccess:BucketLevelPermissions' :: Maybe BlockPublicAccess
blockPublicAccess = Maybe BlockPublicAccess
a} :: BucketLevelPermissions)

-- | Contains information on the bucket policies for the S3 bucket.
bucketLevelPermissions_bucketPolicy :: Lens.Lens' BucketLevelPermissions (Prelude.Maybe BucketPolicy)
bucketLevelPermissions_bucketPolicy :: (Maybe BucketPolicy -> f (Maybe BucketPolicy))
-> BucketLevelPermissions -> f BucketLevelPermissions
bucketLevelPermissions_bucketPolicy = (BucketLevelPermissions -> Maybe BucketPolicy)
-> (BucketLevelPermissions
    -> Maybe BucketPolicy -> BucketLevelPermissions)
-> Lens
     BucketLevelPermissions
     BucketLevelPermissions
     (Maybe BucketPolicy)
     (Maybe BucketPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketLevelPermissions' {Maybe BucketPolicy
bucketPolicy :: Maybe BucketPolicy
$sel:bucketPolicy:BucketLevelPermissions' :: BucketLevelPermissions -> Maybe BucketPolicy
bucketPolicy} -> Maybe BucketPolicy
bucketPolicy) (\s :: BucketLevelPermissions
s@BucketLevelPermissions' {} Maybe BucketPolicy
a -> BucketLevelPermissions
s {$sel:bucketPolicy:BucketLevelPermissions' :: Maybe BucketPolicy
bucketPolicy = Maybe BucketPolicy
a} :: BucketLevelPermissions)

instance Core.FromJSON BucketLevelPermissions where
  parseJSON :: Value -> Parser BucketLevelPermissions
parseJSON =
    String
-> (Object -> Parser BucketLevelPermissions)
-> Value
-> Parser BucketLevelPermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BucketLevelPermissions"
      ( \Object
x ->
          Maybe AccessControlList
-> Maybe BlockPublicAccess
-> Maybe BucketPolicy
-> BucketLevelPermissions
BucketLevelPermissions'
            (Maybe AccessControlList
 -> Maybe BlockPublicAccess
 -> Maybe BucketPolicy
 -> BucketLevelPermissions)
-> Parser (Maybe AccessControlList)
-> Parser
     (Maybe BlockPublicAccess
      -> Maybe BucketPolicy -> BucketLevelPermissions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AccessControlList)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"accessControlList")
            Parser
  (Maybe BlockPublicAccess
   -> Maybe BucketPolicy -> BucketLevelPermissions)
-> Parser (Maybe BlockPublicAccess)
-> Parser (Maybe BucketPolicy -> BucketLevelPermissions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BlockPublicAccess)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"blockPublicAccess")
            Parser (Maybe BucketPolicy -> BucketLevelPermissions)
-> Parser (Maybe BucketPolicy) -> Parser BucketLevelPermissions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BucketPolicy)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"bucketPolicy")
      )

instance Prelude.Hashable BucketLevelPermissions

instance Prelude.NFData BucketLevelPermissions