{-# 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.BucketPublicAccess
-- 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.BucketPublicAccess 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.BucketPermissionConfiguration
import Amazonka.MacieV2.Types.EffectivePermission
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the permissions settings that determine
-- whether an S3 bucket is publicly accessible.
--
-- /See:/ 'newBucketPublicAccess' smart constructor.
data BucketPublicAccess = BucketPublicAccess'
  { -- | Specifies whether the bucket is publicly accessible due to the
    -- combination of permissions settings that apply to the bucket. Possible
    -- values are:
    --
    -- -   NOT_PUBLIC - The bucket isn\'t publicly accessible.
    --
    -- -   PUBLIC - The bucket is publicly accessible.
    --
    -- -   UNKNOWN - Amazon Macie can\'t determine whether the bucket is
    --     publicly accessible.
    BucketPublicAccess -> Maybe EffectivePermission
effectivePermission :: Prelude.Maybe EffectivePermission,
    -- | The account-level and bucket-level permissions settings for the bucket.
    BucketPublicAccess -> Maybe BucketPermissionConfiguration
permissionConfiguration :: Prelude.Maybe BucketPermissionConfiguration
  }
  deriving (BucketPublicAccess -> BucketPublicAccess -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BucketPublicAccess -> BucketPublicAccess -> Bool
$c/= :: BucketPublicAccess -> BucketPublicAccess -> Bool
== :: BucketPublicAccess -> BucketPublicAccess -> Bool
$c== :: BucketPublicAccess -> BucketPublicAccess -> Bool
Prelude.Eq, ReadPrec [BucketPublicAccess]
ReadPrec BucketPublicAccess
Int -> ReadS BucketPublicAccess
ReadS [BucketPublicAccess]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BucketPublicAccess]
$creadListPrec :: ReadPrec [BucketPublicAccess]
readPrec :: ReadPrec BucketPublicAccess
$creadPrec :: ReadPrec BucketPublicAccess
readList :: ReadS [BucketPublicAccess]
$creadList :: ReadS [BucketPublicAccess]
readsPrec :: Int -> ReadS BucketPublicAccess
$creadsPrec :: Int -> ReadS BucketPublicAccess
Prelude.Read, Int -> BucketPublicAccess -> ShowS
[BucketPublicAccess] -> ShowS
BucketPublicAccess -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BucketPublicAccess] -> ShowS
$cshowList :: [BucketPublicAccess] -> ShowS
show :: BucketPublicAccess -> String
$cshow :: BucketPublicAccess -> String
showsPrec :: Int -> BucketPublicAccess -> ShowS
$cshowsPrec :: Int -> BucketPublicAccess -> ShowS
Prelude.Show, forall x. Rep BucketPublicAccess x -> BucketPublicAccess
forall x. BucketPublicAccess -> Rep BucketPublicAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BucketPublicAccess x -> BucketPublicAccess
$cfrom :: forall x. BucketPublicAccess -> Rep BucketPublicAccess x
Prelude.Generic)

-- |
-- Create a value of 'BucketPublicAccess' 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:
--
-- 'effectivePermission', 'bucketPublicAccess_effectivePermission' - Specifies whether the bucket is publicly accessible due to the
-- combination of permissions settings that apply to the bucket. Possible
-- values are:
--
-- -   NOT_PUBLIC - The bucket isn\'t publicly accessible.
--
-- -   PUBLIC - The bucket is publicly accessible.
--
-- -   UNKNOWN - Amazon Macie can\'t determine whether the bucket is
--     publicly accessible.
--
-- 'permissionConfiguration', 'bucketPublicAccess_permissionConfiguration' - The account-level and bucket-level permissions settings for the bucket.
newBucketPublicAccess ::
  BucketPublicAccess
newBucketPublicAccess :: BucketPublicAccess
newBucketPublicAccess =
  BucketPublicAccess'
    { $sel:effectivePermission:BucketPublicAccess' :: Maybe EffectivePermission
effectivePermission =
        forall a. Maybe a
Prelude.Nothing,
      $sel:permissionConfiguration:BucketPublicAccess' :: Maybe BucketPermissionConfiguration
permissionConfiguration = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the bucket is publicly accessible due to the
-- combination of permissions settings that apply to the bucket. Possible
-- values are:
--
-- -   NOT_PUBLIC - The bucket isn\'t publicly accessible.
--
-- -   PUBLIC - The bucket is publicly accessible.
--
-- -   UNKNOWN - Amazon Macie can\'t determine whether the bucket is
--     publicly accessible.
bucketPublicAccess_effectivePermission :: Lens.Lens' BucketPublicAccess (Prelude.Maybe EffectivePermission)
bucketPublicAccess_effectivePermission :: Lens' BucketPublicAccess (Maybe EffectivePermission)
bucketPublicAccess_effectivePermission = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BucketPublicAccess' {Maybe EffectivePermission
effectivePermission :: Maybe EffectivePermission
$sel:effectivePermission:BucketPublicAccess' :: BucketPublicAccess -> Maybe EffectivePermission
effectivePermission} -> Maybe EffectivePermission
effectivePermission) (\s :: BucketPublicAccess
s@BucketPublicAccess' {} Maybe EffectivePermission
a -> BucketPublicAccess
s {$sel:effectivePermission:BucketPublicAccess' :: Maybe EffectivePermission
effectivePermission = Maybe EffectivePermission
a} :: BucketPublicAccess)

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

instance Data.FromJSON BucketPublicAccess where
  parseJSON :: Value -> Parser BucketPublicAccess
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BucketPublicAccess"
      ( \Object
x ->
          Maybe EffectivePermission
-> Maybe BucketPermissionConfiguration -> BucketPublicAccess
BucketPublicAccess'
            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
"effectivePermission")
            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
"permissionConfiguration")
      )

instance Prelude.Hashable BucketPublicAccess where
  hashWithSalt :: Int -> BucketPublicAccess -> Int
hashWithSalt Int
_salt BucketPublicAccess' {Maybe BucketPermissionConfiguration
Maybe EffectivePermission
permissionConfiguration :: Maybe BucketPermissionConfiguration
effectivePermission :: Maybe EffectivePermission
$sel:permissionConfiguration:BucketPublicAccess' :: BucketPublicAccess -> Maybe BucketPermissionConfiguration
$sel:effectivePermission:BucketPublicAccess' :: BucketPublicAccess -> Maybe EffectivePermission
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EffectivePermission
effectivePermission
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BucketPermissionConfiguration
permissionConfiguration

instance Prelude.NFData BucketPublicAccess where
  rnf :: BucketPublicAccess -> ()
rnf BucketPublicAccess' {Maybe BucketPermissionConfiguration
Maybe EffectivePermission
permissionConfiguration :: Maybe BucketPermissionConfiguration
effectivePermission :: Maybe EffectivePermission
$sel:permissionConfiguration:BucketPublicAccess' :: BucketPublicAccess -> Maybe BucketPermissionConfiguration
$sel:effectivePermission:BucketPublicAccess' :: BucketPublicAccess -> Maybe EffectivePermission
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EffectivePermission
effectivePermission
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe BucketPermissionConfiguration
permissionConfiguration