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

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types.PermissionConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the public access policies that apply to the S3 bucket.
--
-- /See:/ 'newPublicAccess' smart constructor.
data PublicAccess = PublicAccess'
  { -- | Contains information about how permissions are configured for the S3
    -- bucket.
    PublicAccess -> Maybe PermissionConfiguration
permissionConfiguration :: Prelude.Maybe PermissionConfiguration,
    -- | Describes the effective permission on this bucket after factoring all
    -- attached policies.
    PublicAccess -> Maybe Text
effectivePermission :: Prelude.Maybe Prelude.Text
  }
  deriving (PublicAccess -> PublicAccess -> Bool
(PublicAccess -> PublicAccess -> Bool)
-> (PublicAccess -> PublicAccess -> Bool) -> Eq PublicAccess
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PublicAccess -> PublicAccess -> Bool
$c/= :: PublicAccess -> PublicAccess -> Bool
== :: PublicAccess -> PublicAccess -> Bool
$c== :: PublicAccess -> PublicAccess -> Bool
Prelude.Eq, ReadPrec [PublicAccess]
ReadPrec PublicAccess
Int -> ReadS PublicAccess
ReadS [PublicAccess]
(Int -> ReadS PublicAccess)
-> ReadS [PublicAccess]
-> ReadPrec PublicAccess
-> ReadPrec [PublicAccess]
-> Read PublicAccess
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PublicAccess]
$creadListPrec :: ReadPrec [PublicAccess]
readPrec :: ReadPrec PublicAccess
$creadPrec :: ReadPrec PublicAccess
readList :: ReadS [PublicAccess]
$creadList :: ReadS [PublicAccess]
readsPrec :: Int -> ReadS PublicAccess
$creadsPrec :: Int -> ReadS PublicAccess
Prelude.Read, Int -> PublicAccess -> ShowS
[PublicAccess] -> ShowS
PublicAccess -> String
(Int -> PublicAccess -> ShowS)
-> (PublicAccess -> String)
-> ([PublicAccess] -> ShowS)
-> Show PublicAccess
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublicAccess] -> ShowS
$cshowList :: [PublicAccess] -> ShowS
show :: PublicAccess -> String
$cshow :: PublicAccess -> String
showsPrec :: Int -> PublicAccess -> ShowS
$cshowsPrec :: Int -> PublicAccess -> ShowS
Prelude.Show, (forall x. PublicAccess -> Rep PublicAccess x)
-> (forall x. Rep PublicAccess x -> PublicAccess)
-> Generic PublicAccess
forall x. Rep PublicAccess x -> PublicAccess
forall x. PublicAccess -> Rep PublicAccess x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PublicAccess x -> PublicAccess
$cfrom :: forall x. PublicAccess -> Rep PublicAccess x
Prelude.Generic)

-- |
-- Create a value of 'PublicAccess' 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', 'publicAccess_permissionConfiguration' - Contains information about how permissions are configured for the S3
-- bucket.
--
-- 'effectivePermission', 'publicAccess_effectivePermission' - Describes the effective permission on this bucket after factoring all
-- attached policies.
newPublicAccess ::
  PublicAccess
newPublicAccess :: PublicAccess
newPublicAccess =
  PublicAccess' :: Maybe PermissionConfiguration -> Maybe Text -> PublicAccess
PublicAccess'
    { $sel:permissionConfiguration:PublicAccess' :: Maybe PermissionConfiguration
permissionConfiguration =
        Maybe PermissionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:effectivePermission:PublicAccess' :: Maybe Text
effectivePermission = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains information about how permissions are configured for the S3
-- bucket.
publicAccess_permissionConfiguration :: Lens.Lens' PublicAccess (Prelude.Maybe PermissionConfiguration)
publicAccess_permissionConfiguration :: (Maybe PermissionConfiguration
 -> f (Maybe PermissionConfiguration))
-> PublicAccess -> f PublicAccess
publicAccess_permissionConfiguration = (PublicAccess -> Maybe PermissionConfiguration)
-> (PublicAccess -> Maybe PermissionConfiguration -> PublicAccess)
-> Lens
     PublicAccess
     PublicAccess
     (Maybe PermissionConfiguration)
     (Maybe PermissionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicAccess' {Maybe PermissionConfiguration
permissionConfiguration :: Maybe PermissionConfiguration
$sel:permissionConfiguration:PublicAccess' :: PublicAccess -> Maybe PermissionConfiguration
permissionConfiguration} -> Maybe PermissionConfiguration
permissionConfiguration) (\s :: PublicAccess
s@PublicAccess' {} Maybe PermissionConfiguration
a -> PublicAccess
s {$sel:permissionConfiguration:PublicAccess' :: Maybe PermissionConfiguration
permissionConfiguration = Maybe PermissionConfiguration
a} :: PublicAccess)

-- | Describes the effective permission on this bucket after factoring all
-- attached policies.
publicAccess_effectivePermission :: Lens.Lens' PublicAccess (Prelude.Maybe Prelude.Text)
publicAccess_effectivePermission :: (Maybe Text -> f (Maybe Text)) -> PublicAccess -> f PublicAccess
publicAccess_effectivePermission = (PublicAccess -> Maybe Text)
-> (PublicAccess -> Maybe Text -> PublicAccess)
-> Lens PublicAccess PublicAccess (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicAccess' {Maybe Text
effectivePermission :: Maybe Text
$sel:effectivePermission:PublicAccess' :: PublicAccess -> Maybe Text
effectivePermission} -> Maybe Text
effectivePermission) (\s :: PublicAccess
s@PublicAccess' {} Maybe Text
a -> PublicAccess
s {$sel:effectivePermission:PublicAccess' :: Maybe Text
effectivePermission = Maybe Text
a} :: PublicAccess)

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

instance Prelude.Hashable PublicAccess

instance Prelude.NFData PublicAccess