{-# 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.SecurityHub.Types.NetworkHeader
-- 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.SecurityHub.Types.NetworkHeader where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.NetworkPathComponentDetails

-- | Details about a network path component that occurs before or after the
-- current component.
--
-- /See:/ 'newNetworkHeader' smart constructor.
data NetworkHeader = NetworkHeader'
  { -- | Information about the destination of the component.
    NetworkHeader -> Maybe NetworkPathComponentDetails
destination :: Prelude.Maybe NetworkPathComponentDetails,
    -- | The protocol used for the component.
    NetworkHeader -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | Information about the origin of the component.
    NetworkHeader -> Maybe NetworkPathComponentDetails
source :: Prelude.Maybe NetworkPathComponentDetails
  }
  deriving (NetworkHeader -> NetworkHeader -> Bool
(NetworkHeader -> NetworkHeader -> Bool)
-> (NetworkHeader -> NetworkHeader -> Bool) -> Eq NetworkHeader
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NetworkHeader -> NetworkHeader -> Bool
$c/= :: NetworkHeader -> NetworkHeader -> Bool
== :: NetworkHeader -> NetworkHeader -> Bool
$c== :: NetworkHeader -> NetworkHeader -> Bool
Prelude.Eq, ReadPrec [NetworkHeader]
ReadPrec NetworkHeader
Int -> ReadS NetworkHeader
ReadS [NetworkHeader]
(Int -> ReadS NetworkHeader)
-> ReadS [NetworkHeader]
-> ReadPrec NetworkHeader
-> ReadPrec [NetworkHeader]
-> Read NetworkHeader
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NetworkHeader]
$creadListPrec :: ReadPrec [NetworkHeader]
readPrec :: ReadPrec NetworkHeader
$creadPrec :: ReadPrec NetworkHeader
readList :: ReadS [NetworkHeader]
$creadList :: ReadS [NetworkHeader]
readsPrec :: Int -> ReadS NetworkHeader
$creadsPrec :: Int -> ReadS NetworkHeader
Prelude.Read, Int -> NetworkHeader -> ShowS
[NetworkHeader] -> ShowS
NetworkHeader -> String
(Int -> NetworkHeader -> ShowS)
-> (NetworkHeader -> String)
-> ([NetworkHeader] -> ShowS)
-> Show NetworkHeader
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NetworkHeader] -> ShowS
$cshowList :: [NetworkHeader] -> ShowS
show :: NetworkHeader -> String
$cshow :: NetworkHeader -> String
showsPrec :: Int -> NetworkHeader -> ShowS
$cshowsPrec :: Int -> NetworkHeader -> ShowS
Prelude.Show, (forall x. NetworkHeader -> Rep NetworkHeader x)
-> (forall x. Rep NetworkHeader x -> NetworkHeader)
-> Generic NetworkHeader
forall x. Rep NetworkHeader x -> NetworkHeader
forall x. NetworkHeader -> Rep NetworkHeader x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NetworkHeader x -> NetworkHeader
$cfrom :: forall x. NetworkHeader -> Rep NetworkHeader x
Prelude.Generic)

-- |
-- Create a value of 'NetworkHeader' 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:
--
-- 'destination', 'networkHeader_destination' - Information about the destination of the component.
--
-- 'protocol', 'networkHeader_protocol' - The protocol used for the component.
--
-- 'source', 'networkHeader_source' - Information about the origin of the component.
newNetworkHeader ::
  NetworkHeader
newNetworkHeader :: NetworkHeader
newNetworkHeader =
  NetworkHeader' :: Maybe NetworkPathComponentDetails
-> Maybe Text -> Maybe NetworkPathComponentDetails -> NetworkHeader
NetworkHeader'
    { $sel:destination:NetworkHeader' :: Maybe NetworkPathComponentDetails
destination = Maybe NetworkPathComponentDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:NetworkHeader' :: Maybe Text
protocol = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:source:NetworkHeader' :: Maybe NetworkPathComponentDetails
source = Maybe NetworkPathComponentDetails
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the destination of the component.
networkHeader_destination :: Lens.Lens' NetworkHeader (Prelude.Maybe NetworkPathComponentDetails)
networkHeader_destination :: (Maybe NetworkPathComponentDetails
 -> f (Maybe NetworkPathComponentDetails))
-> NetworkHeader -> f NetworkHeader
networkHeader_destination = (NetworkHeader -> Maybe NetworkPathComponentDetails)
-> (NetworkHeader
    -> Maybe NetworkPathComponentDetails -> NetworkHeader)
-> Lens
     NetworkHeader
     NetworkHeader
     (Maybe NetworkPathComponentDetails)
     (Maybe NetworkPathComponentDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkHeader' {Maybe NetworkPathComponentDetails
destination :: Maybe NetworkPathComponentDetails
$sel:destination:NetworkHeader' :: NetworkHeader -> Maybe NetworkPathComponentDetails
destination} -> Maybe NetworkPathComponentDetails
destination) (\s :: NetworkHeader
s@NetworkHeader' {} Maybe NetworkPathComponentDetails
a -> NetworkHeader
s {$sel:destination:NetworkHeader' :: Maybe NetworkPathComponentDetails
destination = Maybe NetworkPathComponentDetails
a} :: NetworkHeader)

-- | The protocol used for the component.
networkHeader_protocol :: Lens.Lens' NetworkHeader (Prelude.Maybe Prelude.Text)
networkHeader_protocol :: (Maybe Text -> f (Maybe Text)) -> NetworkHeader -> f NetworkHeader
networkHeader_protocol = (NetworkHeader -> Maybe Text)
-> (NetworkHeader -> Maybe Text -> NetworkHeader)
-> Lens NetworkHeader NetworkHeader (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkHeader' {Maybe Text
protocol :: Maybe Text
$sel:protocol:NetworkHeader' :: NetworkHeader -> Maybe Text
protocol} -> Maybe Text
protocol) (\s :: NetworkHeader
s@NetworkHeader' {} Maybe Text
a -> NetworkHeader
s {$sel:protocol:NetworkHeader' :: Maybe Text
protocol = Maybe Text
a} :: NetworkHeader)

-- | Information about the origin of the component.
networkHeader_source :: Lens.Lens' NetworkHeader (Prelude.Maybe NetworkPathComponentDetails)
networkHeader_source :: (Maybe NetworkPathComponentDetails
 -> f (Maybe NetworkPathComponentDetails))
-> NetworkHeader -> f NetworkHeader
networkHeader_source = (NetworkHeader -> Maybe NetworkPathComponentDetails)
-> (NetworkHeader
    -> Maybe NetworkPathComponentDetails -> NetworkHeader)
-> Lens
     NetworkHeader
     NetworkHeader
     (Maybe NetworkPathComponentDetails)
     (Maybe NetworkPathComponentDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NetworkHeader' {Maybe NetworkPathComponentDetails
source :: Maybe NetworkPathComponentDetails
$sel:source:NetworkHeader' :: NetworkHeader -> Maybe NetworkPathComponentDetails
source} -> Maybe NetworkPathComponentDetails
source) (\s :: NetworkHeader
s@NetworkHeader' {} Maybe NetworkPathComponentDetails
a -> NetworkHeader
s {$sel:source:NetworkHeader' :: Maybe NetworkPathComponentDetails
source = Maybe NetworkPathComponentDetails
a} :: NetworkHeader)

instance Core.FromJSON NetworkHeader where
  parseJSON :: Value -> Parser NetworkHeader
parseJSON =
    String
-> (Object -> Parser NetworkHeader)
-> Value
-> Parser NetworkHeader
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"NetworkHeader"
      ( \Object
x ->
          Maybe NetworkPathComponentDetails
-> Maybe Text -> Maybe NetworkPathComponentDetails -> NetworkHeader
NetworkHeader'
            (Maybe NetworkPathComponentDetails
 -> Maybe Text
 -> Maybe NetworkPathComponentDetails
 -> NetworkHeader)
-> Parser (Maybe NetworkPathComponentDetails)
-> Parser
     (Maybe Text -> Maybe NetworkPathComponentDetails -> NetworkHeader)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe NetworkPathComponentDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Destination")
            Parser
  (Maybe Text -> Maybe NetworkPathComponentDetails -> NetworkHeader)
-> Parser (Maybe Text)
-> Parser (Maybe NetworkPathComponentDetails -> NetworkHeader)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Protocol")
            Parser (Maybe NetworkPathComponentDetails -> NetworkHeader)
-> Parser (Maybe NetworkPathComponentDetails)
-> Parser NetworkHeader
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe NetworkPathComponentDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Source")
      )

instance Prelude.Hashable NetworkHeader

instance Prelude.NFData NetworkHeader

instance Core.ToJSON NetworkHeader where
  toJSON :: NetworkHeader -> Value
toJSON NetworkHeader' {Maybe Text
Maybe NetworkPathComponentDetails
source :: Maybe NetworkPathComponentDetails
protocol :: Maybe Text
destination :: Maybe NetworkPathComponentDetails
$sel:source:NetworkHeader' :: NetworkHeader -> Maybe NetworkPathComponentDetails
$sel:protocol:NetworkHeader' :: NetworkHeader -> Maybe Text
$sel:destination:NetworkHeader' :: NetworkHeader -> Maybe NetworkPathComponentDetails
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Destination" Text -> NetworkPathComponentDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NetworkPathComponentDetails -> Pair)
-> Maybe NetworkPathComponentDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NetworkPathComponentDetails
destination,
            (Text
"Protocol" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
protocol,
            (Text
"Source" Text -> NetworkPathComponentDetails -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NetworkPathComponentDetails -> Pair)
-> Maybe NetworkPathComponentDetails -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe NetworkPathComponentDetails
source
          ]
      )