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

import Amazonka.AppMesh.Types.Backend
import Amazonka.AppMesh.Types.BackendDefaults
import Amazonka.AppMesh.Types.Listener
import Amazonka.AppMesh.Types.Logging
import Amazonka.AppMesh.Types.ServiceDiscovery
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 virtual node.
--
-- /See:/ 'newVirtualNodeSpec' smart constructor.
data VirtualNodeSpec = VirtualNodeSpec'
  { -- | The backends that the virtual node is expected to send outbound traffic
    -- to.
    VirtualNodeSpec -> Maybe [Backend]
backends :: Prelude.Maybe [Backend],
    -- | A reference to an object that represents the defaults for backends.
    VirtualNodeSpec -> Maybe BackendDefaults
backendDefaults :: Prelude.Maybe BackendDefaults,
    -- | The service discovery information for the virtual node. If your virtual
    -- node does not expect ingress traffic, you can omit this parameter. If
    -- you specify a @listener@, then you must specify service discovery
    -- information.
    VirtualNodeSpec -> Maybe ServiceDiscovery
serviceDiscovery :: Prelude.Maybe ServiceDiscovery,
    -- | The listener that the virtual node is expected to receive inbound
    -- traffic from. You can specify one listener.
    VirtualNodeSpec -> Maybe [Listener]
listeners :: Prelude.Maybe [Listener],
    -- | The inbound and outbound access logging information for the virtual
    -- node.
    VirtualNodeSpec -> Maybe Logging
logging :: Prelude.Maybe Logging
  }
  deriving (VirtualNodeSpec -> VirtualNodeSpec -> Bool
(VirtualNodeSpec -> VirtualNodeSpec -> Bool)
-> (VirtualNodeSpec -> VirtualNodeSpec -> Bool)
-> Eq VirtualNodeSpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualNodeSpec -> VirtualNodeSpec -> Bool
$c/= :: VirtualNodeSpec -> VirtualNodeSpec -> Bool
== :: VirtualNodeSpec -> VirtualNodeSpec -> Bool
$c== :: VirtualNodeSpec -> VirtualNodeSpec -> Bool
Prelude.Eq, ReadPrec [VirtualNodeSpec]
ReadPrec VirtualNodeSpec
Int -> ReadS VirtualNodeSpec
ReadS [VirtualNodeSpec]
(Int -> ReadS VirtualNodeSpec)
-> ReadS [VirtualNodeSpec]
-> ReadPrec VirtualNodeSpec
-> ReadPrec [VirtualNodeSpec]
-> Read VirtualNodeSpec
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualNodeSpec]
$creadListPrec :: ReadPrec [VirtualNodeSpec]
readPrec :: ReadPrec VirtualNodeSpec
$creadPrec :: ReadPrec VirtualNodeSpec
readList :: ReadS [VirtualNodeSpec]
$creadList :: ReadS [VirtualNodeSpec]
readsPrec :: Int -> ReadS VirtualNodeSpec
$creadsPrec :: Int -> ReadS VirtualNodeSpec
Prelude.Read, Int -> VirtualNodeSpec -> ShowS
[VirtualNodeSpec] -> ShowS
VirtualNodeSpec -> String
(Int -> VirtualNodeSpec -> ShowS)
-> (VirtualNodeSpec -> String)
-> ([VirtualNodeSpec] -> ShowS)
-> Show VirtualNodeSpec
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualNodeSpec] -> ShowS
$cshowList :: [VirtualNodeSpec] -> ShowS
show :: VirtualNodeSpec -> String
$cshow :: VirtualNodeSpec -> String
showsPrec :: Int -> VirtualNodeSpec -> ShowS
$cshowsPrec :: Int -> VirtualNodeSpec -> ShowS
Prelude.Show, (forall x. VirtualNodeSpec -> Rep VirtualNodeSpec x)
-> (forall x. Rep VirtualNodeSpec x -> VirtualNodeSpec)
-> Generic VirtualNodeSpec
forall x. Rep VirtualNodeSpec x -> VirtualNodeSpec
forall x. VirtualNodeSpec -> Rep VirtualNodeSpec x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VirtualNodeSpec x -> VirtualNodeSpec
$cfrom :: forall x. VirtualNodeSpec -> Rep VirtualNodeSpec x
Prelude.Generic)

-- |
-- Create a value of 'VirtualNodeSpec' 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:
--
-- 'backends', 'virtualNodeSpec_backends' - The backends that the virtual node is expected to send outbound traffic
-- to.
--
-- 'backendDefaults', 'virtualNodeSpec_backendDefaults' - A reference to an object that represents the defaults for backends.
--
-- 'serviceDiscovery', 'virtualNodeSpec_serviceDiscovery' - The service discovery information for the virtual node. If your virtual
-- node does not expect ingress traffic, you can omit this parameter. If
-- you specify a @listener@, then you must specify service discovery
-- information.
--
-- 'listeners', 'virtualNodeSpec_listeners' - The listener that the virtual node is expected to receive inbound
-- traffic from. You can specify one listener.
--
-- 'logging', 'virtualNodeSpec_logging' - The inbound and outbound access logging information for the virtual
-- node.
newVirtualNodeSpec ::
  VirtualNodeSpec
newVirtualNodeSpec :: VirtualNodeSpec
newVirtualNodeSpec =
  VirtualNodeSpec' :: Maybe [Backend]
-> Maybe BackendDefaults
-> Maybe ServiceDiscovery
-> Maybe [Listener]
-> Maybe Logging
-> VirtualNodeSpec
VirtualNodeSpec'
    { $sel:backends:VirtualNodeSpec' :: Maybe [Backend]
backends = Maybe [Backend]
forall a. Maybe a
Prelude.Nothing,
      $sel:backendDefaults:VirtualNodeSpec' :: Maybe BackendDefaults
backendDefaults = Maybe BackendDefaults
forall a. Maybe a
Prelude.Nothing,
      $sel:serviceDiscovery:VirtualNodeSpec' :: Maybe ServiceDiscovery
serviceDiscovery = Maybe ServiceDiscovery
forall a. Maybe a
Prelude.Nothing,
      $sel:listeners:VirtualNodeSpec' :: Maybe [Listener]
listeners = Maybe [Listener]
forall a. Maybe a
Prelude.Nothing,
      $sel:logging:VirtualNodeSpec' :: Maybe Logging
logging = Maybe Logging
forall a. Maybe a
Prelude.Nothing
    }

-- | The backends that the virtual node is expected to send outbound traffic
-- to.
virtualNodeSpec_backends :: Lens.Lens' VirtualNodeSpec (Prelude.Maybe [Backend])
virtualNodeSpec_backends :: (Maybe [Backend] -> f (Maybe [Backend]))
-> VirtualNodeSpec -> f VirtualNodeSpec
virtualNodeSpec_backends = (VirtualNodeSpec -> Maybe [Backend])
-> (VirtualNodeSpec -> Maybe [Backend] -> VirtualNodeSpec)
-> Lens
     VirtualNodeSpec VirtualNodeSpec (Maybe [Backend]) (Maybe [Backend])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeSpec' {Maybe [Backend]
backends :: Maybe [Backend]
$sel:backends:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe [Backend]
backends} -> Maybe [Backend]
backends) (\s :: VirtualNodeSpec
s@VirtualNodeSpec' {} Maybe [Backend]
a -> VirtualNodeSpec
s {$sel:backends:VirtualNodeSpec' :: Maybe [Backend]
backends = Maybe [Backend]
a} :: VirtualNodeSpec) ((Maybe [Backend] -> f (Maybe [Backend]))
 -> VirtualNodeSpec -> f VirtualNodeSpec)
-> ((Maybe [Backend] -> f (Maybe [Backend]))
    -> Maybe [Backend] -> f (Maybe [Backend]))
-> (Maybe [Backend] -> f (Maybe [Backend]))
-> VirtualNodeSpec
-> f VirtualNodeSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Backend] [Backend] [Backend] [Backend]
-> Iso
     (Maybe [Backend])
     (Maybe [Backend])
     (Maybe [Backend])
     (Maybe [Backend])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Backend] [Backend] [Backend] [Backend]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The service discovery information for the virtual node. If your virtual
-- node does not expect ingress traffic, you can omit this parameter. If
-- you specify a @listener@, then you must specify service discovery
-- information.
virtualNodeSpec_serviceDiscovery :: Lens.Lens' VirtualNodeSpec (Prelude.Maybe ServiceDiscovery)
virtualNodeSpec_serviceDiscovery :: (Maybe ServiceDiscovery -> f (Maybe ServiceDiscovery))
-> VirtualNodeSpec -> f VirtualNodeSpec
virtualNodeSpec_serviceDiscovery = (VirtualNodeSpec -> Maybe ServiceDiscovery)
-> (VirtualNodeSpec -> Maybe ServiceDiscovery -> VirtualNodeSpec)
-> Lens
     VirtualNodeSpec
     VirtualNodeSpec
     (Maybe ServiceDiscovery)
     (Maybe ServiceDiscovery)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeSpec' {Maybe ServiceDiscovery
serviceDiscovery :: Maybe ServiceDiscovery
$sel:serviceDiscovery:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe ServiceDiscovery
serviceDiscovery} -> Maybe ServiceDiscovery
serviceDiscovery) (\s :: VirtualNodeSpec
s@VirtualNodeSpec' {} Maybe ServiceDiscovery
a -> VirtualNodeSpec
s {$sel:serviceDiscovery:VirtualNodeSpec' :: Maybe ServiceDiscovery
serviceDiscovery = Maybe ServiceDiscovery
a} :: VirtualNodeSpec)

-- | The listener that the virtual node is expected to receive inbound
-- traffic from. You can specify one listener.
virtualNodeSpec_listeners :: Lens.Lens' VirtualNodeSpec (Prelude.Maybe [Listener])
virtualNodeSpec_listeners :: (Maybe [Listener] -> f (Maybe [Listener]))
-> VirtualNodeSpec -> f VirtualNodeSpec
virtualNodeSpec_listeners = (VirtualNodeSpec -> Maybe [Listener])
-> (VirtualNodeSpec -> Maybe [Listener] -> VirtualNodeSpec)
-> Lens
     VirtualNodeSpec
     VirtualNodeSpec
     (Maybe [Listener])
     (Maybe [Listener])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeSpec' {Maybe [Listener]
listeners :: Maybe [Listener]
$sel:listeners:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe [Listener]
listeners} -> Maybe [Listener]
listeners) (\s :: VirtualNodeSpec
s@VirtualNodeSpec' {} Maybe [Listener]
a -> VirtualNodeSpec
s {$sel:listeners:VirtualNodeSpec' :: Maybe [Listener]
listeners = Maybe [Listener]
a} :: VirtualNodeSpec) ((Maybe [Listener] -> f (Maybe [Listener]))
 -> VirtualNodeSpec -> f VirtualNodeSpec)
-> ((Maybe [Listener] -> f (Maybe [Listener]))
    -> Maybe [Listener] -> f (Maybe [Listener]))
-> (Maybe [Listener] -> f (Maybe [Listener]))
-> VirtualNodeSpec
-> f VirtualNodeSpec
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Listener] [Listener] [Listener] [Listener]
-> Iso
     (Maybe [Listener])
     (Maybe [Listener])
     (Maybe [Listener])
     (Maybe [Listener])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Listener] [Listener] [Listener] [Listener]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The inbound and outbound access logging information for the virtual
-- node.
virtualNodeSpec_logging :: Lens.Lens' VirtualNodeSpec (Prelude.Maybe Logging)
virtualNodeSpec_logging :: (Maybe Logging -> f (Maybe Logging))
-> VirtualNodeSpec -> f VirtualNodeSpec
virtualNodeSpec_logging = (VirtualNodeSpec -> Maybe Logging)
-> (VirtualNodeSpec -> Maybe Logging -> VirtualNodeSpec)
-> Lens
     VirtualNodeSpec VirtualNodeSpec (Maybe Logging) (Maybe Logging)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualNodeSpec' {Maybe Logging
logging :: Maybe Logging
$sel:logging:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe Logging
logging} -> Maybe Logging
logging) (\s :: VirtualNodeSpec
s@VirtualNodeSpec' {} Maybe Logging
a -> VirtualNodeSpec
s {$sel:logging:VirtualNodeSpec' :: Maybe Logging
logging = Maybe Logging
a} :: VirtualNodeSpec)

instance Core.FromJSON VirtualNodeSpec where
  parseJSON :: Value -> Parser VirtualNodeSpec
parseJSON =
    String
-> (Object -> Parser VirtualNodeSpec)
-> Value
-> Parser VirtualNodeSpec
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualNodeSpec"
      ( \Object
x ->
          Maybe [Backend]
-> Maybe BackendDefaults
-> Maybe ServiceDiscovery
-> Maybe [Listener]
-> Maybe Logging
-> VirtualNodeSpec
VirtualNodeSpec'
            (Maybe [Backend]
 -> Maybe BackendDefaults
 -> Maybe ServiceDiscovery
 -> Maybe [Listener]
 -> Maybe Logging
 -> VirtualNodeSpec)
-> Parser (Maybe [Backend])
-> Parser
     (Maybe BackendDefaults
      -> Maybe ServiceDiscovery
      -> Maybe [Listener]
      -> Maybe Logging
      -> VirtualNodeSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Backend]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"backends" Parser (Maybe (Maybe [Backend]))
-> Maybe [Backend] -> Parser (Maybe [Backend])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Backend]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe BackendDefaults
   -> Maybe ServiceDiscovery
   -> Maybe [Listener]
   -> Maybe Logging
   -> VirtualNodeSpec)
-> Parser (Maybe BackendDefaults)
-> Parser
     (Maybe ServiceDiscovery
      -> Maybe [Listener] -> Maybe Logging -> VirtualNodeSpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BackendDefaults)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"backendDefaults")
            Parser
  (Maybe ServiceDiscovery
   -> Maybe [Listener] -> Maybe Logging -> VirtualNodeSpec)
-> Parser (Maybe ServiceDiscovery)
-> Parser (Maybe [Listener] -> Maybe Logging -> VirtualNodeSpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ServiceDiscovery)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"serviceDiscovery")
            Parser (Maybe [Listener] -> Maybe Logging -> VirtualNodeSpec)
-> Parser (Maybe [Listener])
-> Parser (Maybe Logging -> VirtualNodeSpec)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Listener]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"listeners" Parser (Maybe (Maybe [Listener]))
-> Maybe [Listener] -> Parser (Maybe [Listener])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Listener]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Logging -> VirtualNodeSpec)
-> Parser (Maybe Logging) -> Parser VirtualNodeSpec
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Logging)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"logging")
      )

instance Prelude.Hashable VirtualNodeSpec

instance Prelude.NFData VirtualNodeSpec

instance Core.ToJSON VirtualNodeSpec where
  toJSON :: VirtualNodeSpec -> Value
toJSON VirtualNodeSpec' {Maybe [Listener]
Maybe [Backend]
Maybe Logging
Maybe ServiceDiscovery
Maybe BackendDefaults
logging :: Maybe Logging
listeners :: Maybe [Listener]
serviceDiscovery :: Maybe ServiceDiscovery
backendDefaults :: Maybe BackendDefaults
backends :: Maybe [Backend]
$sel:logging:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe Logging
$sel:listeners:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe [Listener]
$sel:serviceDiscovery:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe ServiceDiscovery
$sel:backendDefaults:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe BackendDefaults
$sel:backends:VirtualNodeSpec' :: VirtualNodeSpec -> Maybe [Backend]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"backends" Text -> [Backend] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Backend] -> Pair) -> Maybe [Backend] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Backend]
backends,
            (Text
"backendDefaults" Text -> BackendDefaults -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (BackendDefaults -> Pair) -> Maybe BackendDefaults -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe BackendDefaults
backendDefaults,
            (Text
"serviceDiscovery" Text -> ServiceDiscovery -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ServiceDiscovery -> Pair) -> Maybe ServiceDiscovery -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ServiceDiscovery
serviceDiscovery,
            (Text
"listeners" Text -> [Listener] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Listener] -> Pair) -> Maybe [Listener] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Listener]
listeners,
            (Text
"logging" Text -> Logging -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Logging -> Pair) -> Maybe Logging -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Logging
logging
          ]
      )