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

import Amazonka.AppMesh.Types.VirtualGatewayBackendDefaults
import Amazonka.AppMesh.Types.VirtualGatewayListener
import Amazonka.AppMesh.Types.VirtualGatewayLogging
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 specification of a service mesh resource.
--
-- /See:/ 'newVirtualGatewaySpec' smart constructor.
data VirtualGatewaySpec = VirtualGatewaySpec'
  { -- | A reference to an object that represents the defaults for backends.
    VirtualGatewaySpec -> Maybe VirtualGatewayBackendDefaults
backendDefaults :: Prelude.Maybe VirtualGatewayBackendDefaults,
    VirtualGatewaySpec -> Maybe VirtualGatewayLogging
logging :: Prelude.Maybe VirtualGatewayLogging,
    -- | The listeners that the mesh endpoint is expected to receive inbound
    -- traffic from. You can specify one listener.
    VirtualGatewaySpec -> [VirtualGatewayListener]
listeners :: [VirtualGatewayListener]
  }
  deriving (VirtualGatewaySpec -> VirtualGatewaySpec -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewaySpec -> VirtualGatewaySpec -> Bool
$c/= :: VirtualGatewaySpec -> VirtualGatewaySpec -> Bool
== :: VirtualGatewaySpec -> VirtualGatewaySpec -> Bool
$c== :: VirtualGatewaySpec -> VirtualGatewaySpec -> Bool
Prelude.Eq, ReadPrec [VirtualGatewaySpec]
ReadPrec VirtualGatewaySpec
Int -> ReadS VirtualGatewaySpec
ReadS [VirtualGatewaySpec]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewaySpec]
$creadListPrec :: ReadPrec [VirtualGatewaySpec]
readPrec :: ReadPrec VirtualGatewaySpec
$creadPrec :: ReadPrec VirtualGatewaySpec
readList :: ReadS [VirtualGatewaySpec]
$creadList :: ReadS [VirtualGatewaySpec]
readsPrec :: Int -> ReadS VirtualGatewaySpec
$creadsPrec :: Int -> ReadS VirtualGatewaySpec
Prelude.Read, Int -> VirtualGatewaySpec -> ShowS
[VirtualGatewaySpec] -> ShowS
VirtualGatewaySpec -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewaySpec] -> ShowS
$cshowList :: [VirtualGatewaySpec] -> ShowS
show :: VirtualGatewaySpec -> String
$cshow :: VirtualGatewaySpec -> String
showsPrec :: Int -> VirtualGatewaySpec -> ShowS
$cshowsPrec :: Int -> VirtualGatewaySpec -> ShowS
Prelude.Show, forall x. Rep VirtualGatewaySpec x -> VirtualGatewaySpec
forall x. VirtualGatewaySpec -> Rep VirtualGatewaySpec x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VirtualGatewaySpec x -> VirtualGatewaySpec
$cfrom :: forall x. VirtualGatewaySpec -> Rep VirtualGatewaySpec x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewaySpec' 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:
--
-- 'backendDefaults', 'virtualGatewaySpec_backendDefaults' - A reference to an object that represents the defaults for backends.
--
-- 'logging', 'virtualGatewaySpec_logging' - Undocumented member.
--
-- 'listeners', 'virtualGatewaySpec_listeners' - The listeners that the mesh endpoint is expected to receive inbound
-- traffic from. You can specify one listener.
newVirtualGatewaySpec ::
  VirtualGatewaySpec
newVirtualGatewaySpec :: VirtualGatewaySpec
newVirtualGatewaySpec =
  VirtualGatewaySpec'
    { $sel:backendDefaults:VirtualGatewaySpec' :: Maybe VirtualGatewayBackendDefaults
backendDefaults =
        forall a. Maybe a
Prelude.Nothing,
      $sel:logging:VirtualGatewaySpec' :: Maybe VirtualGatewayLogging
logging = forall a. Maybe a
Prelude.Nothing,
      $sel:listeners:VirtualGatewaySpec' :: [VirtualGatewayListener]
listeners = forall a. Monoid a => a
Prelude.mempty
    }

-- | A reference to an object that represents the defaults for backends.
virtualGatewaySpec_backendDefaults :: Lens.Lens' VirtualGatewaySpec (Prelude.Maybe VirtualGatewayBackendDefaults)
virtualGatewaySpec_backendDefaults :: Lens' VirtualGatewaySpec (Maybe VirtualGatewayBackendDefaults)
virtualGatewaySpec_backendDefaults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewaySpec' {Maybe VirtualGatewayBackendDefaults
backendDefaults :: Maybe VirtualGatewayBackendDefaults
$sel:backendDefaults:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayBackendDefaults
backendDefaults} -> Maybe VirtualGatewayBackendDefaults
backendDefaults) (\s :: VirtualGatewaySpec
s@VirtualGatewaySpec' {} Maybe VirtualGatewayBackendDefaults
a -> VirtualGatewaySpec
s {$sel:backendDefaults:VirtualGatewaySpec' :: Maybe VirtualGatewayBackendDefaults
backendDefaults = Maybe VirtualGatewayBackendDefaults
a} :: VirtualGatewaySpec)

-- | Undocumented member.
virtualGatewaySpec_logging :: Lens.Lens' VirtualGatewaySpec (Prelude.Maybe VirtualGatewayLogging)
virtualGatewaySpec_logging :: Lens' VirtualGatewaySpec (Maybe VirtualGatewayLogging)
virtualGatewaySpec_logging = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewaySpec' {Maybe VirtualGatewayLogging
logging :: Maybe VirtualGatewayLogging
$sel:logging:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayLogging
logging} -> Maybe VirtualGatewayLogging
logging) (\s :: VirtualGatewaySpec
s@VirtualGatewaySpec' {} Maybe VirtualGatewayLogging
a -> VirtualGatewaySpec
s {$sel:logging:VirtualGatewaySpec' :: Maybe VirtualGatewayLogging
logging = Maybe VirtualGatewayLogging
a} :: VirtualGatewaySpec)

-- | The listeners that the mesh endpoint is expected to receive inbound
-- traffic from. You can specify one listener.
virtualGatewaySpec_listeners :: Lens.Lens' VirtualGatewaySpec [VirtualGatewayListener]
virtualGatewaySpec_listeners :: Lens' VirtualGatewaySpec [VirtualGatewayListener]
virtualGatewaySpec_listeners = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewaySpec' {[VirtualGatewayListener]
listeners :: [VirtualGatewayListener]
$sel:listeners:VirtualGatewaySpec' :: VirtualGatewaySpec -> [VirtualGatewayListener]
listeners} -> [VirtualGatewayListener]
listeners) (\s :: VirtualGatewaySpec
s@VirtualGatewaySpec' {} [VirtualGatewayListener]
a -> VirtualGatewaySpec
s {$sel:listeners:VirtualGatewaySpec' :: [VirtualGatewayListener]
listeners = [VirtualGatewayListener]
a} :: VirtualGatewaySpec) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON VirtualGatewaySpec where
  parseJSON :: Value -> Parser VirtualGatewaySpec
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualGatewaySpec"
      ( \Object
x ->
          Maybe VirtualGatewayBackendDefaults
-> Maybe VirtualGatewayLogging
-> [VirtualGatewayListener]
-> VirtualGatewaySpec
VirtualGatewaySpec'
            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
"backendDefaults")
            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
"logging")
            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
"listeners" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable VirtualGatewaySpec where
  hashWithSalt :: Int -> VirtualGatewaySpec -> Int
hashWithSalt Int
_salt VirtualGatewaySpec' {[VirtualGatewayListener]
Maybe VirtualGatewayLogging
Maybe VirtualGatewayBackendDefaults
listeners :: [VirtualGatewayListener]
logging :: Maybe VirtualGatewayLogging
backendDefaults :: Maybe VirtualGatewayBackendDefaults
$sel:listeners:VirtualGatewaySpec' :: VirtualGatewaySpec -> [VirtualGatewayListener]
$sel:logging:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayLogging
$sel:backendDefaults:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayBackendDefaults
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayBackendDefaults
backendDefaults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VirtualGatewayLogging
logging
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [VirtualGatewayListener]
listeners

instance Prelude.NFData VirtualGatewaySpec where
  rnf :: VirtualGatewaySpec -> ()
rnf VirtualGatewaySpec' {[VirtualGatewayListener]
Maybe VirtualGatewayLogging
Maybe VirtualGatewayBackendDefaults
listeners :: [VirtualGatewayListener]
logging :: Maybe VirtualGatewayLogging
backendDefaults :: Maybe VirtualGatewayBackendDefaults
$sel:listeners:VirtualGatewaySpec' :: VirtualGatewaySpec -> [VirtualGatewayListener]
$sel:logging:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayLogging
$sel:backendDefaults:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayBackendDefaults
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayBackendDefaults
backendDefaults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VirtualGatewayLogging
logging
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [VirtualGatewayListener]
listeners

instance Data.ToJSON VirtualGatewaySpec where
  toJSON :: VirtualGatewaySpec -> Value
toJSON VirtualGatewaySpec' {[VirtualGatewayListener]
Maybe VirtualGatewayLogging
Maybe VirtualGatewayBackendDefaults
listeners :: [VirtualGatewayListener]
logging :: Maybe VirtualGatewayLogging
backendDefaults :: Maybe VirtualGatewayBackendDefaults
$sel:listeners:VirtualGatewaySpec' :: VirtualGatewaySpec -> [VirtualGatewayListener]
$sel:logging:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayLogging
$sel:backendDefaults:VirtualGatewaySpec' :: VirtualGatewaySpec -> Maybe VirtualGatewayBackendDefaults
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"backendDefaults" 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 VirtualGatewayBackendDefaults
backendDefaults,
            (Key
"logging" 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 VirtualGatewayLogging
logging,
            forall a. a -> Maybe a
Prelude.Just (Key
"listeners" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [VirtualGatewayListener]
listeners)
          ]
      )