{-# 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.AppMesh.Types.VirtualGatewayTlsValidationContext
-- 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.AppMesh.Types.VirtualGatewayTlsValidationContext where

import Amazonka.AppMesh.Types.SubjectAlternativeNames
import Amazonka.AppMesh.Types.VirtualGatewayTlsValidationContextTrust
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object that represents a Transport Layer Security (TLS) validation
-- context.
--
-- /See:/ 'newVirtualGatewayTlsValidationContext' smart constructor.
data VirtualGatewayTlsValidationContext = VirtualGatewayTlsValidationContext'
  { -- | A reference to an object that represents the SANs for a virtual
    -- gateway\'s listener\'s Transport Layer Security (TLS) validation
    -- context.
    VirtualGatewayTlsValidationContext -> Maybe SubjectAlternativeNames
subjectAlternativeNames :: Prelude.Maybe SubjectAlternativeNames,
    -- | A reference to where to retrieve the trust chain when validating a
    -- peer’s Transport Layer Security (TLS) certificate.
    VirtualGatewayTlsValidationContext
-> VirtualGatewayTlsValidationContextTrust
trust :: VirtualGatewayTlsValidationContextTrust
  }
  deriving (VirtualGatewayTlsValidationContext
-> VirtualGatewayTlsValidationContext -> Bool
(VirtualGatewayTlsValidationContext
 -> VirtualGatewayTlsValidationContext -> Bool)
-> (VirtualGatewayTlsValidationContext
    -> VirtualGatewayTlsValidationContext -> Bool)
-> Eq VirtualGatewayTlsValidationContext
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayTlsValidationContext
-> VirtualGatewayTlsValidationContext -> Bool
$c/= :: VirtualGatewayTlsValidationContext
-> VirtualGatewayTlsValidationContext -> Bool
== :: VirtualGatewayTlsValidationContext
-> VirtualGatewayTlsValidationContext -> Bool
$c== :: VirtualGatewayTlsValidationContext
-> VirtualGatewayTlsValidationContext -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayTlsValidationContext]
ReadPrec VirtualGatewayTlsValidationContext
Int -> ReadS VirtualGatewayTlsValidationContext
ReadS [VirtualGatewayTlsValidationContext]
(Int -> ReadS VirtualGatewayTlsValidationContext)
-> ReadS [VirtualGatewayTlsValidationContext]
-> ReadPrec VirtualGatewayTlsValidationContext
-> ReadPrec [VirtualGatewayTlsValidationContext]
-> Read VirtualGatewayTlsValidationContext
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayTlsValidationContext]
$creadListPrec :: ReadPrec [VirtualGatewayTlsValidationContext]
readPrec :: ReadPrec VirtualGatewayTlsValidationContext
$creadPrec :: ReadPrec VirtualGatewayTlsValidationContext
readList :: ReadS [VirtualGatewayTlsValidationContext]
$creadList :: ReadS [VirtualGatewayTlsValidationContext]
readsPrec :: Int -> ReadS VirtualGatewayTlsValidationContext
$creadsPrec :: Int -> ReadS VirtualGatewayTlsValidationContext
Prelude.Read, Int -> VirtualGatewayTlsValidationContext -> ShowS
[VirtualGatewayTlsValidationContext] -> ShowS
VirtualGatewayTlsValidationContext -> String
(Int -> VirtualGatewayTlsValidationContext -> ShowS)
-> (VirtualGatewayTlsValidationContext -> String)
-> ([VirtualGatewayTlsValidationContext] -> ShowS)
-> Show VirtualGatewayTlsValidationContext
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayTlsValidationContext] -> ShowS
$cshowList :: [VirtualGatewayTlsValidationContext] -> ShowS
show :: VirtualGatewayTlsValidationContext -> String
$cshow :: VirtualGatewayTlsValidationContext -> String
showsPrec :: Int -> VirtualGatewayTlsValidationContext -> ShowS
$cshowsPrec :: Int -> VirtualGatewayTlsValidationContext -> ShowS
Prelude.Show, (forall x.
 VirtualGatewayTlsValidationContext
 -> Rep VirtualGatewayTlsValidationContext x)
-> (forall x.
    Rep VirtualGatewayTlsValidationContext x
    -> VirtualGatewayTlsValidationContext)
-> Generic VirtualGatewayTlsValidationContext
forall x.
Rep VirtualGatewayTlsValidationContext x
-> VirtualGatewayTlsValidationContext
forall x.
VirtualGatewayTlsValidationContext
-> Rep VirtualGatewayTlsValidationContext x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualGatewayTlsValidationContext x
-> VirtualGatewayTlsValidationContext
$cfrom :: forall x.
VirtualGatewayTlsValidationContext
-> Rep VirtualGatewayTlsValidationContext x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayTlsValidationContext' 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:
--
-- 'subjectAlternativeNames', 'virtualGatewayTlsValidationContext_subjectAlternativeNames' - A reference to an object that represents the SANs for a virtual
-- gateway\'s listener\'s Transport Layer Security (TLS) validation
-- context.
--
-- 'trust', 'virtualGatewayTlsValidationContext_trust' - A reference to where to retrieve the trust chain when validating a
-- peer’s Transport Layer Security (TLS) certificate.
newVirtualGatewayTlsValidationContext ::
  -- | 'trust'
  VirtualGatewayTlsValidationContextTrust ->
  VirtualGatewayTlsValidationContext
newVirtualGatewayTlsValidationContext :: VirtualGatewayTlsValidationContextTrust
-> VirtualGatewayTlsValidationContext
newVirtualGatewayTlsValidationContext VirtualGatewayTlsValidationContextTrust
pTrust_ =
  VirtualGatewayTlsValidationContext' :: Maybe SubjectAlternativeNames
-> VirtualGatewayTlsValidationContextTrust
-> VirtualGatewayTlsValidationContext
VirtualGatewayTlsValidationContext'
    { $sel:subjectAlternativeNames:VirtualGatewayTlsValidationContext' :: Maybe SubjectAlternativeNames
subjectAlternativeNames =
        Maybe SubjectAlternativeNames
forall a. Maybe a
Prelude.Nothing,
      $sel:trust:VirtualGatewayTlsValidationContext' :: VirtualGatewayTlsValidationContextTrust
trust = VirtualGatewayTlsValidationContextTrust
pTrust_
    }

-- | A reference to an object that represents the SANs for a virtual
-- gateway\'s listener\'s Transport Layer Security (TLS) validation
-- context.
virtualGatewayTlsValidationContext_subjectAlternativeNames :: Lens.Lens' VirtualGatewayTlsValidationContext (Prelude.Maybe SubjectAlternativeNames)
virtualGatewayTlsValidationContext_subjectAlternativeNames :: (Maybe SubjectAlternativeNames
 -> f (Maybe SubjectAlternativeNames))
-> VirtualGatewayTlsValidationContext
-> f VirtualGatewayTlsValidationContext
virtualGatewayTlsValidationContext_subjectAlternativeNames = (VirtualGatewayTlsValidationContext
 -> Maybe SubjectAlternativeNames)
-> (VirtualGatewayTlsValidationContext
    -> Maybe SubjectAlternativeNames
    -> VirtualGatewayTlsValidationContext)
-> Lens
     VirtualGatewayTlsValidationContext
     VirtualGatewayTlsValidationContext
     (Maybe SubjectAlternativeNames)
     (Maybe SubjectAlternativeNames)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayTlsValidationContext' {Maybe SubjectAlternativeNames
subjectAlternativeNames :: Maybe SubjectAlternativeNames
$sel:subjectAlternativeNames:VirtualGatewayTlsValidationContext' :: VirtualGatewayTlsValidationContext -> Maybe SubjectAlternativeNames
subjectAlternativeNames} -> Maybe SubjectAlternativeNames
subjectAlternativeNames) (\s :: VirtualGatewayTlsValidationContext
s@VirtualGatewayTlsValidationContext' {} Maybe SubjectAlternativeNames
a -> VirtualGatewayTlsValidationContext
s {$sel:subjectAlternativeNames:VirtualGatewayTlsValidationContext' :: Maybe SubjectAlternativeNames
subjectAlternativeNames = Maybe SubjectAlternativeNames
a} :: VirtualGatewayTlsValidationContext)

-- | A reference to where to retrieve the trust chain when validating a
-- peer’s Transport Layer Security (TLS) certificate.
virtualGatewayTlsValidationContext_trust :: Lens.Lens' VirtualGatewayTlsValidationContext VirtualGatewayTlsValidationContextTrust
virtualGatewayTlsValidationContext_trust :: (VirtualGatewayTlsValidationContextTrust
 -> f VirtualGatewayTlsValidationContextTrust)
-> VirtualGatewayTlsValidationContext
-> f VirtualGatewayTlsValidationContext
virtualGatewayTlsValidationContext_trust = (VirtualGatewayTlsValidationContext
 -> VirtualGatewayTlsValidationContextTrust)
-> (VirtualGatewayTlsValidationContext
    -> VirtualGatewayTlsValidationContextTrust
    -> VirtualGatewayTlsValidationContext)
-> Lens
     VirtualGatewayTlsValidationContext
     VirtualGatewayTlsValidationContext
     VirtualGatewayTlsValidationContextTrust
     VirtualGatewayTlsValidationContextTrust
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayTlsValidationContext' {VirtualGatewayTlsValidationContextTrust
trust :: VirtualGatewayTlsValidationContextTrust
$sel:trust:VirtualGatewayTlsValidationContext' :: VirtualGatewayTlsValidationContext
-> VirtualGatewayTlsValidationContextTrust
trust} -> VirtualGatewayTlsValidationContextTrust
trust) (\s :: VirtualGatewayTlsValidationContext
s@VirtualGatewayTlsValidationContext' {} VirtualGatewayTlsValidationContextTrust
a -> VirtualGatewayTlsValidationContext
s {$sel:trust:VirtualGatewayTlsValidationContext' :: VirtualGatewayTlsValidationContextTrust
trust = VirtualGatewayTlsValidationContextTrust
a} :: VirtualGatewayTlsValidationContext)

instance
  Core.FromJSON
    VirtualGatewayTlsValidationContext
  where
  parseJSON :: Value -> Parser VirtualGatewayTlsValidationContext
parseJSON =
    String
-> (Object -> Parser VirtualGatewayTlsValidationContext)
-> Value
-> Parser VirtualGatewayTlsValidationContext
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualGatewayTlsValidationContext"
      ( \Object
x ->
          Maybe SubjectAlternativeNames
-> VirtualGatewayTlsValidationContextTrust
-> VirtualGatewayTlsValidationContext
VirtualGatewayTlsValidationContext'
            (Maybe SubjectAlternativeNames
 -> VirtualGatewayTlsValidationContextTrust
 -> VirtualGatewayTlsValidationContext)
-> Parser (Maybe SubjectAlternativeNames)
-> Parser
     (VirtualGatewayTlsValidationContextTrust
      -> VirtualGatewayTlsValidationContext)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SubjectAlternativeNames)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"subjectAlternativeNames")
            Parser
  (VirtualGatewayTlsValidationContextTrust
   -> VirtualGatewayTlsValidationContext)
-> Parser VirtualGatewayTlsValidationContextTrust
-> Parser VirtualGatewayTlsValidationContext
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser VirtualGatewayTlsValidationContextTrust
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"trust")
      )

instance
  Prelude.Hashable
    VirtualGatewayTlsValidationContext

instance
  Prelude.NFData
    VirtualGatewayTlsValidationContext

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