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

import Amazonka.AccessAnalyzer.Types.NetworkOriginConfiguration
import Amazonka.AccessAnalyzer.Types.S3PublicAccessBlockConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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/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 proposed @S3PublicAccessBlock@ configuration to apply to this Amazon
    -- S3 access point or multi-region access point.
    S3AccessPointConfiguration
-> Maybe S3PublicAccessBlockConfiguration
publicAccessBlock :: Prelude.Maybe S3PublicAccessBlockConfiguration,
    -- | 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
  }
  deriving (S3AccessPointConfiguration -> S3AccessPointConfiguration -> Bool
(S3AccessPointConfiguration -> S3AccessPointConfiguration -> Bool)
-> (S3AccessPointConfiguration
    -> S3AccessPointConfiguration -> Bool)
-> Eq S3AccessPointConfiguration
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]
(Int -> ReadS S3AccessPointConfiguration)
-> ReadS [S3AccessPointConfiguration]
-> ReadPrec S3AccessPointConfiguration
-> ReadPrec [S3AccessPointConfiguration]
-> Read 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
(Int -> S3AccessPointConfiguration -> ShowS)
-> (S3AccessPointConfiguration -> String)
-> ([S3AccessPointConfiguration] -> ShowS)
-> Show S3AccessPointConfiguration
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.
 S3AccessPointConfiguration -> Rep S3AccessPointConfiguration x)
-> (forall x.
    Rep S3AccessPointConfiguration x -> S3AccessPointConfiguration)
-> Generic S3AccessPointConfiguration
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:
--
-- 'publicAccessBlock', 's3AccessPointConfiguration_publicAccessBlock' - The proposed @S3PublicAccessBlock@ configuration to apply to this Amazon
-- S3 access point or multi-region access point.
--
-- '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.
newS3AccessPointConfiguration ::
  S3AccessPointConfiguration
newS3AccessPointConfiguration :: S3AccessPointConfiguration
newS3AccessPointConfiguration =
  S3AccessPointConfiguration' :: Maybe S3PublicAccessBlockConfiguration
-> Maybe Text
-> Maybe NetworkOriginConfiguration
-> S3AccessPointConfiguration
S3AccessPointConfiguration'
    { $sel:publicAccessBlock:S3AccessPointConfiguration' :: Maybe S3PublicAccessBlockConfiguration
publicAccessBlock =
        Maybe S3PublicAccessBlockConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:accessPointPolicy:S3AccessPointConfiguration' :: Maybe Text
accessPointPolicy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:networkOrigin:S3AccessPointConfiguration' :: Maybe NetworkOriginConfiguration
networkOrigin = Maybe NetworkOriginConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe S3PublicAccessBlockConfiguration
 -> f (Maybe S3PublicAccessBlockConfiguration))
-> S3AccessPointConfiguration -> f S3AccessPointConfiguration
s3AccessPointConfiguration_publicAccessBlock = (S3AccessPointConfiguration
 -> Maybe S3PublicAccessBlockConfiguration)
-> (S3AccessPointConfiguration
    -> Maybe S3PublicAccessBlockConfiguration
    -> S3AccessPointConfiguration)
-> Lens
     S3AccessPointConfiguration
     S3AccessPointConfiguration
     (Maybe S3PublicAccessBlockConfiguration)
     (Maybe S3PublicAccessBlockConfiguration)
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)

-- | The access point or multi-region access point policy.
s3AccessPointConfiguration_accessPointPolicy :: Lens.Lens' S3AccessPointConfiguration (Prelude.Maybe Prelude.Text)
s3AccessPointConfiguration_accessPointPolicy :: (Maybe Text -> f (Maybe Text))
-> S3AccessPointConfiguration -> f S3AccessPointConfiguration
s3AccessPointConfiguration_accessPointPolicy = (S3AccessPointConfiguration -> Maybe Text)
-> (S3AccessPointConfiguration
    -> Maybe Text -> S3AccessPointConfiguration)
-> Lens
     S3AccessPointConfiguration
     S3AccessPointConfiguration
     (Maybe Text)
     (Maybe Text)
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 :: (Maybe NetworkOriginConfiguration
 -> f (Maybe NetworkOriginConfiguration))
-> S3AccessPointConfiguration -> f S3AccessPointConfiguration
s3AccessPointConfiguration_networkOrigin = (S3AccessPointConfiguration -> Maybe NetworkOriginConfiguration)
-> (S3AccessPointConfiguration
    -> Maybe NetworkOriginConfiguration -> S3AccessPointConfiguration)
-> Lens
     S3AccessPointConfiguration
     S3AccessPointConfiguration
     (Maybe NetworkOriginConfiguration)
     (Maybe NetworkOriginConfiguration)
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)

instance Core.FromJSON S3AccessPointConfiguration where
  parseJSON :: Value -> Parser S3AccessPointConfiguration
parseJSON =
    String
-> (Object -> Parser S3AccessPointConfiguration)
-> Value
-> Parser S3AccessPointConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"S3AccessPointConfiguration"
      ( \Object
x ->
          Maybe S3PublicAccessBlockConfiguration
-> Maybe Text
-> Maybe NetworkOriginConfiguration
-> S3AccessPointConfiguration
S3AccessPointConfiguration'
            (Maybe S3PublicAccessBlockConfiguration
 -> Maybe Text
 -> Maybe NetworkOriginConfiguration
 -> S3AccessPointConfiguration)
-> Parser (Maybe S3PublicAccessBlockConfiguration)
-> Parser
     (Maybe Text
      -> Maybe NetworkOriginConfiguration -> S3AccessPointConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe S3PublicAccessBlockConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"publicAccessBlock")
            Parser
  (Maybe Text
   -> Maybe NetworkOriginConfiguration -> S3AccessPointConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe NetworkOriginConfiguration -> S3AccessPointConfiguration)
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
"accessPointPolicy")
            Parser
  (Maybe NetworkOriginConfiguration -> S3AccessPointConfiguration)
-> Parser (Maybe NetworkOriginConfiguration)
-> Parser S3AccessPointConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NetworkOriginConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"networkOrigin")
      )

instance Prelude.Hashable S3AccessPointConfiguration

instance Prelude.NFData S3AccessPointConfiguration

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