{-# 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-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.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.Lens as Lens
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
(VirtualGatewaySpec -> VirtualGatewaySpec -> Bool)
-> (VirtualGatewaySpec -> VirtualGatewaySpec -> Bool)
-> Eq VirtualGatewaySpec
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]
(Int -> ReadS VirtualGatewaySpec)
-> ReadS [VirtualGatewaySpec]
-> ReadPrec VirtualGatewaySpec
-> ReadPrec [VirtualGatewaySpec]
-> Read 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
(Int -> VirtualGatewaySpec -> ShowS)
-> (VirtualGatewaySpec -> String)
-> ([VirtualGatewaySpec] -> ShowS)
-> Show VirtualGatewaySpec
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. VirtualGatewaySpec -> Rep VirtualGatewaySpec x)
-> (forall x. Rep VirtualGatewaySpec x -> VirtualGatewaySpec)
-> Generic VirtualGatewaySpec
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' :: Maybe VirtualGatewayBackendDefaults
-> Maybe VirtualGatewayLogging
-> [VirtualGatewayListener]
-> VirtualGatewaySpec
VirtualGatewaySpec'
    { $sel:backendDefaults:VirtualGatewaySpec' :: Maybe VirtualGatewayBackendDefaults
backendDefaults =
        Maybe VirtualGatewayBackendDefaults
forall a. Maybe a
Prelude.Nothing,
      $sel:logging:VirtualGatewaySpec' :: Maybe VirtualGatewayLogging
logging = Maybe VirtualGatewayLogging
forall a. Maybe a
Prelude.Nothing,
      $sel:listeners:VirtualGatewaySpec' :: [VirtualGatewayListener]
listeners = [VirtualGatewayListener]
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 :: (Maybe VirtualGatewayBackendDefaults
 -> f (Maybe VirtualGatewayBackendDefaults))
-> VirtualGatewaySpec -> f VirtualGatewaySpec
virtualGatewaySpec_backendDefaults = (VirtualGatewaySpec -> Maybe VirtualGatewayBackendDefaults)
-> (VirtualGatewaySpec
    -> Maybe VirtualGatewayBackendDefaults -> VirtualGatewaySpec)
-> Lens
     VirtualGatewaySpec
     VirtualGatewaySpec
     (Maybe VirtualGatewayBackendDefaults)
     (Maybe VirtualGatewayBackendDefaults)
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 :: (Maybe VirtualGatewayLogging -> f (Maybe VirtualGatewayLogging))
-> VirtualGatewaySpec -> f VirtualGatewaySpec
virtualGatewaySpec_logging = (VirtualGatewaySpec -> Maybe VirtualGatewayLogging)
-> (VirtualGatewaySpec
    -> Maybe VirtualGatewayLogging -> VirtualGatewaySpec)
-> Lens
     VirtualGatewaySpec
     VirtualGatewaySpec
     (Maybe VirtualGatewayLogging)
     (Maybe VirtualGatewayLogging)
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 :: ([VirtualGatewayListener] -> f [VirtualGatewayListener])
-> VirtualGatewaySpec -> f VirtualGatewaySpec
virtualGatewaySpec_listeners = (VirtualGatewaySpec -> [VirtualGatewayListener])
-> (VirtualGatewaySpec
    -> [VirtualGatewayListener] -> VirtualGatewaySpec)
-> Lens
     VirtualGatewaySpec
     VirtualGatewaySpec
     [VirtualGatewayListener]
     [VirtualGatewayListener]
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) (([VirtualGatewayListener] -> f [VirtualGatewayListener])
 -> VirtualGatewaySpec -> f VirtualGatewaySpec)
-> (([VirtualGatewayListener] -> f [VirtualGatewayListener])
    -> [VirtualGatewayListener] -> f [VirtualGatewayListener])
-> ([VirtualGatewayListener] -> f [VirtualGatewayListener])
-> VirtualGatewaySpec
-> f VirtualGatewaySpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([VirtualGatewayListener] -> f [VirtualGatewayListener])
-> [VirtualGatewayListener] -> f [VirtualGatewayListener]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON VirtualGatewaySpec where
  parseJSON :: Value -> Parser VirtualGatewaySpec
parseJSON =
    String
-> (Object -> Parser VirtualGatewaySpec)
-> Value
-> Parser VirtualGatewaySpec
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualGatewaySpec"
      ( \Object
x ->
          Maybe VirtualGatewayBackendDefaults
-> Maybe VirtualGatewayLogging
-> [VirtualGatewayListener]
-> VirtualGatewaySpec
VirtualGatewaySpec'
            (Maybe VirtualGatewayBackendDefaults
 -> Maybe VirtualGatewayLogging
 -> [VirtualGatewayListener]
 -> VirtualGatewaySpec)
-> Parser (Maybe VirtualGatewayBackendDefaults)
-> Parser
     (Maybe VirtualGatewayLogging
      -> [VirtualGatewayListener] -> VirtualGatewaySpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe VirtualGatewayBackendDefaults)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"backendDefaults")
            Parser
  (Maybe VirtualGatewayLogging
   -> [VirtualGatewayListener] -> VirtualGatewaySpec)
-> Parser (Maybe VirtualGatewayLogging)
-> Parser ([VirtualGatewayListener] -> VirtualGatewaySpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VirtualGatewayLogging)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"logging")
            Parser ([VirtualGatewayListener] -> VirtualGatewaySpec)
-> Parser [VirtualGatewayListener] -> Parser VirtualGatewaySpec
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [VirtualGatewayListener])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"listeners" Parser (Maybe [VirtualGatewayListener])
-> [VirtualGatewayListener] -> Parser [VirtualGatewayListener]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [VirtualGatewayListener]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable VirtualGatewaySpec

instance Prelude.NFData VirtualGatewaySpec

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"backendDefaults" Text -> VirtualGatewayBackendDefaults -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (VirtualGatewayBackendDefaults -> Pair)
-> Maybe VirtualGatewayBackendDefaults -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualGatewayBackendDefaults
backendDefaults,
            (Text
"logging" Text -> VirtualGatewayLogging -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VirtualGatewayLogging -> Pair)
-> Maybe VirtualGatewayLogging -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VirtualGatewayLogging
logging,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"listeners" Text -> [VirtualGatewayListener] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [VirtualGatewayListener]
listeners)
          ]
      )