{-# 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-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.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.Lens as Lens
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 VirtualGatewayHttp2ConnectionPool
http2 :: Prelude.Maybe VirtualGatewayHttp2ConnectionPool,
    -- | 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
  }
  deriving (VirtualGatewayConnectionPool
-> VirtualGatewayConnectionPool -> Bool
(VirtualGatewayConnectionPool
 -> VirtualGatewayConnectionPool -> Bool)
-> (VirtualGatewayConnectionPool
    -> VirtualGatewayConnectionPool -> Bool)
-> Eq VirtualGatewayConnectionPool
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]
(Int -> ReadS VirtualGatewayConnectionPool)
-> ReadS [VirtualGatewayConnectionPool]
-> ReadPrec VirtualGatewayConnectionPool
-> ReadPrec [VirtualGatewayConnectionPool]
-> Read 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
(Int -> VirtualGatewayConnectionPool -> ShowS)
-> (VirtualGatewayConnectionPool -> String)
-> ([VirtualGatewayConnectionPool] -> ShowS)
-> Show VirtualGatewayConnectionPool
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.
 VirtualGatewayConnectionPool -> Rep VirtualGatewayConnectionPool x)
-> (forall x.
    Rep VirtualGatewayConnectionPool x -> VirtualGatewayConnectionPool)
-> Generic VirtualGatewayConnectionPool
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:
--
-- 'http2', 'virtualGatewayConnectionPool_http2' - An object that represents a type of connection pool.
--
-- 'grpc', 'virtualGatewayConnectionPool_grpc' - An object that represents a type of connection pool.
--
-- 'http', 'virtualGatewayConnectionPool_http' - An object that represents a type of connection pool.
newVirtualGatewayConnectionPool ::
  VirtualGatewayConnectionPool
newVirtualGatewayConnectionPool :: VirtualGatewayConnectionPool
newVirtualGatewayConnectionPool =
  VirtualGatewayConnectionPool' :: Maybe VirtualGatewayHttp2ConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
-> VirtualGatewayConnectionPool
VirtualGatewayConnectionPool'
    { $sel:http2:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayHttp2ConnectionPool
http2 =
        Maybe VirtualGatewayHttp2ConnectionPool
forall a. Maybe a
Prelude.Nothing,
      $sel:grpc:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayGrpcConnectionPool
grpc = Maybe VirtualGatewayGrpcConnectionPool
forall a. Maybe a
Prelude.Nothing,
      $sel:http:VirtualGatewayConnectionPool' :: Maybe VirtualGatewayHttpConnectionPool
http = Maybe VirtualGatewayHttpConnectionPool
forall a. Maybe a
Prelude.Nothing
    }

-- | An object that represents a type of connection pool.
virtualGatewayConnectionPool_http2 :: Lens.Lens' VirtualGatewayConnectionPool (Prelude.Maybe VirtualGatewayHttp2ConnectionPool)
virtualGatewayConnectionPool_http2 :: (Maybe VirtualGatewayHttp2ConnectionPool
 -> f (Maybe VirtualGatewayHttp2ConnectionPool))
-> VirtualGatewayConnectionPool -> f VirtualGatewayConnectionPool
virtualGatewayConnectionPool_http2 = (VirtualGatewayConnectionPool
 -> Maybe VirtualGatewayHttp2ConnectionPool)
-> (VirtualGatewayConnectionPool
    -> Maybe VirtualGatewayHttp2ConnectionPool
    -> VirtualGatewayConnectionPool)
-> Lens
     VirtualGatewayConnectionPool
     VirtualGatewayConnectionPool
     (Maybe VirtualGatewayHttp2ConnectionPool)
     (Maybe VirtualGatewayHttp2ConnectionPool)
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)

-- | An object that represents a type of connection pool.
virtualGatewayConnectionPool_grpc :: Lens.Lens' VirtualGatewayConnectionPool (Prelude.Maybe VirtualGatewayGrpcConnectionPool)
virtualGatewayConnectionPool_grpc :: (Maybe VirtualGatewayGrpcConnectionPool
 -> f (Maybe VirtualGatewayGrpcConnectionPool))
-> VirtualGatewayConnectionPool -> f VirtualGatewayConnectionPool
virtualGatewayConnectionPool_grpc = (VirtualGatewayConnectionPool
 -> Maybe VirtualGatewayGrpcConnectionPool)
-> (VirtualGatewayConnectionPool
    -> Maybe VirtualGatewayGrpcConnectionPool
    -> VirtualGatewayConnectionPool)
-> Lens
     VirtualGatewayConnectionPool
     VirtualGatewayConnectionPool
     (Maybe VirtualGatewayGrpcConnectionPool)
     (Maybe VirtualGatewayGrpcConnectionPool)
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 :: (Maybe VirtualGatewayHttpConnectionPool
 -> f (Maybe VirtualGatewayHttpConnectionPool))
-> VirtualGatewayConnectionPool -> f VirtualGatewayConnectionPool
virtualGatewayConnectionPool_http = (VirtualGatewayConnectionPool
 -> Maybe VirtualGatewayHttpConnectionPool)
-> (VirtualGatewayConnectionPool
    -> Maybe VirtualGatewayHttpConnectionPool
    -> VirtualGatewayConnectionPool)
-> Lens
     VirtualGatewayConnectionPool
     VirtualGatewayConnectionPool
     (Maybe VirtualGatewayHttpConnectionPool)
     (Maybe VirtualGatewayHttpConnectionPool)
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)

instance Core.FromJSON VirtualGatewayConnectionPool where
  parseJSON :: Value -> Parser VirtualGatewayConnectionPool
parseJSON =
    String
-> (Object -> Parser VirtualGatewayConnectionPool)
-> Value
-> Parser VirtualGatewayConnectionPool
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualGatewayConnectionPool"
      ( \Object
x ->
          Maybe VirtualGatewayHttp2ConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
-> VirtualGatewayConnectionPool
VirtualGatewayConnectionPool'
            (Maybe VirtualGatewayHttp2ConnectionPool
 -> Maybe VirtualGatewayGrpcConnectionPool
 -> Maybe VirtualGatewayHttpConnectionPool
 -> VirtualGatewayConnectionPool)
-> Parser (Maybe VirtualGatewayHttp2ConnectionPool)
-> Parser
     (Maybe VirtualGatewayGrpcConnectionPool
      -> Maybe VirtualGatewayHttpConnectionPool
      -> VirtualGatewayConnectionPool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe VirtualGatewayHttp2ConnectionPool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"http2")
            Parser
  (Maybe VirtualGatewayGrpcConnectionPool
   -> Maybe VirtualGatewayHttpConnectionPool
   -> VirtualGatewayConnectionPool)
-> Parser (Maybe VirtualGatewayGrpcConnectionPool)
-> Parser
     (Maybe VirtualGatewayHttpConnectionPool
      -> VirtualGatewayConnectionPool)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VirtualGatewayGrpcConnectionPool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"grpc")
            Parser
  (Maybe VirtualGatewayHttpConnectionPool
   -> VirtualGatewayConnectionPool)
-> Parser (Maybe VirtualGatewayHttpConnectionPool)
-> Parser VirtualGatewayConnectionPool
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VirtualGatewayHttpConnectionPool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"http")
      )

instance
  Prelude.Hashable
    VirtualGatewayConnectionPool

instance Prelude.NFData VirtualGatewayConnectionPool

instance Core.ToJSON VirtualGatewayConnectionPool where
  toJSON :: VirtualGatewayConnectionPool -> Value
toJSON VirtualGatewayConnectionPool' {Maybe VirtualGatewayGrpcConnectionPool
Maybe VirtualGatewayHttp2ConnectionPool
Maybe VirtualGatewayHttpConnectionPool
http :: Maybe VirtualGatewayHttpConnectionPool
grpc :: Maybe VirtualGatewayGrpcConnectionPool
http2 :: Maybe VirtualGatewayHttp2ConnectionPool
$sel:http:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttpConnectionPool
$sel:grpc:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayGrpcConnectionPool
$sel:http2:VirtualGatewayConnectionPool' :: VirtualGatewayConnectionPool
-> Maybe VirtualGatewayHttp2ConnectionPool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"http2" Text -> VirtualGatewayHttp2ConnectionPool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualGatewayHttp2ConnectionPool -> Pair)
-> Maybe VirtualGatewayHttp2ConnectionPool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualGatewayHttp2ConnectionPool
http2,
            (Text
"grpc" Text -> VirtualGatewayGrpcConnectionPool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualGatewayGrpcConnectionPool -> Pair)
-> Maybe VirtualGatewayGrpcConnectionPool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualGatewayGrpcConnectionPool
grpc,
            (Text
"http" Text -> VirtualGatewayHttpConnectionPool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualGatewayHttpConnectionPool -> Pair)
-> Maybe VirtualGatewayHttpConnectionPool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualGatewayHttpConnectionPool
http
          ]
      )