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

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types.AccountLevelPermissions
import Amazonka.GuardDuty.Types.BucketLevelPermissions
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about how permissions are configured for the S3
-- bucket.
--
-- /See:/ 'newPermissionConfiguration' smart constructor.
data PermissionConfiguration = PermissionConfiguration'
  { -- | Contains information about the bucket level permissions for the S3
    -- bucket.
    PermissionConfiguration -> Maybe BucketLevelPermissions
bucketLevelPermissions :: Prelude.Maybe BucketLevelPermissions,
    -- | Contains information about the account level permissions on the S3
    -- bucket.
    PermissionConfiguration -> Maybe AccountLevelPermissions
accountLevelPermissions :: Prelude.Maybe AccountLevelPermissions
  }
  deriving (PermissionConfiguration -> PermissionConfiguration -> Bool
(PermissionConfiguration -> PermissionConfiguration -> Bool)
-> (PermissionConfiguration -> PermissionConfiguration -> Bool)
-> Eq PermissionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PermissionConfiguration -> PermissionConfiguration -> Bool
$c/= :: PermissionConfiguration -> PermissionConfiguration -> Bool
== :: PermissionConfiguration -> PermissionConfiguration -> Bool
$c== :: PermissionConfiguration -> PermissionConfiguration -> Bool
Prelude.Eq, ReadPrec [PermissionConfiguration]
ReadPrec PermissionConfiguration
Int -> ReadS PermissionConfiguration
ReadS [PermissionConfiguration]
(Int -> ReadS PermissionConfiguration)
-> ReadS [PermissionConfiguration]
-> ReadPrec PermissionConfiguration
-> ReadPrec [PermissionConfiguration]
-> Read PermissionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PermissionConfiguration]
$creadListPrec :: ReadPrec [PermissionConfiguration]
readPrec :: ReadPrec PermissionConfiguration
$creadPrec :: ReadPrec PermissionConfiguration
readList :: ReadS [PermissionConfiguration]
$creadList :: ReadS [PermissionConfiguration]
readsPrec :: Int -> ReadS PermissionConfiguration
$creadsPrec :: Int -> ReadS PermissionConfiguration
Prelude.Read, Int -> PermissionConfiguration -> ShowS
[PermissionConfiguration] -> ShowS
PermissionConfiguration -> String
(Int -> PermissionConfiguration -> ShowS)
-> (PermissionConfiguration -> String)
-> ([PermissionConfiguration] -> ShowS)
-> Show PermissionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PermissionConfiguration] -> ShowS
$cshowList :: [PermissionConfiguration] -> ShowS
show :: PermissionConfiguration -> String
$cshow :: PermissionConfiguration -> String
showsPrec :: Int -> PermissionConfiguration -> ShowS
$cshowsPrec :: Int -> PermissionConfiguration -> ShowS
Prelude.Show, (forall x.
 PermissionConfiguration -> Rep PermissionConfiguration x)
-> (forall x.
    Rep PermissionConfiguration x -> PermissionConfiguration)
-> Generic PermissionConfiguration
forall x. Rep PermissionConfiguration x -> PermissionConfiguration
forall x. PermissionConfiguration -> Rep PermissionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PermissionConfiguration x -> PermissionConfiguration
$cfrom :: forall x. PermissionConfiguration -> Rep PermissionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'PermissionConfiguration' 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', 'permissionConfiguration_bucketLevelPermissions' - Contains information about the bucket level permissions for the S3
-- bucket.
--
-- 'accountLevelPermissions', 'permissionConfiguration_accountLevelPermissions' - Contains information about the account level permissions on the S3
-- bucket.
newPermissionConfiguration ::
  PermissionConfiguration
newPermissionConfiguration :: PermissionConfiguration
newPermissionConfiguration =
  PermissionConfiguration' :: Maybe BucketLevelPermissions
-> Maybe AccountLevelPermissions -> PermissionConfiguration
PermissionConfiguration'
    { $sel:bucketLevelPermissions:PermissionConfiguration' :: Maybe BucketLevelPermissions
bucketLevelPermissions =
        Maybe BucketLevelPermissions
forall a. Maybe a
Prelude.Nothing,
      $sel:accountLevelPermissions:PermissionConfiguration' :: Maybe AccountLevelPermissions
accountLevelPermissions = Maybe AccountLevelPermissions
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains information about the bucket level permissions for the S3
-- bucket.
permissionConfiguration_bucketLevelPermissions :: Lens.Lens' PermissionConfiguration (Prelude.Maybe BucketLevelPermissions)
permissionConfiguration_bucketLevelPermissions :: (Maybe BucketLevelPermissions -> f (Maybe BucketLevelPermissions))
-> PermissionConfiguration -> f PermissionConfiguration
permissionConfiguration_bucketLevelPermissions = (PermissionConfiguration -> Maybe BucketLevelPermissions)
-> (PermissionConfiguration
    -> Maybe BucketLevelPermissions -> PermissionConfiguration)
-> Lens
     PermissionConfiguration
     PermissionConfiguration
     (Maybe BucketLevelPermissions)
     (Maybe BucketLevelPermissions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PermissionConfiguration' {Maybe BucketLevelPermissions
bucketLevelPermissions :: Maybe BucketLevelPermissions
$sel:bucketLevelPermissions:PermissionConfiguration' :: PermissionConfiguration -> Maybe BucketLevelPermissions
bucketLevelPermissions} -> Maybe BucketLevelPermissions
bucketLevelPermissions) (\s :: PermissionConfiguration
s@PermissionConfiguration' {} Maybe BucketLevelPermissions
a -> PermissionConfiguration
s {$sel:bucketLevelPermissions:PermissionConfiguration' :: Maybe BucketLevelPermissions
bucketLevelPermissions = Maybe BucketLevelPermissions
a} :: PermissionConfiguration)

-- | Contains information about the account level permissions on the S3
-- bucket.
permissionConfiguration_accountLevelPermissions :: Lens.Lens' PermissionConfiguration (Prelude.Maybe AccountLevelPermissions)
permissionConfiguration_accountLevelPermissions :: (Maybe AccountLevelPermissions
 -> f (Maybe AccountLevelPermissions))
-> PermissionConfiguration -> f PermissionConfiguration
permissionConfiguration_accountLevelPermissions = (PermissionConfiguration -> Maybe AccountLevelPermissions)
-> (PermissionConfiguration
    -> Maybe AccountLevelPermissions -> PermissionConfiguration)
-> Lens
     PermissionConfiguration
     PermissionConfiguration
     (Maybe AccountLevelPermissions)
     (Maybe AccountLevelPermissions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PermissionConfiguration' {Maybe AccountLevelPermissions
accountLevelPermissions :: Maybe AccountLevelPermissions
$sel:accountLevelPermissions:PermissionConfiguration' :: PermissionConfiguration -> Maybe AccountLevelPermissions
accountLevelPermissions} -> Maybe AccountLevelPermissions
accountLevelPermissions) (\s :: PermissionConfiguration
s@PermissionConfiguration' {} Maybe AccountLevelPermissions
a -> PermissionConfiguration
s {$sel:accountLevelPermissions:PermissionConfiguration' :: Maybe AccountLevelPermissions
accountLevelPermissions = Maybe AccountLevelPermissions
a} :: PermissionConfiguration)

instance Core.FromJSON PermissionConfiguration where
  parseJSON :: Value -> Parser PermissionConfiguration
parseJSON =
    String
-> (Object -> Parser PermissionConfiguration)
-> Value
-> Parser PermissionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PermissionConfiguration"
      ( \Object
x ->
          Maybe BucketLevelPermissions
-> Maybe AccountLevelPermissions -> PermissionConfiguration
PermissionConfiguration'
            (Maybe BucketLevelPermissions
 -> Maybe AccountLevelPermissions -> PermissionConfiguration)
-> Parser (Maybe BucketLevelPermissions)
-> Parser
     (Maybe AccountLevelPermissions -> PermissionConfiguration)
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 -> PermissionConfiguration)
-> Parser (Maybe AccountLevelPermissions)
-> Parser PermissionConfiguration
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 PermissionConfiguration

instance Prelude.NFData PermissionConfiguration