{-# 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.Panorama.Types.NetworkPayload
-- 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.Panorama.Types.NetworkPayload where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Panorama.Types.EthernetPayload
import qualified Amazonka.Prelude as Prelude

-- | The network configuration for a device.
--
-- /See:/ 'newNetworkPayload' smart constructor.
data NetworkPayload = NetworkPayload'
  { -- | Settings for Ethernet port 1.
    NetworkPayload -> Maybe EthernetPayload
ethernet1 :: Prelude.Maybe EthernetPayload,
    -- | Settings for Ethernet port 0.
    NetworkPayload -> Maybe EthernetPayload
ethernet0 :: Prelude.Maybe EthernetPayload
  }
  deriving (NetworkPayload -> NetworkPayload -> Bool
(NetworkPayload -> NetworkPayload -> Bool)
-> (NetworkPayload -> NetworkPayload -> Bool) -> Eq NetworkPayload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkPayload -> NetworkPayload -> Bool
$c/= :: NetworkPayload -> NetworkPayload -> Bool
== :: NetworkPayload -> NetworkPayload -> Bool
$c== :: NetworkPayload -> NetworkPayload -> Bool
Prelude.Eq, ReadPrec [NetworkPayload]
ReadPrec NetworkPayload
Int -> ReadS NetworkPayload
ReadS [NetworkPayload]
(Int -> ReadS NetworkPayload)
-> ReadS [NetworkPayload]
-> ReadPrec NetworkPayload
-> ReadPrec [NetworkPayload]
-> Read NetworkPayload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkPayload]
$creadListPrec :: ReadPrec [NetworkPayload]
readPrec :: ReadPrec NetworkPayload
$creadPrec :: ReadPrec NetworkPayload
readList :: ReadS [NetworkPayload]
$creadList :: ReadS [NetworkPayload]
readsPrec :: Int -> ReadS NetworkPayload
$creadsPrec :: Int -> ReadS NetworkPayload
Prelude.Read, Int -> NetworkPayload -> ShowS
[NetworkPayload] -> ShowS
NetworkPayload -> String
(Int -> NetworkPayload -> ShowS)
-> (NetworkPayload -> String)
-> ([NetworkPayload] -> ShowS)
-> Show NetworkPayload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkPayload] -> ShowS
$cshowList :: [NetworkPayload] -> ShowS
show :: NetworkPayload -> String
$cshow :: NetworkPayload -> String
showsPrec :: Int -> NetworkPayload -> ShowS
$cshowsPrec :: Int -> NetworkPayload -> ShowS
Prelude.Show, (forall x. NetworkPayload -> Rep NetworkPayload x)
-> (forall x. Rep NetworkPayload x -> NetworkPayload)
-> Generic NetworkPayload
forall x. Rep NetworkPayload x -> NetworkPayload
forall x. NetworkPayload -> Rep NetworkPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NetworkPayload x -> NetworkPayload
$cfrom :: forall x. NetworkPayload -> Rep NetworkPayload x
Prelude.Generic)

-- |
-- Create a value of 'NetworkPayload' 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:
--
-- 'ethernet1', 'networkPayload_ethernet1' - Settings for Ethernet port 1.
--
-- 'ethernet0', 'networkPayload_ethernet0' - Settings for Ethernet port 0.
newNetworkPayload ::
  NetworkPayload
newNetworkPayload :: NetworkPayload
newNetworkPayload =
  NetworkPayload' :: Maybe EthernetPayload -> Maybe EthernetPayload -> NetworkPayload
NetworkPayload'
    { $sel:ethernet1:NetworkPayload' :: Maybe EthernetPayload
ethernet1 = Maybe EthernetPayload
forall a. Maybe a
Prelude.Nothing,
      $sel:ethernet0:NetworkPayload' :: Maybe EthernetPayload
ethernet0 = Maybe EthernetPayload
forall a. Maybe a
Prelude.Nothing
    }

-- | Settings for Ethernet port 1.
networkPayload_ethernet1 :: Lens.Lens' NetworkPayload (Prelude.Maybe EthernetPayload)
networkPayload_ethernet1 :: (Maybe EthernetPayload -> f (Maybe EthernetPayload))
-> NetworkPayload -> f NetworkPayload
networkPayload_ethernet1 = (NetworkPayload -> Maybe EthernetPayload)
-> (NetworkPayload -> Maybe EthernetPayload -> NetworkPayload)
-> Lens
     NetworkPayload
     NetworkPayload
     (Maybe EthernetPayload)
     (Maybe EthernetPayload)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkPayload' {Maybe EthernetPayload
ethernet1 :: Maybe EthernetPayload
$sel:ethernet1:NetworkPayload' :: NetworkPayload -> Maybe EthernetPayload
ethernet1} -> Maybe EthernetPayload
ethernet1) (\s :: NetworkPayload
s@NetworkPayload' {} Maybe EthernetPayload
a -> NetworkPayload
s {$sel:ethernet1:NetworkPayload' :: Maybe EthernetPayload
ethernet1 = Maybe EthernetPayload
a} :: NetworkPayload)

-- | Settings for Ethernet port 0.
networkPayload_ethernet0 :: Lens.Lens' NetworkPayload (Prelude.Maybe EthernetPayload)
networkPayload_ethernet0 :: (Maybe EthernetPayload -> f (Maybe EthernetPayload))
-> NetworkPayload -> f NetworkPayload
networkPayload_ethernet0 = (NetworkPayload -> Maybe EthernetPayload)
-> (NetworkPayload -> Maybe EthernetPayload -> NetworkPayload)
-> Lens
     NetworkPayload
     NetworkPayload
     (Maybe EthernetPayload)
     (Maybe EthernetPayload)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkPayload' {Maybe EthernetPayload
ethernet0 :: Maybe EthernetPayload
$sel:ethernet0:NetworkPayload' :: NetworkPayload -> Maybe EthernetPayload
ethernet0} -> Maybe EthernetPayload
ethernet0) (\s :: NetworkPayload
s@NetworkPayload' {} Maybe EthernetPayload
a -> NetworkPayload
s {$sel:ethernet0:NetworkPayload' :: Maybe EthernetPayload
ethernet0 = Maybe EthernetPayload
a} :: NetworkPayload)

instance Core.FromJSON NetworkPayload where
  parseJSON :: Value -> Parser NetworkPayload
parseJSON =
    String
-> (Object -> Parser NetworkPayload)
-> Value
-> Parser NetworkPayload
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NetworkPayload"
      ( \Object
x ->
          Maybe EthernetPayload -> Maybe EthernetPayload -> NetworkPayload
NetworkPayload'
            (Maybe EthernetPayload -> Maybe EthernetPayload -> NetworkPayload)
-> Parser (Maybe EthernetPayload)
-> Parser (Maybe EthernetPayload -> NetworkPayload)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EthernetPayload)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Ethernet1")
            Parser (Maybe EthernetPayload -> NetworkPayload)
-> Parser (Maybe EthernetPayload) -> Parser NetworkPayload
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EthernetPayload)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Ethernet0")
      )

instance Prelude.Hashable NetworkPayload

instance Prelude.NFData NetworkPayload

instance Core.ToJSON NetworkPayload where
  toJSON :: NetworkPayload -> Value
toJSON NetworkPayload' {Maybe EthernetPayload
ethernet0 :: Maybe EthernetPayload
ethernet1 :: Maybe EthernetPayload
$sel:ethernet0:NetworkPayload' :: NetworkPayload -> Maybe EthernetPayload
$sel:ethernet1:NetworkPayload' :: NetworkPayload -> Maybe EthernetPayload
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Ethernet1" Text -> EthernetPayload -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EthernetPayload -> Pair) -> Maybe EthernetPayload -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EthernetPayload
ethernet1,
            (Text
"Ethernet0" Text -> EthernetPayload -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EthernetPayload -> Pair) -> Maybe EthernetPayload -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EthernetPayload
ethernet0
          ]
      )