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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information on the current access control policies for the
-- bucket.
--
-- /See:/ 'newAccessControlList' smart constructor.
data AccessControlList = AccessControlList'
  { -- | A value that indicates whether public write access for the bucket is
    -- enabled through an Access Control List (ACL).
    AccessControlList -> Maybe Bool
allowsPublicWriteAccess :: Prelude.Maybe Prelude.Bool,
    -- | A value that indicates whether public read access for the bucket is
    -- enabled through an Access Control List (ACL).
    AccessControlList -> Maybe Bool
allowsPublicReadAccess :: Prelude.Maybe Prelude.Bool
  }
  deriving (AccessControlList -> AccessControlList -> Bool
(AccessControlList -> AccessControlList -> Bool)
-> (AccessControlList -> AccessControlList -> Bool)
-> Eq AccessControlList
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessControlList -> AccessControlList -> Bool
$c/= :: AccessControlList -> AccessControlList -> Bool
== :: AccessControlList -> AccessControlList -> Bool
$c== :: AccessControlList -> AccessControlList -> Bool
Prelude.Eq, ReadPrec [AccessControlList]
ReadPrec AccessControlList
Int -> ReadS AccessControlList
ReadS [AccessControlList]
(Int -> ReadS AccessControlList)
-> ReadS [AccessControlList]
-> ReadPrec AccessControlList
-> ReadPrec [AccessControlList]
-> Read AccessControlList
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccessControlList]
$creadListPrec :: ReadPrec [AccessControlList]
readPrec :: ReadPrec AccessControlList
$creadPrec :: ReadPrec AccessControlList
readList :: ReadS [AccessControlList]
$creadList :: ReadS [AccessControlList]
readsPrec :: Int -> ReadS AccessControlList
$creadsPrec :: Int -> ReadS AccessControlList
Prelude.Read, Int -> AccessControlList -> ShowS
[AccessControlList] -> ShowS
AccessControlList -> String
(Int -> AccessControlList -> ShowS)
-> (AccessControlList -> String)
-> ([AccessControlList] -> ShowS)
-> Show AccessControlList
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessControlList] -> ShowS
$cshowList :: [AccessControlList] -> ShowS
show :: AccessControlList -> String
$cshow :: AccessControlList -> String
showsPrec :: Int -> AccessControlList -> ShowS
$cshowsPrec :: Int -> AccessControlList -> ShowS
Prelude.Show, (forall x. AccessControlList -> Rep AccessControlList x)
-> (forall x. Rep AccessControlList x -> AccessControlList)
-> Generic AccessControlList
forall x. Rep AccessControlList x -> AccessControlList
forall x. AccessControlList -> Rep AccessControlList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccessControlList x -> AccessControlList
$cfrom :: forall x. AccessControlList -> Rep AccessControlList x
Prelude.Generic)

-- |
-- Create a value of 'AccessControlList' 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:
--
-- 'allowsPublicWriteAccess', 'accessControlList_allowsPublicWriteAccess' - A value that indicates whether public write access for the bucket is
-- enabled through an Access Control List (ACL).
--
-- 'allowsPublicReadAccess', 'accessControlList_allowsPublicReadAccess' - A value that indicates whether public read access for the bucket is
-- enabled through an Access Control List (ACL).
newAccessControlList ::
  AccessControlList
newAccessControlList :: AccessControlList
newAccessControlList =
  AccessControlList' :: Maybe Bool -> Maybe Bool -> AccessControlList
AccessControlList'
    { $sel:allowsPublicWriteAccess:AccessControlList' :: Maybe Bool
allowsPublicWriteAccess =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:allowsPublicReadAccess:AccessControlList' :: Maybe Bool
allowsPublicReadAccess = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | A value that indicates whether public write access for the bucket is
-- enabled through an Access Control List (ACL).
accessControlList_allowsPublicWriteAccess :: Lens.Lens' AccessControlList (Prelude.Maybe Prelude.Bool)
accessControlList_allowsPublicWriteAccess :: (Maybe Bool -> f (Maybe Bool))
-> AccessControlList -> f AccessControlList
accessControlList_allowsPublicWriteAccess = (AccessControlList -> Maybe Bool)
-> (AccessControlList -> Maybe Bool -> AccessControlList)
-> Lens
     AccessControlList AccessControlList (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessControlList' {Maybe Bool
allowsPublicWriteAccess :: Maybe Bool
$sel:allowsPublicWriteAccess:AccessControlList' :: AccessControlList -> Maybe Bool
allowsPublicWriteAccess} -> Maybe Bool
allowsPublicWriteAccess) (\s :: AccessControlList
s@AccessControlList' {} Maybe Bool
a -> AccessControlList
s {$sel:allowsPublicWriteAccess:AccessControlList' :: Maybe Bool
allowsPublicWriteAccess = Maybe Bool
a} :: AccessControlList)

-- | A value that indicates whether public read access for the bucket is
-- enabled through an Access Control List (ACL).
accessControlList_allowsPublicReadAccess :: Lens.Lens' AccessControlList (Prelude.Maybe Prelude.Bool)
accessControlList_allowsPublicReadAccess :: (Maybe Bool -> f (Maybe Bool))
-> AccessControlList -> f AccessControlList
accessControlList_allowsPublicReadAccess = (AccessControlList -> Maybe Bool)
-> (AccessControlList -> Maybe Bool -> AccessControlList)
-> Lens
     AccessControlList AccessControlList (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccessControlList' {Maybe Bool
allowsPublicReadAccess :: Maybe Bool
$sel:allowsPublicReadAccess:AccessControlList' :: AccessControlList -> Maybe Bool
allowsPublicReadAccess} -> Maybe Bool
allowsPublicReadAccess) (\s :: AccessControlList
s@AccessControlList' {} Maybe Bool
a -> AccessControlList
s {$sel:allowsPublicReadAccess:AccessControlList' :: Maybe Bool
allowsPublicReadAccess = Maybe Bool
a} :: AccessControlList)

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

instance Prelude.Hashable AccessControlList

instance Prelude.NFData AccessControlList