{-# 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-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.BucketPublicAccess where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | The account-level and bucket-level permissions settings for the bucket.
    BucketPublicAccess -> Maybe BucketPermissionConfiguration
permissionConfiguration :: Prelude.Maybe BucketPermissionConfiguration,
    -- | 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
  }
  deriving (BucketPublicAccess -> BucketPublicAccess -> Bool
(BucketPublicAccess -> BucketPublicAccess -> Bool)
-> (BucketPublicAccess -> BucketPublicAccess -> Bool)
-> Eq BucketPublicAccess
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]
(Int -> ReadS BucketPublicAccess)
-> ReadS [BucketPublicAccess]
-> ReadPrec BucketPublicAccess
-> ReadPrec [BucketPublicAccess]
-> Read 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
(Int -> BucketPublicAccess -> ShowS)
-> (BucketPublicAccess -> String)
-> ([BucketPublicAccess] -> ShowS)
-> Show BucketPublicAccess
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. BucketPublicAccess -> Rep BucketPublicAccess x)
-> (forall x. Rep BucketPublicAccess x -> BucketPublicAccess)
-> Generic BucketPublicAccess
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:
--
-- 'permissionConfiguration', 'bucketPublicAccess_permissionConfiguration' - The account-level and bucket-level permissions settings for the bucket.
--
-- '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.
newBucketPublicAccess ::
  BucketPublicAccess
newBucketPublicAccess :: BucketPublicAccess
newBucketPublicAccess =
  BucketPublicAccess' :: Maybe BucketPermissionConfiguration
-> Maybe EffectivePermission -> BucketPublicAccess
BucketPublicAccess'
    { $sel:permissionConfiguration:BucketPublicAccess' :: Maybe BucketPermissionConfiguration
permissionConfiguration =
        Maybe BucketPermissionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:effectivePermission:BucketPublicAccess' :: Maybe EffectivePermission
effectivePermission = Maybe EffectivePermission
forall a. Maybe a
Prelude.Nothing
    }

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

-- | 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 :: (Maybe EffectivePermission -> f (Maybe EffectivePermission))
-> BucketPublicAccess -> f BucketPublicAccess
bucketPublicAccess_effectivePermission = (BucketPublicAccess -> Maybe EffectivePermission)
-> (BucketPublicAccess
    -> Maybe EffectivePermission -> BucketPublicAccess)
-> Lens
     BucketPublicAccess
     BucketPublicAccess
     (Maybe EffectivePermission)
     (Maybe 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)

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

instance Prelude.Hashable BucketPublicAccess

instance Prelude.NFData BucketPublicAccess