{-# 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.NetworkFirewall.Types.MatchAttributes
-- 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.NetworkFirewall.Types.MatchAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkFirewall.Types.Address
import Amazonka.NetworkFirewall.Types.PortRange
import Amazonka.NetworkFirewall.Types.TCPFlagField
import qualified Amazonka.Prelude as Prelude

-- | Criteria for Network Firewall to use to inspect an individual packet in
-- stateless rule inspection. Each match attributes set can include one or
-- more items such as IP address, CIDR range, port number, protocol, and
-- TCP flags.
--
-- /See:/ 'newMatchAttributes' smart constructor.
data MatchAttributes = MatchAttributes'
  { -- | The protocols to inspect for, specified using each protocol\'s assigned
    -- internet protocol number (IANA). If not specified, this matches with any
    -- protocol.
    MatchAttributes -> Maybe [Natural]
protocols :: Prelude.Maybe [Prelude.Natural],
    -- | The TCP flags and masks to inspect for. If not specified, this matches
    -- with any settings. This setting is only used for protocol 6 (TCP).
    MatchAttributes -> Maybe [TCPFlagField]
tCPFlags :: Prelude.Maybe [TCPFlagField],
    -- | The destination ports to inspect for. If not specified, this matches
    -- with any destination port. This setting is only used for protocols 6
    -- (TCP) and 17 (UDP).
    --
    -- You can specify individual ports, for example @1994@ and you can specify
    -- port ranges, for example @1990:1994@.
    MatchAttributes -> Maybe [PortRange]
destinationPorts :: Prelude.Maybe [PortRange],
    -- | The source IP addresses and address ranges to inspect for, in CIDR
    -- notation. If not specified, this matches with any source address.
    MatchAttributes -> Maybe [Address]
sources :: Prelude.Maybe [Address],
    -- | The source ports to inspect for. If not specified, this matches with any
    -- source port. This setting is only used for protocols 6 (TCP) and 17
    -- (UDP).
    --
    -- You can specify individual ports, for example @1994@ and you can specify
    -- port ranges, for example @1990:1994@.
    MatchAttributes -> Maybe [PortRange]
sourcePorts :: Prelude.Maybe [PortRange],
    -- | The destination IP addresses and address ranges to inspect for, in CIDR
    -- notation. If not specified, this matches with any destination address.
    MatchAttributes -> Maybe [Address]
destinations :: Prelude.Maybe [Address]
  }
  deriving (MatchAttributes -> MatchAttributes -> Bool
(MatchAttributes -> MatchAttributes -> Bool)
-> (MatchAttributes -> MatchAttributes -> Bool)
-> Eq MatchAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MatchAttributes -> MatchAttributes -> Bool
$c/= :: MatchAttributes -> MatchAttributes -> Bool
== :: MatchAttributes -> MatchAttributes -> Bool
$c== :: MatchAttributes -> MatchAttributes -> Bool
Prelude.Eq, ReadPrec [MatchAttributes]
ReadPrec MatchAttributes
Int -> ReadS MatchAttributes
ReadS [MatchAttributes]
(Int -> ReadS MatchAttributes)
-> ReadS [MatchAttributes]
-> ReadPrec MatchAttributes
-> ReadPrec [MatchAttributes]
-> Read MatchAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MatchAttributes]
$creadListPrec :: ReadPrec [MatchAttributes]
readPrec :: ReadPrec MatchAttributes
$creadPrec :: ReadPrec MatchAttributes
readList :: ReadS [MatchAttributes]
$creadList :: ReadS [MatchAttributes]
readsPrec :: Int -> ReadS MatchAttributes
$creadsPrec :: Int -> ReadS MatchAttributes
Prelude.Read, Int -> MatchAttributes -> ShowS
[MatchAttributes] -> ShowS
MatchAttributes -> String
(Int -> MatchAttributes -> ShowS)
-> (MatchAttributes -> String)
-> ([MatchAttributes] -> ShowS)
-> Show MatchAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MatchAttributes] -> ShowS
$cshowList :: [MatchAttributes] -> ShowS
show :: MatchAttributes -> String
$cshow :: MatchAttributes -> String
showsPrec :: Int -> MatchAttributes -> ShowS
$cshowsPrec :: Int -> MatchAttributes -> ShowS
Prelude.Show, (forall x. MatchAttributes -> Rep MatchAttributes x)
-> (forall x. Rep MatchAttributes x -> MatchAttributes)
-> Generic MatchAttributes
forall x. Rep MatchAttributes x -> MatchAttributes
forall x. MatchAttributes -> Rep MatchAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MatchAttributes x -> MatchAttributes
$cfrom :: forall x. MatchAttributes -> Rep MatchAttributes x
Prelude.Generic)

-- |
-- Create a value of 'MatchAttributes' 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:
--
-- 'protocols', 'matchAttributes_protocols' - The protocols to inspect for, specified using each protocol\'s assigned
-- internet protocol number (IANA). If not specified, this matches with any
-- protocol.
--
-- 'tCPFlags', 'matchAttributes_tCPFlags' - The TCP flags and masks to inspect for. If not specified, this matches
-- with any settings. This setting is only used for protocol 6 (TCP).
--
-- 'destinationPorts', 'matchAttributes_destinationPorts' - The destination ports to inspect for. If not specified, this matches
-- with any destination port. This setting is only used for protocols 6
-- (TCP) and 17 (UDP).
--
-- You can specify individual ports, for example @1994@ and you can specify
-- port ranges, for example @1990:1994@.
--
-- 'sources', 'matchAttributes_sources' - The source IP addresses and address ranges to inspect for, in CIDR
-- notation. If not specified, this matches with any source address.
--
-- 'sourcePorts', 'matchAttributes_sourcePorts' - The source ports to inspect for. If not specified, this matches with any
-- source port. This setting is only used for protocols 6 (TCP) and 17
-- (UDP).
--
-- You can specify individual ports, for example @1994@ and you can specify
-- port ranges, for example @1990:1994@.
--
-- 'destinations', 'matchAttributes_destinations' - The destination IP addresses and address ranges to inspect for, in CIDR
-- notation. If not specified, this matches with any destination address.
newMatchAttributes ::
  MatchAttributes
newMatchAttributes :: MatchAttributes
newMatchAttributes =
  MatchAttributes' :: Maybe [Natural]
-> Maybe [TCPFlagField]
-> Maybe [PortRange]
-> Maybe [Address]
-> Maybe [PortRange]
-> Maybe [Address]
-> MatchAttributes
MatchAttributes'
    { $sel:protocols:MatchAttributes' :: Maybe [Natural]
protocols = Maybe [Natural]
forall a. Maybe a
Prelude.Nothing,
      $sel:tCPFlags:MatchAttributes' :: Maybe [TCPFlagField]
tCPFlags = Maybe [TCPFlagField]
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationPorts:MatchAttributes' :: Maybe [PortRange]
destinationPorts = Maybe [PortRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:sources:MatchAttributes' :: Maybe [Address]
sources = Maybe [Address]
forall a. Maybe a
Prelude.Nothing,
      $sel:sourcePorts:MatchAttributes' :: Maybe [PortRange]
sourcePorts = Maybe [PortRange]
forall a. Maybe a
Prelude.Nothing,
      $sel:destinations:MatchAttributes' :: Maybe [Address]
destinations = Maybe [Address]
forall a. Maybe a
Prelude.Nothing
    }

-- | The protocols to inspect for, specified using each protocol\'s assigned
-- internet protocol number (IANA). If not specified, this matches with any
-- protocol.
matchAttributes_protocols :: Lens.Lens' MatchAttributes (Prelude.Maybe [Prelude.Natural])
matchAttributes_protocols :: (Maybe [Natural] -> f (Maybe [Natural]))
-> MatchAttributes -> f MatchAttributes
matchAttributes_protocols = (MatchAttributes -> Maybe [Natural])
-> (MatchAttributes -> Maybe [Natural] -> MatchAttributes)
-> Lens
     MatchAttributes MatchAttributes (Maybe [Natural]) (Maybe [Natural])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchAttributes' {Maybe [Natural]
protocols :: Maybe [Natural]
$sel:protocols:MatchAttributes' :: MatchAttributes -> Maybe [Natural]
protocols} -> Maybe [Natural]
protocols) (\s :: MatchAttributes
s@MatchAttributes' {} Maybe [Natural]
a -> MatchAttributes
s {$sel:protocols:MatchAttributes' :: Maybe [Natural]
protocols = Maybe [Natural]
a} :: MatchAttributes) ((Maybe [Natural] -> f (Maybe [Natural]))
 -> MatchAttributes -> f MatchAttributes)
-> ((Maybe [Natural] -> f (Maybe [Natural]))
    -> Maybe [Natural] -> f (Maybe [Natural]))
-> (Maybe [Natural] -> f (Maybe [Natural]))
-> MatchAttributes
-> f MatchAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Natural] [Natural] [Natural] [Natural]
-> Iso
     (Maybe [Natural])
     (Maybe [Natural])
     (Maybe [Natural])
     (Maybe [Natural])
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 [Natural] [Natural] [Natural] [Natural]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The TCP flags and masks to inspect for. If not specified, this matches
-- with any settings. This setting is only used for protocol 6 (TCP).
matchAttributes_tCPFlags :: Lens.Lens' MatchAttributes (Prelude.Maybe [TCPFlagField])
matchAttributes_tCPFlags :: (Maybe [TCPFlagField] -> f (Maybe [TCPFlagField]))
-> MatchAttributes -> f MatchAttributes
matchAttributes_tCPFlags = (MatchAttributes -> Maybe [TCPFlagField])
-> (MatchAttributes -> Maybe [TCPFlagField] -> MatchAttributes)
-> Lens
     MatchAttributes
     MatchAttributes
     (Maybe [TCPFlagField])
     (Maybe [TCPFlagField])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchAttributes' {Maybe [TCPFlagField]
tCPFlags :: Maybe [TCPFlagField]
$sel:tCPFlags:MatchAttributes' :: MatchAttributes -> Maybe [TCPFlagField]
tCPFlags} -> Maybe [TCPFlagField]
tCPFlags) (\s :: MatchAttributes
s@MatchAttributes' {} Maybe [TCPFlagField]
a -> MatchAttributes
s {$sel:tCPFlags:MatchAttributes' :: Maybe [TCPFlagField]
tCPFlags = Maybe [TCPFlagField]
a} :: MatchAttributes) ((Maybe [TCPFlagField] -> f (Maybe [TCPFlagField]))
 -> MatchAttributes -> f MatchAttributes)
-> ((Maybe [TCPFlagField] -> f (Maybe [TCPFlagField]))
    -> Maybe [TCPFlagField] -> f (Maybe [TCPFlagField]))
-> (Maybe [TCPFlagField] -> f (Maybe [TCPFlagField]))
-> MatchAttributes
-> f MatchAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [TCPFlagField] [TCPFlagField] [TCPFlagField] [TCPFlagField]
-> Iso
     (Maybe [TCPFlagField])
     (Maybe [TCPFlagField])
     (Maybe [TCPFlagField])
     (Maybe [TCPFlagField])
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 [TCPFlagField] [TCPFlagField] [TCPFlagField] [TCPFlagField]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The destination ports to inspect for. If not specified, this matches
-- with any destination port. This setting is only used for protocols 6
-- (TCP) and 17 (UDP).
--
-- You can specify individual ports, for example @1994@ and you can specify
-- port ranges, for example @1990:1994@.
matchAttributes_destinationPorts :: Lens.Lens' MatchAttributes (Prelude.Maybe [PortRange])
matchAttributes_destinationPorts :: (Maybe [PortRange] -> f (Maybe [PortRange]))
-> MatchAttributes -> f MatchAttributes
matchAttributes_destinationPorts = (MatchAttributes -> Maybe [PortRange])
-> (MatchAttributes -> Maybe [PortRange] -> MatchAttributes)
-> Lens
     MatchAttributes
     MatchAttributes
     (Maybe [PortRange])
     (Maybe [PortRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchAttributes' {Maybe [PortRange]
destinationPorts :: Maybe [PortRange]
$sel:destinationPorts:MatchAttributes' :: MatchAttributes -> Maybe [PortRange]
destinationPorts} -> Maybe [PortRange]
destinationPorts) (\s :: MatchAttributes
s@MatchAttributes' {} Maybe [PortRange]
a -> MatchAttributes
s {$sel:destinationPorts:MatchAttributes' :: Maybe [PortRange]
destinationPorts = Maybe [PortRange]
a} :: MatchAttributes) ((Maybe [PortRange] -> f (Maybe [PortRange]))
 -> MatchAttributes -> f MatchAttributes)
-> ((Maybe [PortRange] -> f (Maybe [PortRange]))
    -> Maybe [PortRange] -> f (Maybe [PortRange]))
-> (Maybe [PortRange] -> f (Maybe [PortRange]))
-> MatchAttributes
-> f MatchAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [PortRange] [PortRange] [PortRange] [PortRange]
-> Iso
     (Maybe [PortRange])
     (Maybe [PortRange])
     (Maybe [PortRange])
     (Maybe [PortRange])
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 [PortRange] [PortRange] [PortRange] [PortRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The source IP addresses and address ranges to inspect for, in CIDR
-- notation. If not specified, this matches with any source address.
matchAttributes_sources :: Lens.Lens' MatchAttributes (Prelude.Maybe [Address])
matchAttributes_sources :: (Maybe [Address] -> f (Maybe [Address]))
-> MatchAttributes -> f MatchAttributes
matchAttributes_sources = (MatchAttributes -> Maybe [Address])
-> (MatchAttributes -> Maybe [Address] -> MatchAttributes)
-> Lens
     MatchAttributes MatchAttributes (Maybe [Address]) (Maybe [Address])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchAttributes' {Maybe [Address]
sources :: Maybe [Address]
$sel:sources:MatchAttributes' :: MatchAttributes -> Maybe [Address]
sources} -> Maybe [Address]
sources) (\s :: MatchAttributes
s@MatchAttributes' {} Maybe [Address]
a -> MatchAttributes
s {$sel:sources:MatchAttributes' :: Maybe [Address]
sources = Maybe [Address]
a} :: MatchAttributes) ((Maybe [Address] -> f (Maybe [Address]))
 -> MatchAttributes -> f MatchAttributes)
-> ((Maybe [Address] -> f (Maybe [Address]))
    -> Maybe [Address] -> f (Maybe [Address]))
-> (Maybe [Address] -> f (Maybe [Address]))
-> MatchAttributes
-> f MatchAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Address] [Address] [Address] [Address]
-> Iso
     (Maybe [Address])
     (Maybe [Address])
     (Maybe [Address])
     (Maybe [Address])
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 [Address] [Address] [Address] [Address]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The source ports to inspect for. If not specified, this matches with any
-- source port. This setting is only used for protocols 6 (TCP) and 17
-- (UDP).
--
-- You can specify individual ports, for example @1994@ and you can specify
-- port ranges, for example @1990:1994@.
matchAttributes_sourcePorts :: Lens.Lens' MatchAttributes (Prelude.Maybe [PortRange])
matchAttributes_sourcePorts :: (Maybe [PortRange] -> f (Maybe [PortRange]))
-> MatchAttributes -> f MatchAttributes
matchAttributes_sourcePorts = (MatchAttributes -> Maybe [PortRange])
-> (MatchAttributes -> Maybe [PortRange] -> MatchAttributes)
-> Lens
     MatchAttributes
     MatchAttributes
     (Maybe [PortRange])
     (Maybe [PortRange])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchAttributes' {Maybe [PortRange]
sourcePorts :: Maybe [PortRange]
$sel:sourcePorts:MatchAttributes' :: MatchAttributes -> Maybe [PortRange]
sourcePorts} -> Maybe [PortRange]
sourcePorts) (\s :: MatchAttributes
s@MatchAttributes' {} Maybe [PortRange]
a -> MatchAttributes
s {$sel:sourcePorts:MatchAttributes' :: Maybe [PortRange]
sourcePorts = Maybe [PortRange]
a} :: MatchAttributes) ((Maybe [PortRange] -> f (Maybe [PortRange]))
 -> MatchAttributes -> f MatchAttributes)
-> ((Maybe [PortRange] -> f (Maybe [PortRange]))
    -> Maybe [PortRange] -> f (Maybe [PortRange]))
-> (Maybe [PortRange] -> f (Maybe [PortRange]))
-> MatchAttributes
-> f MatchAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [PortRange] [PortRange] [PortRange] [PortRange]
-> Iso
     (Maybe [PortRange])
     (Maybe [PortRange])
     (Maybe [PortRange])
     (Maybe [PortRange])
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 [PortRange] [PortRange] [PortRange] [PortRange]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The destination IP addresses and address ranges to inspect for, in CIDR
-- notation. If not specified, this matches with any destination address.
matchAttributes_destinations :: Lens.Lens' MatchAttributes (Prelude.Maybe [Address])
matchAttributes_destinations :: (Maybe [Address] -> f (Maybe [Address]))
-> MatchAttributes -> f MatchAttributes
matchAttributes_destinations = (MatchAttributes -> Maybe [Address])
-> (MatchAttributes -> Maybe [Address] -> MatchAttributes)
-> Lens
     MatchAttributes MatchAttributes (Maybe [Address]) (Maybe [Address])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchAttributes' {Maybe [Address]
destinations :: Maybe [Address]
$sel:destinations:MatchAttributes' :: MatchAttributes -> Maybe [Address]
destinations} -> Maybe [Address]
destinations) (\s :: MatchAttributes
s@MatchAttributes' {} Maybe [Address]
a -> MatchAttributes
s {$sel:destinations:MatchAttributes' :: Maybe [Address]
destinations = Maybe [Address]
a} :: MatchAttributes) ((Maybe [Address] -> f (Maybe [Address]))
 -> MatchAttributes -> f MatchAttributes)
-> ((Maybe [Address] -> f (Maybe [Address]))
    -> Maybe [Address] -> f (Maybe [Address]))
-> (Maybe [Address] -> f (Maybe [Address]))
-> MatchAttributes
-> f MatchAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Address] [Address] [Address] [Address]
-> Iso
     (Maybe [Address])
     (Maybe [Address])
     (Maybe [Address])
     (Maybe [Address])
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 [Address] [Address] [Address] [Address]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON MatchAttributes where
  parseJSON :: Value -> Parser MatchAttributes
parseJSON =
    String
-> (Object -> Parser MatchAttributes)
-> Value
-> Parser MatchAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MatchAttributes"
      ( \Object
x ->
          Maybe [Natural]
-> Maybe [TCPFlagField]
-> Maybe [PortRange]
-> Maybe [Address]
-> Maybe [PortRange]
-> Maybe [Address]
-> MatchAttributes
MatchAttributes'
            (Maybe [Natural]
 -> Maybe [TCPFlagField]
 -> Maybe [PortRange]
 -> Maybe [Address]
 -> Maybe [PortRange]
 -> Maybe [Address]
 -> MatchAttributes)
-> Parser (Maybe [Natural])
-> Parser
     (Maybe [TCPFlagField]
      -> Maybe [PortRange]
      -> Maybe [Address]
      -> Maybe [PortRange]
      -> Maybe [Address]
      -> MatchAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Natural]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Protocols" Parser (Maybe (Maybe [Natural]))
-> Maybe [Natural] -> Parser (Maybe [Natural])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Natural]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [TCPFlagField]
   -> Maybe [PortRange]
   -> Maybe [Address]
   -> Maybe [PortRange]
   -> Maybe [Address]
   -> MatchAttributes)
-> Parser (Maybe [TCPFlagField])
-> Parser
     (Maybe [PortRange]
      -> Maybe [Address]
      -> Maybe [PortRange]
      -> Maybe [Address]
      -> MatchAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [TCPFlagField]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TCPFlags" Parser (Maybe (Maybe [TCPFlagField]))
-> Maybe [TCPFlagField] -> Parser (Maybe [TCPFlagField])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [TCPFlagField]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [PortRange]
   -> Maybe [Address]
   -> Maybe [PortRange]
   -> Maybe [Address]
   -> MatchAttributes)
-> Parser (Maybe [PortRange])
-> Parser
     (Maybe [Address]
      -> Maybe [PortRange] -> Maybe [Address] -> MatchAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [PortRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DestinationPorts"
                            Parser (Maybe (Maybe [PortRange]))
-> Maybe [PortRange] -> Parser (Maybe [PortRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PortRange]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [Address]
   -> Maybe [PortRange] -> Maybe [Address] -> MatchAttributes)
-> Parser (Maybe [Address])
-> Parser (Maybe [PortRange] -> Maybe [Address] -> MatchAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Address]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Sources" Parser (Maybe (Maybe [Address]))
-> Maybe [Address] -> Parser (Maybe [Address])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Address]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [PortRange] -> Maybe [Address] -> MatchAttributes)
-> Parser (Maybe [PortRange])
-> Parser (Maybe [Address] -> MatchAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [PortRange]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SourcePorts" Parser (Maybe (Maybe [PortRange]))
-> Maybe [PortRange] -> Parser (Maybe [PortRange])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PortRange]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Address] -> MatchAttributes)
-> Parser (Maybe [Address]) -> Parser MatchAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Address]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Destinations" Parser (Maybe (Maybe [Address]))
-> Maybe [Address] -> Parser (Maybe [Address])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Address]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable MatchAttributes

instance Prelude.NFData MatchAttributes

instance Core.ToJSON MatchAttributes where
  toJSON :: MatchAttributes -> Value
toJSON MatchAttributes' {Maybe [Natural]
Maybe [Address]
Maybe [PortRange]
Maybe [TCPFlagField]
destinations :: Maybe [Address]
sourcePorts :: Maybe [PortRange]
sources :: Maybe [Address]
destinationPorts :: Maybe [PortRange]
tCPFlags :: Maybe [TCPFlagField]
protocols :: Maybe [Natural]
$sel:destinations:MatchAttributes' :: MatchAttributes -> Maybe [Address]
$sel:sourcePorts:MatchAttributes' :: MatchAttributes -> Maybe [PortRange]
$sel:sources:MatchAttributes' :: MatchAttributes -> Maybe [Address]
$sel:destinationPorts:MatchAttributes' :: MatchAttributes -> Maybe [PortRange]
$sel:tCPFlags:MatchAttributes' :: MatchAttributes -> Maybe [TCPFlagField]
$sel:protocols:MatchAttributes' :: MatchAttributes -> Maybe [Natural]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Protocols" Text -> [Natural] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Natural] -> Pair) -> Maybe [Natural] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Natural]
protocols,
            (Text
"TCPFlags" Text -> [TCPFlagField] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([TCPFlagField] -> Pair) -> Maybe [TCPFlagField] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TCPFlagField]
tCPFlags,
            (Text
"DestinationPorts" Text -> [PortRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([PortRange] -> Pair) -> Maybe [PortRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PortRange]
destinationPorts,
            (Text
"Sources" Text -> [Address] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Address] -> Pair) -> Maybe [Address] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Address]
sources,
            (Text
"SourcePorts" Text -> [PortRange] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([PortRange] -> Pair) -> Maybe [PortRange] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PortRange]
sourcePorts,
            (Text
"Destinations" Text -> [Address] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Address] -> Pair) -> Maybe [Address] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Address]
destinations
          ]
      )