{-# 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.AccessAnalyzer.Types.S3AccessPointConfiguration
-- 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.AccessAnalyzer.Types.S3AccessPointConfiguration where

import Amazonka.AccessAnalyzer.Types.NetworkOriginConfiguration
import Amazonka.AccessAnalyzer.Types.S3PublicAccessBlockConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The configuration for an Amazon S3 access point or multi-region access
-- point for the bucket. You can propose up to 10 access points or
-- multi-region access points per bucket. If the proposed Amazon S3 access
-- point configuration is for an existing bucket, the access preview uses
-- the proposed access point configuration in place of the existing access
-- points. To propose an access point without a policy, you can provide an
-- empty string as the access point policy. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/creating-access-points.html Creating access points>.
-- For more information about access point policy limits, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/access-points-restrictions-limitations.html Access points restrictions and limitations>.
--
-- /See:/ 'newS3AccessPointConfiguration' smart constructor.
data S3AccessPointConfiguration = S3AccessPointConfiguration'
  { -- | The access point or multi-region access point policy.
    S3AccessPointConfiguration -> Maybe Text
accessPointPolicy :: Prelude.Maybe Prelude.Text,
    -- | The proposed @Internet@ and @VpcConfiguration@ to apply to this Amazon
    -- S3 access point. @VpcConfiguration@ does not apply to multi-region
    -- access points. If the access preview is for a new resource and neither
    -- is specified, the access preview uses @Internet@ for the network origin.
    -- If the access preview is for an existing resource and neither is
    -- specified, the access preview uses the exiting network origin.
    S3AccessPointConfiguration -> Maybe NetworkOriginConfiguration
networkOrigin :: Prelude.Maybe NetworkOriginConfiguration,
    -- | The proposed @S3PublicAccessBlock@ configuration to apply to this Amazon
    -- S3 access point or multi-region access point.
    S3AccessPointConfiguration
-> Maybe S3PublicAccessBlockConfiguration
publicAccessBlock :: Prelude.Maybe S3PublicAccessBlockConfiguration
  }
  deriving (S3AccessPointConfiguration -> S3AccessPointConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3AccessPointConfiguration -> S3AccessPointConfiguration -> Bool
$c/= :: S3AccessPointConfiguration -> S3AccessPointConfiguration -> Bool
== :: S3AccessPointConfiguration -> S3AccessPointConfiguration -> Bool
$c== :: S3AccessPointConfiguration -> S3AccessPointConfiguration -> Bool
Prelude.Eq, ReadPrec [S3AccessPointConfiguration]
ReadPrec S3AccessPointConfiguration
Int -> ReadS S3AccessPointConfiguration
ReadS [S3AccessPointConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3AccessPointConfiguration]
$creadListPrec :: ReadPrec [S3AccessPointConfiguration]
readPrec :: ReadPrec S3AccessPointConfiguration
$creadPrec :: ReadPrec S3AccessPointConfiguration
readList :: ReadS [S3AccessPointConfiguration]
$creadList :: ReadS [S3AccessPointConfiguration]
readsPrec :: Int -> ReadS S3AccessPointConfiguration
$creadsPrec :: Int -> ReadS S3AccessPointConfiguration
Prelude.Read, Int -> S3AccessPointConfiguration -> ShowS
[S3AccessPointConfiguration] -> ShowS
S3AccessPointConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3AccessPointConfiguration] -> ShowS
$cshowList :: [S3AccessPointConfiguration] -> ShowS
show :: S3AccessPointConfiguration -> String
$cshow :: S3AccessPointConfiguration -> String
showsPrec :: Int -> S3AccessPointConfiguration -> ShowS
$cshowsPrec :: Int -> S3AccessPointConfiguration -> ShowS
Prelude.Show, forall x.
Rep S3AccessPointConfiguration x -> S3AccessPointConfiguration
forall x.
S3AccessPointConfiguration -> Rep S3AccessPointConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep S3AccessPointConfiguration x -> S3AccessPointConfiguration
$cfrom :: forall x.
S3AccessPointConfiguration -> Rep S3AccessPointConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'S3AccessPointConfiguration' 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:
--
-- 'accessPointPolicy', 's3AccessPointConfiguration_accessPointPolicy' - The access point or multi-region access point policy.
--
-- 'networkOrigin', 's3AccessPointConfiguration_networkOrigin' - The proposed @Internet@ and @VpcConfiguration@ to apply to this Amazon
-- S3 access point. @VpcConfiguration@ does not apply to multi-region
-- access points. If the access preview is for a new resource and neither
-- is specified, the access preview uses @Internet@ for the network origin.
-- If the access preview is for an existing resource and neither is
-- specified, the access preview uses the exiting network origin.
--
-- 'publicAccessBlock', 's3AccessPointConfiguration_publicAccessBlock' - The proposed @S3PublicAccessBlock@ configuration to apply to this Amazon
-- S3 access point or multi-region access point.
newS3AccessPointConfiguration ::
  S3AccessPointConfiguration
newS3AccessPointConfiguration :: S3AccessPointConfiguration
newS3AccessPointConfiguration =
  S3AccessPointConfiguration'
    { $sel:accessPointPolicy:S3AccessPointConfiguration' :: Maybe Text
accessPointPolicy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:networkOrigin:S3AccessPointConfiguration' :: Maybe NetworkOriginConfiguration
networkOrigin = forall a. Maybe a
Prelude.Nothing,
      $sel:publicAccessBlock:S3AccessPointConfiguration' :: Maybe S3PublicAccessBlockConfiguration
publicAccessBlock = forall a. Maybe a
Prelude.Nothing
    }

-- | The access point or multi-region access point policy.
s3AccessPointConfiguration_accessPointPolicy :: Lens.Lens' S3AccessPointConfiguration (Prelude.Maybe Prelude.Text)
s3AccessPointConfiguration_accessPointPolicy :: Lens' S3AccessPointConfiguration (Maybe Text)
s3AccessPointConfiguration_accessPointPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3AccessPointConfiguration' {Maybe Text
accessPointPolicy :: Maybe Text
$sel:accessPointPolicy:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe Text
accessPointPolicy} -> Maybe Text
accessPointPolicy) (\s :: S3AccessPointConfiguration
s@S3AccessPointConfiguration' {} Maybe Text
a -> S3AccessPointConfiguration
s {$sel:accessPointPolicy:S3AccessPointConfiguration' :: Maybe Text
accessPointPolicy = Maybe Text
a} :: S3AccessPointConfiguration)

-- | The proposed @Internet@ and @VpcConfiguration@ to apply to this Amazon
-- S3 access point. @VpcConfiguration@ does not apply to multi-region
-- access points. If the access preview is for a new resource and neither
-- is specified, the access preview uses @Internet@ for the network origin.
-- If the access preview is for an existing resource and neither is
-- specified, the access preview uses the exiting network origin.
s3AccessPointConfiguration_networkOrigin :: Lens.Lens' S3AccessPointConfiguration (Prelude.Maybe NetworkOriginConfiguration)
s3AccessPointConfiguration_networkOrigin :: Lens' S3AccessPointConfiguration (Maybe NetworkOriginConfiguration)
s3AccessPointConfiguration_networkOrigin = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3AccessPointConfiguration' {Maybe NetworkOriginConfiguration
networkOrigin :: Maybe NetworkOriginConfiguration
$sel:networkOrigin:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe NetworkOriginConfiguration
networkOrigin} -> Maybe NetworkOriginConfiguration
networkOrigin) (\s :: S3AccessPointConfiguration
s@S3AccessPointConfiguration' {} Maybe NetworkOriginConfiguration
a -> S3AccessPointConfiguration
s {$sel:networkOrigin:S3AccessPointConfiguration' :: Maybe NetworkOriginConfiguration
networkOrigin = Maybe NetworkOriginConfiguration
a} :: S3AccessPointConfiguration)

-- | The proposed @S3PublicAccessBlock@ configuration to apply to this Amazon
-- S3 access point or multi-region access point.
s3AccessPointConfiguration_publicAccessBlock :: Lens.Lens' S3AccessPointConfiguration (Prelude.Maybe S3PublicAccessBlockConfiguration)
s3AccessPointConfiguration_publicAccessBlock :: Lens'
  S3AccessPointConfiguration (Maybe S3PublicAccessBlockConfiguration)
s3AccessPointConfiguration_publicAccessBlock = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3AccessPointConfiguration' {Maybe S3PublicAccessBlockConfiguration
publicAccessBlock :: Maybe S3PublicAccessBlockConfiguration
$sel:publicAccessBlock:S3AccessPointConfiguration' :: S3AccessPointConfiguration
-> Maybe S3PublicAccessBlockConfiguration
publicAccessBlock} -> Maybe S3PublicAccessBlockConfiguration
publicAccessBlock) (\s :: S3AccessPointConfiguration
s@S3AccessPointConfiguration' {} Maybe S3PublicAccessBlockConfiguration
a -> S3AccessPointConfiguration
s {$sel:publicAccessBlock:S3AccessPointConfiguration' :: Maybe S3PublicAccessBlockConfiguration
publicAccessBlock = Maybe S3PublicAccessBlockConfiguration
a} :: S3AccessPointConfiguration)

instance Data.FromJSON S3AccessPointConfiguration where
  parseJSON :: Value -> Parser S3AccessPointConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3AccessPointConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe NetworkOriginConfiguration
-> Maybe S3PublicAccessBlockConfiguration
-> S3AccessPointConfiguration
S3AccessPointConfiguration'
            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
"accessPointPolicy")
            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
"networkOrigin")
            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
"publicAccessBlock")
      )

instance Prelude.Hashable S3AccessPointConfiguration where
  hashWithSalt :: Int -> S3AccessPointConfiguration -> Int
hashWithSalt Int
_salt S3AccessPointConfiguration' {Maybe Text
Maybe S3PublicAccessBlockConfiguration
Maybe NetworkOriginConfiguration
publicAccessBlock :: Maybe S3PublicAccessBlockConfiguration
networkOrigin :: Maybe NetworkOriginConfiguration
accessPointPolicy :: Maybe Text
$sel:publicAccessBlock:S3AccessPointConfiguration' :: S3AccessPointConfiguration
-> Maybe S3PublicAccessBlockConfiguration
$sel:networkOrigin:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe NetworkOriginConfiguration
$sel:accessPointPolicy:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accessPointPolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NetworkOriginConfiguration
networkOrigin
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3PublicAccessBlockConfiguration
publicAccessBlock

instance Prelude.NFData S3AccessPointConfiguration where
  rnf :: S3AccessPointConfiguration -> ()
rnf S3AccessPointConfiguration' {Maybe Text
Maybe S3PublicAccessBlockConfiguration
Maybe NetworkOriginConfiguration
publicAccessBlock :: Maybe S3PublicAccessBlockConfiguration
networkOrigin :: Maybe NetworkOriginConfiguration
accessPointPolicy :: Maybe Text
$sel:publicAccessBlock:S3AccessPointConfiguration' :: S3AccessPointConfiguration
-> Maybe S3PublicAccessBlockConfiguration
$sel:networkOrigin:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe NetworkOriginConfiguration
$sel:accessPointPolicy:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accessPointPolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NetworkOriginConfiguration
networkOrigin
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3PublicAccessBlockConfiguration
publicAccessBlock

instance Data.ToJSON S3AccessPointConfiguration where
  toJSON :: S3AccessPointConfiguration -> Value
toJSON S3AccessPointConfiguration' {Maybe Text
Maybe S3PublicAccessBlockConfiguration
Maybe NetworkOriginConfiguration
publicAccessBlock :: Maybe S3PublicAccessBlockConfiguration
networkOrigin :: Maybe NetworkOriginConfiguration
accessPointPolicy :: Maybe Text
$sel:publicAccessBlock:S3AccessPointConfiguration' :: S3AccessPointConfiguration
-> Maybe S3PublicAccessBlockConfiguration
$sel:networkOrigin:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe NetworkOriginConfiguration
$sel:accessPointPolicy:S3AccessPointConfiguration' :: S3AccessPointConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"accessPointPolicy" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
accessPointPolicy,
            (Key
"networkOrigin" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NetworkOriginConfiguration
networkOrigin,
            (Key
"publicAccessBlock" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3PublicAccessBlockConfiguration
publicAccessBlock
          ]
      )