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

import Amazonka.AccessAnalyzer.Types.InternetConfiguration
import Amazonka.AccessAnalyzer.Types.VpcConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The proposed @InternetConfiguration@ or @VpcConfiguration@ to apply to
-- the Amazon S3 access point. @VpcConfiguration@ does not apply to
-- multi-region access points. You can make the access point accessible
-- from the internet, or you can specify that all requests made through
-- that access point must originate from a specific virtual private cloud
-- (VPC). You can specify only one type of network configuration. For more
-- information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/creating-access-points.html Creating access points>.
--
-- /See:/ 'newNetworkOriginConfiguration' smart constructor.
data NetworkOriginConfiguration = NetworkOriginConfiguration'
  { -- | The configuration for the Amazon S3 access point or multi-region access
    -- point with an @Internet@ origin.
    NetworkOriginConfiguration -> Maybe InternetConfiguration
internetConfiguration :: Prelude.Maybe InternetConfiguration,
    NetworkOriginConfiguration -> Maybe VpcConfiguration
vpcConfiguration :: Prelude.Maybe VpcConfiguration
  }
  deriving (NetworkOriginConfiguration -> NetworkOriginConfiguration -> Bool
(NetworkOriginConfiguration -> NetworkOriginConfiguration -> Bool)
-> (NetworkOriginConfiguration
    -> NetworkOriginConfiguration -> Bool)
-> Eq NetworkOriginConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkOriginConfiguration -> NetworkOriginConfiguration -> Bool
$c/= :: NetworkOriginConfiguration -> NetworkOriginConfiguration -> Bool
== :: NetworkOriginConfiguration -> NetworkOriginConfiguration -> Bool
$c== :: NetworkOriginConfiguration -> NetworkOriginConfiguration -> Bool
Prelude.Eq, ReadPrec [NetworkOriginConfiguration]
ReadPrec NetworkOriginConfiguration
Int -> ReadS NetworkOriginConfiguration
ReadS [NetworkOriginConfiguration]
(Int -> ReadS NetworkOriginConfiguration)
-> ReadS [NetworkOriginConfiguration]
-> ReadPrec NetworkOriginConfiguration
-> ReadPrec [NetworkOriginConfiguration]
-> Read NetworkOriginConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkOriginConfiguration]
$creadListPrec :: ReadPrec [NetworkOriginConfiguration]
readPrec :: ReadPrec NetworkOriginConfiguration
$creadPrec :: ReadPrec NetworkOriginConfiguration
readList :: ReadS [NetworkOriginConfiguration]
$creadList :: ReadS [NetworkOriginConfiguration]
readsPrec :: Int -> ReadS NetworkOriginConfiguration
$creadsPrec :: Int -> ReadS NetworkOriginConfiguration
Prelude.Read, Int -> NetworkOriginConfiguration -> ShowS
[NetworkOriginConfiguration] -> ShowS
NetworkOriginConfiguration -> String
(Int -> NetworkOriginConfiguration -> ShowS)
-> (NetworkOriginConfiguration -> String)
-> ([NetworkOriginConfiguration] -> ShowS)
-> Show NetworkOriginConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkOriginConfiguration] -> ShowS
$cshowList :: [NetworkOriginConfiguration] -> ShowS
show :: NetworkOriginConfiguration -> String
$cshow :: NetworkOriginConfiguration -> String
showsPrec :: Int -> NetworkOriginConfiguration -> ShowS
$cshowsPrec :: Int -> NetworkOriginConfiguration -> ShowS
Prelude.Show, (forall x.
 NetworkOriginConfiguration -> Rep NetworkOriginConfiguration x)
-> (forall x.
    Rep NetworkOriginConfiguration x -> NetworkOriginConfiguration)
-> Generic NetworkOriginConfiguration
forall x.
Rep NetworkOriginConfiguration x -> NetworkOriginConfiguration
forall x.
NetworkOriginConfiguration -> Rep NetworkOriginConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep NetworkOriginConfiguration x -> NetworkOriginConfiguration
$cfrom :: forall x.
NetworkOriginConfiguration -> Rep NetworkOriginConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'NetworkOriginConfiguration' 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:
--
-- 'internetConfiguration', 'networkOriginConfiguration_internetConfiguration' - The configuration for the Amazon S3 access point or multi-region access
-- point with an @Internet@ origin.
--
-- 'vpcConfiguration', 'networkOriginConfiguration_vpcConfiguration' - Undocumented member.
newNetworkOriginConfiguration ::
  NetworkOriginConfiguration
newNetworkOriginConfiguration :: NetworkOriginConfiguration
newNetworkOriginConfiguration =
  NetworkOriginConfiguration' :: Maybe InternetConfiguration
-> Maybe VpcConfiguration -> NetworkOriginConfiguration
NetworkOriginConfiguration'
    { $sel:internetConfiguration:NetworkOriginConfiguration' :: Maybe InternetConfiguration
internetConfiguration =
        Maybe InternetConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:vpcConfiguration:NetworkOriginConfiguration' :: Maybe VpcConfiguration
vpcConfiguration = Maybe VpcConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | The configuration for the Amazon S3 access point or multi-region access
-- point with an @Internet@ origin.
networkOriginConfiguration_internetConfiguration :: Lens.Lens' NetworkOriginConfiguration (Prelude.Maybe InternetConfiguration)
networkOriginConfiguration_internetConfiguration :: (Maybe InternetConfiguration -> f (Maybe InternetConfiguration))
-> NetworkOriginConfiguration -> f NetworkOriginConfiguration
networkOriginConfiguration_internetConfiguration = (NetworkOriginConfiguration -> Maybe InternetConfiguration)
-> (NetworkOriginConfiguration
    -> Maybe InternetConfiguration -> NetworkOriginConfiguration)
-> Lens
     NetworkOriginConfiguration
     NetworkOriginConfiguration
     (Maybe InternetConfiguration)
     (Maybe InternetConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkOriginConfiguration' {Maybe InternetConfiguration
internetConfiguration :: Maybe InternetConfiguration
$sel:internetConfiguration:NetworkOriginConfiguration' :: NetworkOriginConfiguration -> Maybe InternetConfiguration
internetConfiguration} -> Maybe InternetConfiguration
internetConfiguration) (\s :: NetworkOriginConfiguration
s@NetworkOriginConfiguration' {} Maybe InternetConfiguration
a -> NetworkOriginConfiguration
s {$sel:internetConfiguration:NetworkOriginConfiguration' :: Maybe InternetConfiguration
internetConfiguration = Maybe InternetConfiguration
a} :: NetworkOriginConfiguration)

-- | Undocumented member.
networkOriginConfiguration_vpcConfiguration :: Lens.Lens' NetworkOriginConfiguration (Prelude.Maybe VpcConfiguration)
networkOriginConfiguration_vpcConfiguration :: (Maybe VpcConfiguration -> f (Maybe VpcConfiguration))
-> NetworkOriginConfiguration -> f NetworkOriginConfiguration
networkOriginConfiguration_vpcConfiguration = (NetworkOriginConfiguration -> Maybe VpcConfiguration)
-> (NetworkOriginConfiguration
    -> Maybe VpcConfiguration -> NetworkOriginConfiguration)
-> Lens
     NetworkOriginConfiguration
     NetworkOriginConfiguration
     (Maybe VpcConfiguration)
     (Maybe VpcConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkOriginConfiguration' {Maybe VpcConfiguration
vpcConfiguration :: Maybe VpcConfiguration
$sel:vpcConfiguration:NetworkOriginConfiguration' :: NetworkOriginConfiguration -> Maybe VpcConfiguration
vpcConfiguration} -> Maybe VpcConfiguration
vpcConfiguration) (\s :: NetworkOriginConfiguration
s@NetworkOriginConfiguration' {} Maybe VpcConfiguration
a -> NetworkOriginConfiguration
s {$sel:vpcConfiguration:NetworkOriginConfiguration' :: Maybe VpcConfiguration
vpcConfiguration = Maybe VpcConfiguration
a} :: NetworkOriginConfiguration)

instance Core.FromJSON NetworkOriginConfiguration where
  parseJSON :: Value -> Parser NetworkOriginConfiguration
parseJSON =
    String
-> (Object -> Parser NetworkOriginConfiguration)
-> Value
-> Parser NetworkOriginConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NetworkOriginConfiguration"
      ( \Object
x ->
          Maybe InternetConfiguration
-> Maybe VpcConfiguration -> NetworkOriginConfiguration
NetworkOriginConfiguration'
            (Maybe InternetConfiguration
 -> Maybe VpcConfiguration -> NetworkOriginConfiguration)
-> Parser (Maybe InternetConfiguration)
-> Parser (Maybe VpcConfiguration -> NetworkOriginConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InternetConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"internetConfiguration")
            Parser (Maybe VpcConfiguration -> NetworkOriginConfiguration)
-> Parser (Maybe VpcConfiguration)
-> Parser NetworkOriginConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VpcConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vpcConfiguration")
      )

instance Prelude.Hashable NetworkOriginConfiguration

instance Prelude.NFData NetworkOriginConfiguration

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