{-# 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.ApiGatewayV2.Types.TlsConfig
-- 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.ApiGatewayV2.Types.TlsConfig where

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

-- | The TLS configuration for a private integration. If you specify a TLS
-- configuration, private integration traffic uses the HTTPS protocol.
-- Supported only for HTTP APIs.
--
-- /See:/ 'newTlsConfig' smart constructor.
data TlsConfig = TlsConfig'
  { -- | If you specify a server name, API Gateway uses it to verify the hostname
    -- on the integration\'s certificate. The server name is also included in
    -- the TLS handshake to support Server Name Indication (SNI) or virtual
    -- hosting.
    TlsConfig -> Maybe Text
serverNameToVerify :: Prelude.Maybe Prelude.Text
  }
  deriving (TlsConfig -> TlsConfig -> Bool
(TlsConfig -> TlsConfig -> Bool)
-> (TlsConfig -> TlsConfig -> Bool) -> Eq TlsConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TlsConfig -> TlsConfig -> Bool
$c/= :: TlsConfig -> TlsConfig -> Bool
== :: TlsConfig -> TlsConfig -> Bool
$c== :: TlsConfig -> TlsConfig -> Bool
Prelude.Eq, ReadPrec [TlsConfig]
ReadPrec TlsConfig
Int -> ReadS TlsConfig
ReadS [TlsConfig]
(Int -> ReadS TlsConfig)
-> ReadS [TlsConfig]
-> ReadPrec TlsConfig
-> ReadPrec [TlsConfig]
-> Read TlsConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TlsConfig]
$creadListPrec :: ReadPrec [TlsConfig]
readPrec :: ReadPrec TlsConfig
$creadPrec :: ReadPrec TlsConfig
readList :: ReadS [TlsConfig]
$creadList :: ReadS [TlsConfig]
readsPrec :: Int -> ReadS TlsConfig
$creadsPrec :: Int -> ReadS TlsConfig
Prelude.Read, Int -> TlsConfig -> ShowS
[TlsConfig] -> ShowS
TlsConfig -> String
(Int -> TlsConfig -> ShowS)
-> (TlsConfig -> String)
-> ([TlsConfig] -> ShowS)
-> Show TlsConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TlsConfig] -> ShowS
$cshowList :: [TlsConfig] -> ShowS
show :: TlsConfig -> String
$cshow :: TlsConfig -> String
showsPrec :: Int -> TlsConfig -> ShowS
$cshowsPrec :: Int -> TlsConfig -> ShowS
Prelude.Show, (forall x. TlsConfig -> Rep TlsConfig x)
-> (forall x. Rep TlsConfig x -> TlsConfig) -> Generic TlsConfig
forall x. Rep TlsConfig x -> TlsConfig
forall x. TlsConfig -> Rep TlsConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TlsConfig x -> TlsConfig
$cfrom :: forall x. TlsConfig -> Rep TlsConfig x
Prelude.Generic)

-- |
-- Create a value of 'TlsConfig' 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:
--
-- 'serverNameToVerify', 'tlsConfig_serverNameToVerify' - If you specify a server name, API Gateway uses it to verify the hostname
-- on the integration\'s certificate. The server name is also included in
-- the TLS handshake to support Server Name Indication (SNI) or virtual
-- hosting.
newTlsConfig ::
  TlsConfig
newTlsConfig :: TlsConfig
newTlsConfig =
  TlsConfig' :: Maybe Text -> TlsConfig
TlsConfig' {$sel:serverNameToVerify:TlsConfig' :: Maybe Text
serverNameToVerify = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | If you specify a server name, API Gateway uses it to verify the hostname
-- on the integration\'s certificate. The server name is also included in
-- the TLS handshake to support Server Name Indication (SNI) or virtual
-- hosting.
tlsConfig_serverNameToVerify :: Lens.Lens' TlsConfig (Prelude.Maybe Prelude.Text)
tlsConfig_serverNameToVerify :: (Maybe Text -> f (Maybe Text)) -> TlsConfig -> f TlsConfig
tlsConfig_serverNameToVerify = (TlsConfig -> Maybe Text)
-> (TlsConfig -> Maybe Text -> TlsConfig)
-> Lens TlsConfig TlsConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TlsConfig' {Maybe Text
serverNameToVerify :: Maybe Text
$sel:serverNameToVerify:TlsConfig' :: TlsConfig -> Maybe Text
serverNameToVerify} -> Maybe Text
serverNameToVerify) (\s :: TlsConfig
s@TlsConfig' {} Maybe Text
a -> TlsConfig
s {$sel:serverNameToVerify:TlsConfig' :: Maybe Text
serverNameToVerify = Maybe Text
a} :: TlsConfig)

instance Core.FromJSON TlsConfig where
  parseJSON :: Value -> Parser TlsConfig
parseJSON =
    String -> (Object -> Parser TlsConfig) -> Value -> Parser TlsConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TlsConfig"
      ( \Object
x ->
          Maybe Text -> TlsConfig
TlsConfig'
            (Maybe Text -> TlsConfig)
-> Parser (Maybe Text) -> Parser TlsConfig
forall (f :: * -> *) a b. Functor 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
"serverNameToVerify")
      )

instance Prelude.Hashable TlsConfig

instance Prelude.NFData TlsConfig