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

import Amazonka.AppMesh.Types.VirtualGatewayConnectionPool
import Amazonka.AppMesh.Types.VirtualGatewayHealthCheckPolicy
import Amazonka.AppMesh.Types.VirtualGatewayListenerTls
import Amazonka.AppMesh.Types.VirtualGatewayPortMapping
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 a listener for a virtual gateway.
--
-- /See:/ 'newVirtualGatewayListener' smart constructor.
data VirtualGatewayListener = VirtualGatewayListener'
  { -- | The connection pool information for the virtual gateway listener.
    VirtualGatewayListener -> Maybe VirtualGatewayConnectionPool
connectionPool :: Prelude.Maybe VirtualGatewayConnectionPool,
    -- | The health check information for the listener.
    VirtualGatewayListener -> Maybe VirtualGatewayHealthCheckPolicy
healthCheck :: Prelude.Maybe VirtualGatewayHealthCheckPolicy,
    -- | A reference to an object that represents the Transport Layer Security
    -- (TLS) properties for the listener.
    VirtualGatewayListener -> Maybe VirtualGatewayListenerTls
tls :: Prelude.Maybe VirtualGatewayListenerTls,
    -- | The port mapping information for the listener.
    VirtualGatewayListener -> VirtualGatewayPortMapping
portMapping :: VirtualGatewayPortMapping
  }
  deriving (VirtualGatewayListener -> VirtualGatewayListener -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayListener -> VirtualGatewayListener -> Bool
$c/= :: VirtualGatewayListener -> VirtualGatewayListener -> Bool
== :: VirtualGatewayListener -> VirtualGatewayListener -> Bool
$c== :: VirtualGatewayListener -> VirtualGatewayListener -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayListener]
ReadPrec VirtualGatewayListener
Int -> ReadS VirtualGatewayListener
ReadS [VirtualGatewayListener]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayListener]
$creadListPrec :: ReadPrec [VirtualGatewayListener]
readPrec :: ReadPrec VirtualGatewayListener
$creadPrec :: ReadPrec VirtualGatewayListener
readList :: ReadS [VirtualGatewayListener]
$creadList :: ReadS [VirtualGatewayListener]
readsPrec :: Int -> ReadS VirtualGatewayListener
$creadsPrec :: Int -> ReadS VirtualGatewayListener
Prelude.Read, Int -> VirtualGatewayListener -> ShowS
[VirtualGatewayListener] -> ShowS
VirtualGatewayListener -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayListener] -> ShowS
$cshowList :: [VirtualGatewayListener] -> ShowS
show :: VirtualGatewayListener -> String
$cshow :: VirtualGatewayListener -> String
showsPrec :: Int -> VirtualGatewayListener -> ShowS
$cshowsPrec :: Int -> VirtualGatewayListener -> ShowS
Prelude.Show, forall x. Rep VirtualGatewayListener x -> VirtualGatewayListener
forall x. VirtualGatewayListener -> Rep VirtualGatewayListener x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VirtualGatewayListener x -> VirtualGatewayListener
$cfrom :: forall x. VirtualGatewayListener -> Rep VirtualGatewayListener x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayListener' 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:
--
-- 'connectionPool', 'virtualGatewayListener_connectionPool' - The connection pool information for the virtual gateway listener.
--
-- 'healthCheck', 'virtualGatewayListener_healthCheck' - The health check information for the listener.
--
-- 'tls', 'virtualGatewayListener_tls' - A reference to an object that represents the Transport Layer Security
-- (TLS) properties for the listener.
--
-- 'portMapping', 'virtualGatewayListener_portMapping' - The port mapping information for the listener.
newVirtualGatewayListener ::
  -- | 'portMapping'
  VirtualGatewayPortMapping ->
  VirtualGatewayListener
newVirtualGatewayListener :: VirtualGatewayPortMapping -> VirtualGatewayListener
newVirtualGatewayListener VirtualGatewayPortMapping
pPortMapping_ =
  VirtualGatewayListener'
    { $sel:connectionPool:VirtualGatewayListener' :: Maybe VirtualGatewayConnectionPool
connectionPool =
        forall a. Maybe a
Prelude.Nothing,
      $sel:healthCheck:VirtualGatewayListener' :: Maybe VirtualGatewayHealthCheckPolicy
healthCheck = forall a. Maybe a
Prelude.Nothing,
      $sel:tls:VirtualGatewayListener' :: Maybe VirtualGatewayListenerTls
tls = forall a. Maybe a
Prelude.Nothing,
      $sel:portMapping:VirtualGatewayListener' :: VirtualGatewayPortMapping
portMapping = VirtualGatewayPortMapping
pPortMapping_
    }

-- | The connection pool information for the virtual gateway listener.
virtualGatewayListener_connectionPool :: Lens.Lens' VirtualGatewayListener (Prelude.Maybe VirtualGatewayConnectionPool)
virtualGatewayListener_connectionPool :: Lens' VirtualGatewayListener (Maybe VirtualGatewayConnectionPool)
virtualGatewayListener_connectionPool = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayListener' {Maybe VirtualGatewayConnectionPool
connectionPool :: Maybe VirtualGatewayConnectionPool
$sel:connectionPool:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayConnectionPool
connectionPool} -> Maybe VirtualGatewayConnectionPool
connectionPool) (\s :: VirtualGatewayListener
s@VirtualGatewayListener' {} Maybe VirtualGatewayConnectionPool
a -> VirtualGatewayListener
s {$sel:connectionPool:VirtualGatewayListener' :: Maybe VirtualGatewayConnectionPool
connectionPool = Maybe VirtualGatewayConnectionPool
a} :: VirtualGatewayListener)

-- | The health check information for the listener.
virtualGatewayListener_healthCheck :: Lens.Lens' VirtualGatewayListener (Prelude.Maybe VirtualGatewayHealthCheckPolicy)
virtualGatewayListener_healthCheck :: Lens'
  VirtualGatewayListener (Maybe VirtualGatewayHealthCheckPolicy)
virtualGatewayListener_healthCheck = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayListener' {Maybe VirtualGatewayHealthCheckPolicy
healthCheck :: Maybe VirtualGatewayHealthCheckPolicy
$sel:healthCheck:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayHealthCheckPolicy
healthCheck} -> Maybe VirtualGatewayHealthCheckPolicy
healthCheck) (\s :: VirtualGatewayListener
s@VirtualGatewayListener' {} Maybe VirtualGatewayHealthCheckPolicy
a -> VirtualGatewayListener
s {$sel:healthCheck:VirtualGatewayListener' :: Maybe VirtualGatewayHealthCheckPolicy
healthCheck = Maybe VirtualGatewayHealthCheckPolicy
a} :: VirtualGatewayListener)

-- | A reference to an object that represents the Transport Layer Security
-- (TLS) properties for the listener.
virtualGatewayListener_tls :: Lens.Lens' VirtualGatewayListener (Prelude.Maybe VirtualGatewayListenerTls)
virtualGatewayListener_tls :: Lens' VirtualGatewayListener (Maybe VirtualGatewayListenerTls)
virtualGatewayListener_tls = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayListener' {Maybe VirtualGatewayListenerTls
tls :: Maybe VirtualGatewayListenerTls
$sel:tls:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayListenerTls
tls} -> Maybe VirtualGatewayListenerTls
tls) (\s :: VirtualGatewayListener
s@VirtualGatewayListener' {} Maybe VirtualGatewayListenerTls
a -> VirtualGatewayListener
s {$sel:tls:VirtualGatewayListener' :: Maybe VirtualGatewayListenerTls
tls = Maybe VirtualGatewayListenerTls
a} :: VirtualGatewayListener)

-- | The port mapping information for the listener.
virtualGatewayListener_portMapping :: Lens.Lens' VirtualGatewayListener VirtualGatewayPortMapping
virtualGatewayListener_portMapping :: Lens' VirtualGatewayListener VirtualGatewayPortMapping
virtualGatewayListener_portMapping = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayListener' {VirtualGatewayPortMapping
portMapping :: VirtualGatewayPortMapping
$sel:portMapping:VirtualGatewayListener' :: VirtualGatewayListener -> VirtualGatewayPortMapping
portMapping} -> VirtualGatewayPortMapping
portMapping) (\s :: VirtualGatewayListener
s@VirtualGatewayListener' {} VirtualGatewayPortMapping
a -> VirtualGatewayListener
s {$sel:portMapping:VirtualGatewayListener' :: VirtualGatewayPortMapping
portMapping = VirtualGatewayPortMapping
a} :: VirtualGatewayListener)

instance Data.FromJSON VirtualGatewayListener where
  parseJSON :: Value -> Parser VirtualGatewayListener
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualGatewayListener"
      ( \Object
x ->
          Maybe VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHealthCheckPolicy
-> Maybe VirtualGatewayListenerTls
-> VirtualGatewayPortMapping
-> VirtualGatewayListener
VirtualGatewayListener'
            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
"connectionPool")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"healthCheck")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tls")
            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
"portMapping")
      )

instance Prelude.Hashable VirtualGatewayListener where
  hashWithSalt :: Int -> VirtualGatewayListener -> Int
hashWithSalt Int
_salt VirtualGatewayListener' {Maybe VirtualGatewayConnectionPool
Maybe VirtualGatewayHealthCheckPolicy
Maybe VirtualGatewayListenerTls
VirtualGatewayPortMapping
portMapping :: VirtualGatewayPortMapping
tls :: Maybe VirtualGatewayListenerTls
healthCheck :: Maybe VirtualGatewayHealthCheckPolicy
connectionPool :: Maybe VirtualGatewayConnectionPool
$sel:portMapping:VirtualGatewayListener' :: VirtualGatewayListener -> VirtualGatewayPortMapping
$sel:tls:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayListenerTls
$sel:healthCheck:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayHealthCheckPolicy
$sel:connectionPool:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayConnectionPool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayConnectionPool
connectionPool
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayHealthCheckPolicy
healthCheck
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayListenerTls
tls
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` VirtualGatewayPortMapping
portMapping

instance Prelude.NFData VirtualGatewayListener where
  rnf :: VirtualGatewayListener -> ()
rnf VirtualGatewayListener' {Maybe VirtualGatewayConnectionPool
Maybe VirtualGatewayHealthCheckPolicy
Maybe VirtualGatewayListenerTls
VirtualGatewayPortMapping
portMapping :: VirtualGatewayPortMapping
tls :: Maybe VirtualGatewayListenerTls
healthCheck :: Maybe VirtualGatewayHealthCheckPolicy
connectionPool :: Maybe VirtualGatewayConnectionPool
$sel:portMapping:VirtualGatewayListener' :: VirtualGatewayListener -> VirtualGatewayPortMapping
$sel:tls:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayListenerTls
$sel:healthCheck:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayHealthCheckPolicy
$sel:connectionPool:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayConnectionPool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayConnectionPool
connectionPool
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayHealthCheckPolicy
healthCheck
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayListenerTls
tls
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf VirtualGatewayPortMapping
portMapping

instance Data.ToJSON VirtualGatewayListener where
  toJSON :: VirtualGatewayListener -> Value
toJSON VirtualGatewayListener' {Maybe VirtualGatewayConnectionPool
Maybe VirtualGatewayHealthCheckPolicy
Maybe VirtualGatewayListenerTls
VirtualGatewayPortMapping
portMapping :: VirtualGatewayPortMapping
tls :: Maybe VirtualGatewayListenerTls
healthCheck :: Maybe VirtualGatewayHealthCheckPolicy
connectionPool :: Maybe VirtualGatewayConnectionPool
$sel:portMapping:VirtualGatewayListener' :: VirtualGatewayListener -> VirtualGatewayPortMapping
$sel:tls:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayListenerTls
$sel:healthCheck:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayHealthCheckPolicy
$sel:connectionPool:VirtualGatewayListener' :: VirtualGatewayListener -> Maybe VirtualGatewayConnectionPool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"connectionPool" 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 VirtualGatewayConnectionPool
connectionPool,
            (Key
"healthCheck" 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 VirtualGatewayHealthCheckPolicy
healthCheck,
            (Key
"tls" 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 VirtualGatewayListenerTls
tls,
            forall a. a -> Maybe a
Prelude.Just (Key
"portMapping" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= VirtualGatewayPortMapping
portMapping)
          ]
      )