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

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

-- | /See:/ 'newTlsConfig' smart constructor.
data TlsConfig = TlsConfig'
  { -- | Specifies whether or not API Gateway skips verification that the
    -- certificate for an integration endpoint is issued by a
    -- <https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-supported-certificate-authorities-for-http-endpoints.html supported certificate authority>.
    -- This isn’t recommended, but it enables you to use certificates that are
    -- signed by private certificate authorities, or certificates that are
    -- self-signed. If enabled, API Gateway still performs basic certificate
    -- validation, which includes checking the certificate\'s expiration date,
    -- hostname, and presence of a root certificate authority. Supported only
    -- for @HTTP@ and @HTTP_PROXY@ integrations.
    TlsConfig -> Maybe Bool
insecureSkipVerification :: Prelude.Maybe Prelude.Bool
  }
  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:
--
-- 'insecureSkipVerification', 'tlsConfig_insecureSkipVerification' - Specifies whether or not API Gateway skips verification that the
-- certificate for an integration endpoint is issued by a
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-supported-certificate-authorities-for-http-endpoints.html supported certificate authority>.
-- This isn’t recommended, but it enables you to use certificates that are
-- signed by private certificate authorities, or certificates that are
-- self-signed. If enabled, API Gateway still performs basic certificate
-- validation, which includes checking the certificate\'s expiration date,
-- hostname, and presence of a root certificate authority. Supported only
-- for @HTTP@ and @HTTP_PROXY@ integrations.
newTlsConfig ::
  TlsConfig
newTlsConfig :: TlsConfig
newTlsConfig =
  TlsConfig' :: Maybe Bool -> TlsConfig
TlsConfig'
    { $sel:insecureSkipVerification:TlsConfig' :: Maybe Bool
insecureSkipVerification =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether or not API Gateway skips verification that the
-- certificate for an integration endpoint is issued by a
-- <https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-supported-certificate-authorities-for-http-endpoints.html supported certificate authority>.
-- This isn’t recommended, but it enables you to use certificates that are
-- signed by private certificate authorities, or certificates that are
-- self-signed. If enabled, API Gateway still performs basic certificate
-- validation, which includes checking the certificate\'s expiration date,
-- hostname, and presence of a root certificate authority. Supported only
-- for @HTTP@ and @HTTP_PROXY@ integrations.
tlsConfig_insecureSkipVerification :: Lens.Lens' TlsConfig (Prelude.Maybe Prelude.Bool)
tlsConfig_insecureSkipVerification :: (Maybe Bool -> f (Maybe Bool)) -> TlsConfig -> f TlsConfig
tlsConfig_insecureSkipVerification = (TlsConfig -> Maybe Bool)
-> (TlsConfig -> Maybe Bool -> TlsConfig)
-> Lens TlsConfig TlsConfig (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TlsConfig' {Maybe Bool
insecureSkipVerification :: Maybe Bool
$sel:insecureSkipVerification:TlsConfig' :: TlsConfig -> Maybe Bool
insecureSkipVerification} -> Maybe Bool
insecureSkipVerification) (\s :: TlsConfig
s@TlsConfig' {} Maybe Bool
a -> TlsConfig
s {$sel:insecureSkipVerification:TlsConfig' :: Maybe Bool
insecureSkipVerification = Maybe Bool
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 Bool -> TlsConfig
TlsConfig'
            (Maybe Bool -> TlsConfig)
-> Parser (Maybe Bool) -> Parser TlsConfig
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
"insecureSkipVerification")
      )

instance Prelude.Hashable TlsConfig

instance Prelude.NFData TlsConfig

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