{-# 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.ListenerTls
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppMesh.Types.ListenerTls where

import Amazonka.AppMesh.Types.ListenerTlsCertificate
import Amazonka.AppMesh.Types.ListenerTlsMode
import Amazonka.AppMesh.Types.ListenerTlsValidationContext
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object that represents the Transport Layer Security (TLS) properties
-- for a listener.
--
-- /See:/ 'newListenerTls' smart constructor.
data ListenerTls = ListenerTls'
  { -- | A reference to an object that represents a listener\'s Transport Layer
    -- Security (TLS) validation context.
    ListenerTls -> Maybe ListenerTlsValidationContext
validation :: Prelude.Maybe ListenerTlsValidationContext,
    -- | A reference to an object that represents a listener\'s Transport Layer
    -- Security (TLS) certificate.
    ListenerTls -> ListenerTlsCertificate
certificate :: ListenerTlsCertificate,
    -- | Specify one of the following modes.
    --
    -- -   ____STRICT – Listener only accepts connections with TLS enabled.
    --
    -- -   ____PERMISSIVE – Listener accepts connections with or without TLS
    --     enabled.
    --
    -- -   ____DISABLED – Listener only accepts connections without TLS.
    ListenerTls -> ListenerTlsMode
mode :: ListenerTlsMode
  }
  deriving (ListenerTls -> ListenerTls -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListenerTls -> ListenerTls -> Bool
$c/= :: ListenerTls -> ListenerTls -> Bool
== :: ListenerTls -> ListenerTls -> Bool
$c== :: ListenerTls -> ListenerTls -> Bool
Prelude.Eq, ReadPrec [ListenerTls]
ReadPrec ListenerTls
Int -> ReadS ListenerTls
ReadS [ListenerTls]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListenerTls]
$creadListPrec :: ReadPrec [ListenerTls]
readPrec :: ReadPrec ListenerTls
$creadPrec :: ReadPrec ListenerTls
readList :: ReadS [ListenerTls]
$creadList :: ReadS [ListenerTls]
readsPrec :: Int -> ReadS ListenerTls
$creadsPrec :: Int -> ReadS ListenerTls
Prelude.Read, Int -> ListenerTls -> ShowS
[ListenerTls] -> ShowS
ListenerTls -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListenerTls] -> ShowS
$cshowList :: [ListenerTls] -> ShowS
show :: ListenerTls -> String
$cshow :: ListenerTls -> String
showsPrec :: Int -> ListenerTls -> ShowS
$cshowsPrec :: Int -> ListenerTls -> ShowS
Prelude.Show, forall x. Rep ListenerTls x -> ListenerTls
forall x. ListenerTls -> Rep ListenerTls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListenerTls x -> ListenerTls
$cfrom :: forall x. ListenerTls -> Rep ListenerTls x
Prelude.Generic)

-- |
-- Create a value of 'ListenerTls' 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:
--
-- 'validation', 'listenerTls_validation' - A reference to an object that represents a listener\'s Transport Layer
-- Security (TLS) validation context.
--
-- 'certificate', 'listenerTls_certificate' - A reference to an object that represents a listener\'s Transport Layer
-- Security (TLS) certificate.
--
-- 'mode', 'listenerTls_mode' - Specify one of the following modes.
--
-- -   ____STRICT – Listener only accepts connections with TLS enabled.
--
-- -   ____PERMISSIVE – Listener accepts connections with or without TLS
--     enabled.
--
-- -   ____DISABLED – Listener only accepts connections without TLS.
newListenerTls ::
  -- | 'certificate'
  ListenerTlsCertificate ->
  -- | 'mode'
  ListenerTlsMode ->
  ListenerTls
newListenerTls :: ListenerTlsCertificate -> ListenerTlsMode -> ListenerTls
newListenerTls ListenerTlsCertificate
pCertificate_ ListenerTlsMode
pMode_ =
  ListenerTls'
    { $sel:validation:ListenerTls' :: Maybe ListenerTlsValidationContext
validation = forall a. Maybe a
Prelude.Nothing,
      $sel:certificate:ListenerTls' :: ListenerTlsCertificate
certificate = ListenerTlsCertificate
pCertificate_,
      $sel:mode:ListenerTls' :: ListenerTlsMode
mode = ListenerTlsMode
pMode_
    }

-- | A reference to an object that represents a listener\'s Transport Layer
-- Security (TLS) validation context.
listenerTls_validation :: Lens.Lens' ListenerTls (Prelude.Maybe ListenerTlsValidationContext)
listenerTls_validation :: Lens' ListenerTls (Maybe ListenerTlsValidationContext)
listenerTls_validation = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListenerTls' {Maybe ListenerTlsValidationContext
validation :: Maybe ListenerTlsValidationContext
$sel:validation:ListenerTls' :: ListenerTls -> Maybe ListenerTlsValidationContext
validation} -> Maybe ListenerTlsValidationContext
validation) (\s :: ListenerTls
s@ListenerTls' {} Maybe ListenerTlsValidationContext
a -> ListenerTls
s {$sel:validation:ListenerTls' :: Maybe ListenerTlsValidationContext
validation = Maybe ListenerTlsValidationContext
a} :: ListenerTls)

-- | A reference to an object that represents a listener\'s Transport Layer
-- Security (TLS) certificate.
listenerTls_certificate :: Lens.Lens' ListenerTls ListenerTlsCertificate
listenerTls_certificate :: Lens' ListenerTls ListenerTlsCertificate
listenerTls_certificate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListenerTls' {ListenerTlsCertificate
certificate :: ListenerTlsCertificate
$sel:certificate:ListenerTls' :: ListenerTls -> ListenerTlsCertificate
certificate} -> ListenerTlsCertificate
certificate) (\s :: ListenerTls
s@ListenerTls' {} ListenerTlsCertificate
a -> ListenerTls
s {$sel:certificate:ListenerTls' :: ListenerTlsCertificate
certificate = ListenerTlsCertificate
a} :: ListenerTls)

-- | Specify one of the following modes.
--
-- -   ____STRICT – Listener only accepts connections with TLS enabled.
--
-- -   ____PERMISSIVE – Listener accepts connections with or without TLS
--     enabled.
--
-- -   ____DISABLED – Listener only accepts connections without TLS.
listenerTls_mode :: Lens.Lens' ListenerTls ListenerTlsMode
listenerTls_mode :: Lens' ListenerTls ListenerTlsMode
listenerTls_mode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListenerTls' {ListenerTlsMode
mode :: ListenerTlsMode
$sel:mode:ListenerTls' :: ListenerTls -> ListenerTlsMode
mode} -> ListenerTlsMode
mode) (\s :: ListenerTls
s@ListenerTls' {} ListenerTlsMode
a -> ListenerTls
s {$sel:mode:ListenerTls' :: ListenerTlsMode
mode = ListenerTlsMode
a} :: ListenerTls)

instance Data.FromJSON ListenerTls where
  parseJSON :: Value -> Parser ListenerTls
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ListenerTls"
      ( \Object
x ->
          Maybe ListenerTlsValidationContext
-> ListenerTlsCertificate -> ListenerTlsMode -> ListenerTls
ListenerTls'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"validation")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"certificate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"mode")
      )

instance Prelude.Hashable ListenerTls where
  hashWithSalt :: Int -> ListenerTls -> Int
hashWithSalt Int
_salt ListenerTls' {Maybe ListenerTlsValidationContext
ListenerTlsMode
ListenerTlsCertificate
mode :: ListenerTlsMode
certificate :: ListenerTlsCertificate
validation :: Maybe ListenerTlsValidationContext
$sel:mode:ListenerTls' :: ListenerTls -> ListenerTlsMode
$sel:certificate:ListenerTls' :: ListenerTls -> ListenerTlsCertificate
$sel:validation:ListenerTls' :: ListenerTls -> Maybe ListenerTlsValidationContext
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ListenerTlsValidationContext
validation
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ListenerTlsCertificate
certificate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ListenerTlsMode
mode

instance Prelude.NFData ListenerTls where
  rnf :: ListenerTls -> ()
rnf ListenerTls' {Maybe ListenerTlsValidationContext
ListenerTlsMode
ListenerTlsCertificate
mode :: ListenerTlsMode
certificate :: ListenerTlsCertificate
validation :: Maybe ListenerTlsValidationContext
$sel:mode:ListenerTls' :: ListenerTls -> ListenerTlsMode
$sel:certificate:ListenerTls' :: ListenerTls -> ListenerTlsCertificate
$sel:validation:ListenerTls' :: ListenerTls -> Maybe ListenerTlsValidationContext
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ListenerTlsValidationContext
validation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ListenerTlsCertificate
certificate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ListenerTlsMode
mode

instance Data.ToJSON ListenerTls where
  toJSON :: ListenerTls -> Value
toJSON ListenerTls' {Maybe ListenerTlsValidationContext
ListenerTlsMode
ListenerTlsCertificate
mode :: ListenerTlsMode
certificate :: ListenerTlsCertificate
validation :: Maybe ListenerTlsValidationContext
$sel:mode:ListenerTls' :: ListenerTls -> ListenerTlsMode
$sel:certificate:ListenerTls' :: ListenerTls -> ListenerTlsCertificate
$sel:validation:ListenerTls' :: ListenerTls -> Maybe ListenerTlsValidationContext
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"validation" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ListenerTlsValidationContext
validation,
            forall a. a -> Maybe a
Prelude.Just (Key
"certificate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ListenerTlsCertificate
certificate),
            forall a. a -> Maybe a
Prelude.Just (Key
"mode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ListenerTlsMode
mode)
          ]
      )