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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Panorama.Types.ConnectionType
import Amazonka.Panorama.Types.StaticIpConnectionInfo
import qualified Amazonka.Prelude as Prelude

-- | A device\'s network configuration.
--
-- /See:/ 'newEthernetPayload' smart constructor.
data EthernetPayload = EthernetPayload'
  { -- | Network configuration for a static IP connection.
    EthernetPayload -> Maybe StaticIpConnectionInfo
staticIpConnectionInfo :: Prelude.Maybe StaticIpConnectionInfo,
    -- | How the device gets an IP address.
    EthernetPayload -> ConnectionType
connectionType :: ConnectionType
  }
  deriving (EthernetPayload -> EthernetPayload -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EthernetPayload -> EthernetPayload -> Bool
$c/= :: EthernetPayload -> EthernetPayload -> Bool
== :: EthernetPayload -> EthernetPayload -> Bool
$c== :: EthernetPayload -> EthernetPayload -> Bool
Prelude.Eq, ReadPrec [EthernetPayload]
ReadPrec EthernetPayload
Int -> ReadS EthernetPayload
ReadS [EthernetPayload]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EthernetPayload]
$creadListPrec :: ReadPrec [EthernetPayload]
readPrec :: ReadPrec EthernetPayload
$creadPrec :: ReadPrec EthernetPayload
readList :: ReadS [EthernetPayload]
$creadList :: ReadS [EthernetPayload]
readsPrec :: Int -> ReadS EthernetPayload
$creadsPrec :: Int -> ReadS EthernetPayload
Prelude.Read, Int -> EthernetPayload -> ShowS
[EthernetPayload] -> ShowS
EthernetPayload -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EthernetPayload] -> ShowS
$cshowList :: [EthernetPayload] -> ShowS
show :: EthernetPayload -> String
$cshow :: EthernetPayload -> String
showsPrec :: Int -> EthernetPayload -> ShowS
$cshowsPrec :: Int -> EthernetPayload -> ShowS
Prelude.Show, forall x. Rep EthernetPayload x -> EthernetPayload
forall x. EthernetPayload -> Rep EthernetPayload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EthernetPayload x -> EthernetPayload
$cfrom :: forall x. EthernetPayload -> Rep EthernetPayload x
Prelude.Generic)

-- |
-- Create a value of 'EthernetPayload' 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:
--
-- 'staticIpConnectionInfo', 'ethernetPayload_staticIpConnectionInfo' - Network configuration for a static IP connection.
--
-- 'connectionType', 'ethernetPayload_connectionType' - How the device gets an IP address.
newEthernetPayload ::
  -- | 'connectionType'
  ConnectionType ->
  EthernetPayload
newEthernetPayload :: ConnectionType -> EthernetPayload
newEthernetPayload ConnectionType
pConnectionType_ =
  EthernetPayload'
    { $sel:staticIpConnectionInfo:EthernetPayload' :: Maybe StaticIpConnectionInfo
staticIpConnectionInfo =
        forall a. Maybe a
Prelude.Nothing,
      $sel:connectionType:EthernetPayload' :: ConnectionType
connectionType = ConnectionType
pConnectionType_
    }

-- | Network configuration for a static IP connection.
ethernetPayload_staticIpConnectionInfo :: Lens.Lens' EthernetPayload (Prelude.Maybe StaticIpConnectionInfo)
ethernetPayload_staticIpConnectionInfo :: Lens' EthernetPayload (Maybe StaticIpConnectionInfo)
ethernetPayload_staticIpConnectionInfo = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EthernetPayload' {Maybe StaticIpConnectionInfo
staticIpConnectionInfo :: Maybe StaticIpConnectionInfo
$sel:staticIpConnectionInfo:EthernetPayload' :: EthernetPayload -> Maybe StaticIpConnectionInfo
staticIpConnectionInfo} -> Maybe StaticIpConnectionInfo
staticIpConnectionInfo) (\s :: EthernetPayload
s@EthernetPayload' {} Maybe StaticIpConnectionInfo
a -> EthernetPayload
s {$sel:staticIpConnectionInfo:EthernetPayload' :: Maybe StaticIpConnectionInfo
staticIpConnectionInfo = Maybe StaticIpConnectionInfo
a} :: EthernetPayload)

-- | How the device gets an IP address.
ethernetPayload_connectionType :: Lens.Lens' EthernetPayload ConnectionType
ethernetPayload_connectionType :: Lens' EthernetPayload ConnectionType
ethernetPayload_connectionType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EthernetPayload' {ConnectionType
connectionType :: ConnectionType
$sel:connectionType:EthernetPayload' :: EthernetPayload -> ConnectionType
connectionType} -> ConnectionType
connectionType) (\s :: EthernetPayload
s@EthernetPayload' {} ConnectionType
a -> EthernetPayload
s {$sel:connectionType:EthernetPayload' :: ConnectionType
connectionType = ConnectionType
a} :: EthernetPayload)

instance Data.FromJSON EthernetPayload where
  parseJSON :: Value -> Parser EthernetPayload
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EthernetPayload"
      ( \Object
x ->
          Maybe StaticIpConnectionInfo -> ConnectionType -> EthernetPayload
EthernetPayload'
            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
"StaticIpConnectionInfo")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ConnectionType")
      )

instance Prelude.Hashable EthernetPayload where
  hashWithSalt :: Int -> EthernetPayload -> Int
hashWithSalt Int
_salt EthernetPayload' {Maybe StaticIpConnectionInfo
ConnectionType
connectionType :: ConnectionType
staticIpConnectionInfo :: Maybe StaticIpConnectionInfo
$sel:connectionType:EthernetPayload' :: EthernetPayload -> ConnectionType
$sel:staticIpConnectionInfo:EthernetPayload' :: EthernetPayload -> Maybe StaticIpConnectionInfo
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StaticIpConnectionInfo
staticIpConnectionInfo
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ConnectionType
connectionType

instance Prelude.NFData EthernetPayload where
  rnf :: EthernetPayload -> ()
rnf EthernetPayload' {Maybe StaticIpConnectionInfo
ConnectionType
connectionType :: ConnectionType
staticIpConnectionInfo :: Maybe StaticIpConnectionInfo
$sel:connectionType:EthernetPayload' :: EthernetPayload -> ConnectionType
$sel:staticIpConnectionInfo:EthernetPayload' :: EthernetPayload -> Maybe StaticIpConnectionInfo
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StaticIpConnectionInfo
staticIpConnectionInfo
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ConnectionType
connectionType

instance Data.ToJSON EthernetPayload where
  toJSON :: EthernetPayload -> Value
toJSON EthernetPayload' {Maybe StaticIpConnectionInfo
ConnectionType
connectionType :: ConnectionType
staticIpConnectionInfo :: Maybe StaticIpConnectionInfo
$sel:connectionType:EthernetPayload' :: EthernetPayload -> ConnectionType
$sel:staticIpConnectionInfo:EthernetPayload' :: EthernetPayload -> Maybe StaticIpConnectionInfo
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StaticIpConnectionInfo" 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 StaticIpConnectionInfo
staticIpConnectionInfo,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ConnectionType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ConnectionType
connectionType)
          ]
      )