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

import Amazonka.AppMesh.Types.VirtualGatewayGrpcConnectionPool
import Amazonka.AppMesh.Types.VirtualGatewayHttp2ConnectionPool
import Amazonka.AppMesh.Types.VirtualGatewayHttpConnectionPool
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 type of virtual gateway connection pool.
--
-- Only one protocol is used at a time and should be the same protocol as
-- the one chosen under port mapping.
--
-- If not present the default value for @maxPendingRequests@ is
-- @2147483647@.
--
-- /See:/ 'newVirtualGatewayConnectionPool' smart constructor.
data VirtualGatewayConnectionPool = VirtualGatewayConnectionPool'
  { -- | An object that represents a type of connection pool.
    VirtualGatewayConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
grpc :: Prelude.Maybe VirtualGatewayGrpcConnectionPool,
    -- | An object that represents a type of connection pool.
    VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
http :: Prelude.Maybe VirtualGatewayHttpConnectionPool,
    -- | An object that represents a type of connection pool.
    VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttp2ConnectionPool
http2 :: Prelude.Maybe VirtualGatewayHttp2ConnectionPool
  }
  deriving (VirtualGatewayConnectionPool
-> VirtualGatewayConnectionPool -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayConnectionPool
-> VirtualGatewayConnectionPool -> Bool
$c/= :: VirtualGatewayConnectionPool
-> VirtualGatewayConnectionPool -> Bool
== :: VirtualGatewayConnectionPool
-> VirtualGatewayConnectionPool -> Bool
$c== :: VirtualGatewayConnectionPool
-> VirtualGatewayConnectionPool -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayConnectionPool]
ReadPrec VirtualGatewayConnectionPool
Int -> ReadS VirtualGatewayConnectionPool
ReadS [VirtualGatewayConnectionPool]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayConnectionPool]
$creadListPrec :: ReadPrec [VirtualGatewayConnectionPool]
readPrec :: ReadPrec VirtualGatewayConnectionPool
$creadPrec :: ReadPrec VirtualGatewayConnectionPool
readList :: ReadS [VirtualGatewayConnectionPool]
$creadList :: ReadS [VirtualGatewayConnectionPool]
readsPrec :: Int -> ReadS VirtualGatewayConnectionPool
$creadsPrec :: Int -> ReadS VirtualGatewayConnectionPool
Prelude.Read, Int -> VirtualGatewayConnectionPool -> ShowS
[VirtualGatewayConnectionPool] -> ShowS
VirtualGatewayConnectionPool -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayConnectionPool] -> ShowS
$cshowList :: [VirtualGatewayConnectionPool] -> ShowS
show :: VirtualGatewayConnectionPool -> String
$cshow :: VirtualGatewayConnectionPool -> String
showsPrec :: Int -> VirtualGatewayConnectionPool -> ShowS
$cshowsPrec :: Int -> VirtualGatewayConnectionPool -> ShowS
Prelude.Show, forall x.
Rep VirtualGatewayConnectionPool x -> VirtualGatewayConnectionPool
forall x.
VirtualGatewayConnectionPool -> Rep VirtualGatewayConnectionPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualGatewayConnectionPool x -> VirtualGatewayConnectionPool
$cfrom :: forall x.
VirtualGatewayConnectionPool -> Rep VirtualGatewayConnectionPool x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayConnectionPool' 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:
--
-- 'grpc', 'virtualGatewayConnectionPool_grpc' - An object that represents a type of connection pool.
--
-- 'http', 'virtualGatewayConnectionPool_http' - An object that represents a type of connection pool.
--
-- 'http2', 'virtualGatewayConnectionPool_http2' - An object that represents a type of connection pool.
newVirtualGatewayConnectionPool ::
  VirtualGatewayConnectionPool
newVirtualGatewayConnectionPool :: VirtualGatewayConnectionPool
newVirtualGatewayConnectionPool =
  VirtualGatewayConnectionPool'
    { $sel:grpc:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayGrpcConnectionPool
grpc =
        forall a. Maybe a
Prelude.Nothing,
      $sel:http:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayHttpConnectionPool
http = forall a. Maybe a
Prelude.Nothing,
      $sel:http2:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayHttp2ConnectionPool
http2 = forall a. Maybe a
Prelude.Nothing
    }

-- | An object that represents a type of connection pool.
virtualGatewayConnectionPool_grpc :: Lens.Lens' VirtualGatewayConnectionPool (Prelude.Maybe VirtualGatewayGrpcConnectionPool)
virtualGatewayConnectionPool_grpc :: Lens'
  VirtualGatewayConnectionPool
  (Maybe VirtualGatewayGrpcConnectionPool)
virtualGatewayConnectionPool_grpc = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayConnectionPool' {Maybe VirtualGatewayGrpcConnectionPool
grpc :: Maybe VirtualGatewayGrpcConnectionPool
$sel:grpc:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
grpc} -> Maybe VirtualGatewayGrpcConnectionPool
grpc) (\s :: VirtualGatewayConnectionPool
s@VirtualGatewayConnectionPool' {} Maybe VirtualGatewayGrpcConnectionPool
a -> VirtualGatewayConnectionPool
s {$sel:grpc:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayGrpcConnectionPool
grpc = Maybe VirtualGatewayGrpcConnectionPool
a} :: VirtualGatewayConnectionPool)

-- | An object that represents a type of connection pool.
virtualGatewayConnectionPool_http :: Lens.Lens' VirtualGatewayConnectionPool (Prelude.Maybe VirtualGatewayHttpConnectionPool)
virtualGatewayConnectionPool_http :: Lens'
  VirtualGatewayConnectionPool
  (Maybe VirtualGatewayHttpConnectionPool)
virtualGatewayConnectionPool_http = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayConnectionPool' {Maybe VirtualGatewayHttpConnectionPool
http :: Maybe VirtualGatewayHttpConnectionPool
$sel:http:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
http} -> Maybe VirtualGatewayHttpConnectionPool
http) (\s :: VirtualGatewayConnectionPool
s@VirtualGatewayConnectionPool' {} Maybe VirtualGatewayHttpConnectionPool
a -> VirtualGatewayConnectionPool
s {$sel:http:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayHttpConnectionPool
http = Maybe VirtualGatewayHttpConnectionPool
a} :: VirtualGatewayConnectionPool)

-- | An object that represents a type of connection pool.
virtualGatewayConnectionPool_http2 :: Lens.Lens' VirtualGatewayConnectionPool (Prelude.Maybe VirtualGatewayHttp2ConnectionPool)
virtualGatewayConnectionPool_http2 :: Lens'
  VirtualGatewayConnectionPool
  (Maybe VirtualGatewayHttp2ConnectionPool)
virtualGatewayConnectionPool_http2 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayConnectionPool' {Maybe VirtualGatewayHttp2ConnectionPool
http2 :: Maybe VirtualGatewayHttp2ConnectionPool
$sel:http2:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttp2ConnectionPool
http2} -> Maybe VirtualGatewayHttp2ConnectionPool
http2) (\s :: VirtualGatewayConnectionPool
s@VirtualGatewayConnectionPool' {} Maybe VirtualGatewayHttp2ConnectionPool
a -> VirtualGatewayConnectionPool
s {$sel:http2:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayHttp2ConnectionPool
http2 = Maybe VirtualGatewayHttp2ConnectionPool
a} :: VirtualGatewayConnectionPool)

instance Data.FromJSON VirtualGatewayConnectionPool where
  parseJSON :: Value -> Parser VirtualGatewayConnectionPool
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualGatewayConnectionPool"
      ( \Object
x ->
          Maybe VirtualGatewayGrpcConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
-> Maybe VirtualGatewayHttp2ConnectionPool
-> VirtualGatewayConnectionPool
VirtualGatewayConnectionPool'
            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
"grpc")
            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
"http")
            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
"http2")
      )

instance
  Prelude.Hashable
    VirtualGatewayConnectionPool
  where
  hashWithSalt :: Int -> VirtualGatewayConnectionPool -> Int
hashWithSalt Int
_salt VirtualGatewayConnectionPool' {Maybe VirtualGatewayGrpcConnectionPool
Maybe VirtualGatewayHttp2ConnectionPool
Maybe VirtualGatewayHttpConnectionPool
http2 :: Maybe VirtualGatewayHttp2ConnectionPool
http :: Maybe VirtualGatewayHttpConnectionPool
grpc :: Maybe VirtualGatewayGrpcConnectionPool
$sel:http2:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttp2ConnectionPool
$sel:http:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
$sel:grpc:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayGrpcConnectionPool
grpc
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayHttpConnectionPool
http
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayHttp2ConnectionPool
http2

instance Prelude.NFData VirtualGatewayConnectionPool where
  rnf :: VirtualGatewayConnectionPool -> ()
rnf VirtualGatewayConnectionPool' {Maybe VirtualGatewayGrpcConnectionPool
Maybe VirtualGatewayHttp2ConnectionPool
Maybe VirtualGatewayHttpConnectionPool
http2 :: Maybe VirtualGatewayHttp2ConnectionPool
http :: Maybe VirtualGatewayHttpConnectionPool
grpc :: Maybe VirtualGatewayGrpcConnectionPool
$sel:http2:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttp2ConnectionPool
$sel:http:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
$sel:grpc:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayGrpcConnectionPool
grpc
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayHttpConnectionPool
http
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayHttp2ConnectionPool
http2

instance Data.ToJSON VirtualGatewayConnectionPool where
  toJSON :: VirtualGatewayConnectionPool -> Value
toJSON VirtualGatewayConnectionPool' {Maybe VirtualGatewayGrpcConnectionPool
Maybe VirtualGatewayHttp2ConnectionPool
Maybe VirtualGatewayHttpConnectionPool
http2 :: Maybe VirtualGatewayHttp2ConnectionPool
http :: Maybe VirtualGatewayHttpConnectionPool
grpc :: Maybe VirtualGatewayGrpcConnectionPool
$sel:http2:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttp2ConnectionPool
$sel:http:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
$sel:grpc:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"grpc" 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 VirtualGatewayGrpcConnectionPool
grpc,
            (Key
"http" 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 VirtualGatewayHttpConnectionPool
http,
            (Key
"http2" 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 VirtualGatewayHttp2ConnectionPool
http2
          ]
      )