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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.IcmpTypeCode
import Amazonka.SecurityHub.Types.PortRangeFromTo

-- | A rule for the network ACL. Each rule allows or denies access based on
-- the IP address, traffic direction, port, and protocol.
--
-- /See:/ 'newAwsEc2NetworkAclEntry' smart constructor.
data AwsEc2NetworkAclEntry = AwsEc2NetworkAclEntry'
  { -- | The IPV6 network range for which to deny or allow access.
    AwsEc2NetworkAclEntry -> Maybe Text
ipv6CidrBlock :: Prelude.Maybe Prelude.Text,
    -- | The Internet Control Message Protocol (ICMP) type and code for which to
    -- deny or allow access.
    AwsEc2NetworkAclEntry -> Maybe IcmpTypeCode
icmpTypeCode :: Prelude.Maybe IcmpTypeCode,
    -- | The rule number. The rules are processed in order by their number.
    AwsEc2NetworkAclEntry -> Maybe Int
ruleNumber :: Prelude.Maybe Prelude.Int,
    -- | Whether the rule is used to allow access or deny access.
    AwsEc2NetworkAclEntry -> Maybe Text
ruleAction :: Prelude.Maybe Prelude.Text,
    -- | The protocol that the rule applies to. To deny or allow access to all
    -- protocols, use the value -1.
    AwsEc2NetworkAclEntry -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | For TCP or UDP protocols, the range of ports that the rule applies to.
    AwsEc2NetworkAclEntry -> Maybe PortRangeFromTo
portRange :: Prelude.Maybe PortRangeFromTo,
    -- | The IPV4 network range for which to deny or allow access.
    AwsEc2NetworkAclEntry -> Maybe Text
cidrBlock :: Prelude.Maybe Prelude.Text,
    -- | Whether the rule is an egress rule. An egress rule is a rule that
    -- applies to traffic that leaves the subnet.
    AwsEc2NetworkAclEntry -> Maybe Bool
egress :: Prelude.Maybe Prelude.Bool
  }
  deriving (AwsEc2NetworkAclEntry -> AwsEc2NetworkAclEntry -> Bool
(AwsEc2NetworkAclEntry -> AwsEc2NetworkAclEntry -> Bool)
-> (AwsEc2NetworkAclEntry -> AwsEc2NetworkAclEntry -> Bool)
-> Eq AwsEc2NetworkAclEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEc2NetworkAclEntry -> AwsEc2NetworkAclEntry -> Bool
$c/= :: AwsEc2NetworkAclEntry -> AwsEc2NetworkAclEntry -> Bool
== :: AwsEc2NetworkAclEntry -> AwsEc2NetworkAclEntry -> Bool
$c== :: AwsEc2NetworkAclEntry -> AwsEc2NetworkAclEntry -> Bool
Prelude.Eq, ReadPrec [AwsEc2NetworkAclEntry]
ReadPrec AwsEc2NetworkAclEntry
Int -> ReadS AwsEc2NetworkAclEntry
ReadS [AwsEc2NetworkAclEntry]
(Int -> ReadS AwsEc2NetworkAclEntry)
-> ReadS [AwsEc2NetworkAclEntry]
-> ReadPrec AwsEc2NetworkAclEntry
-> ReadPrec [AwsEc2NetworkAclEntry]
-> Read AwsEc2NetworkAclEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEc2NetworkAclEntry]
$creadListPrec :: ReadPrec [AwsEc2NetworkAclEntry]
readPrec :: ReadPrec AwsEc2NetworkAclEntry
$creadPrec :: ReadPrec AwsEc2NetworkAclEntry
readList :: ReadS [AwsEc2NetworkAclEntry]
$creadList :: ReadS [AwsEc2NetworkAclEntry]
readsPrec :: Int -> ReadS AwsEc2NetworkAclEntry
$creadsPrec :: Int -> ReadS AwsEc2NetworkAclEntry
Prelude.Read, Int -> AwsEc2NetworkAclEntry -> ShowS
[AwsEc2NetworkAclEntry] -> ShowS
AwsEc2NetworkAclEntry -> String
(Int -> AwsEc2NetworkAclEntry -> ShowS)
-> (AwsEc2NetworkAclEntry -> String)
-> ([AwsEc2NetworkAclEntry] -> ShowS)
-> Show AwsEc2NetworkAclEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEc2NetworkAclEntry] -> ShowS
$cshowList :: [AwsEc2NetworkAclEntry] -> ShowS
show :: AwsEc2NetworkAclEntry -> String
$cshow :: AwsEc2NetworkAclEntry -> String
showsPrec :: Int -> AwsEc2NetworkAclEntry -> ShowS
$cshowsPrec :: Int -> AwsEc2NetworkAclEntry -> ShowS
Prelude.Show, (forall x. AwsEc2NetworkAclEntry -> Rep AwsEc2NetworkAclEntry x)
-> (forall x. Rep AwsEc2NetworkAclEntry x -> AwsEc2NetworkAclEntry)
-> Generic AwsEc2NetworkAclEntry
forall x. Rep AwsEc2NetworkAclEntry x -> AwsEc2NetworkAclEntry
forall x. AwsEc2NetworkAclEntry -> Rep AwsEc2NetworkAclEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsEc2NetworkAclEntry x -> AwsEc2NetworkAclEntry
$cfrom :: forall x. AwsEc2NetworkAclEntry -> Rep AwsEc2NetworkAclEntry x
Prelude.Generic)

-- |
-- Create a value of 'AwsEc2NetworkAclEntry' 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:
--
-- 'ipv6CidrBlock', 'awsEc2NetworkAclEntry_ipv6CidrBlock' - The IPV6 network range for which to deny or allow access.
--
-- 'icmpTypeCode', 'awsEc2NetworkAclEntry_icmpTypeCode' - The Internet Control Message Protocol (ICMP) type and code for which to
-- deny or allow access.
--
-- 'ruleNumber', 'awsEc2NetworkAclEntry_ruleNumber' - The rule number. The rules are processed in order by their number.
--
-- 'ruleAction', 'awsEc2NetworkAclEntry_ruleAction' - Whether the rule is used to allow access or deny access.
--
-- 'protocol', 'awsEc2NetworkAclEntry_protocol' - The protocol that the rule applies to. To deny or allow access to all
-- protocols, use the value -1.
--
-- 'portRange', 'awsEc2NetworkAclEntry_portRange' - For TCP or UDP protocols, the range of ports that the rule applies to.
--
-- 'cidrBlock', 'awsEc2NetworkAclEntry_cidrBlock' - The IPV4 network range for which to deny or allow access.
--
-- 'egress', 'awsEc2NetworkAclEntry_egress' - Whether the rule is an egress rule. An egress rule is a rule that
-- applies to traffic that leaves the subnet.
newAwsEc2NetworkAclEntry ::
  AwsEc2NetworkAclEntry
newAwsEc2NetworkAclEntry :: AwsEc2NetworkAclEntry
newAwsEc2NetworkAclEntry =
  AwsEc2NetworkAclEntry' :: Maybe Text
-> Maybe IcmpTypeCode
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe PortRangeFromTo
-> Maybe Text
-> Maybe Bool
-> AwsEc2NetworkAclEntry
AwsEc2NetworkAclEntry'
    { $sel:ipv6CidrBlock:AwsEc2NetworkAclEntry' :: Maybe Text
ipv6CidrBlock =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:icmpTypeCode:AwsEc2NetworkAclEntry' :: Maybe IcmpTypeCode
icmpTypeCode = Maybe IcmpTypeCode
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleNumber:AwsEc2NetworkAclEntry' :: Maybe Int
ruleNumber = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleAction:AwsEc2NetworkAclEntry' :: Maybe Text
ruleAction = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:AwsEc2NetworkAclEntry' :: Maybe Text
protocol = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:portRange:AwsEc2NetworkAclEntry' :: Maybe PortRangeFromTo
portRange = Maybe PortRangeFromTo
forall a. Maybe a
Prelude.Nothing,
      $sel:cidrBlock:AwsEc2NetworkAclEntry' :: Maybe Text
cidrBlock = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:egress:AwsEc2NetworkAclEntry' :: Maybe Bool
egress = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The IPV6 network range for which to deny or allow access.
awsEc2NetworkAclEntry_ipv6CidrBlock :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe Prelude.Text)
awsEc2NetworkAclEntry_ipv6CidrBlock :: (Maybe Text -> f (Maybe Text))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_ipv6CidrBlock = (AwsEc2NetworkAclEntry -> Maybe Text)
-> (AwsEc2NetworkAclEntry -> Maybe Text -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry
     AwsEc2NetworkAclEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe Text
ipv6CidrBlock :: Maybe Text
$sel:ipv6CidrBlock:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
ipv6CidrBlock} -> Maybe Text
ipv6CidrBlock) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe Text
a -> AwsEc2NetworkAclEntry
s {$sel:ipv6CidrBlock:AwsEc2NetworkAclEntry' :: Maybe Text
ipv6CidrBlock = Maybe Text
a} :: AwsEc2NetworkAclEntry)

-- | The Internet Control Message Protocol (ICMP) type and code for which to
-- deny or allow access.
awsEc2NetworkAclEntry_icmpTypeCode :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe IcmpTypeCode)
awsEc2NetworkAclEntry_icmpTypeCode :: (Maybe IcmpTypeCode -> f (Maybe IcmpTypeCode))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_icmpTypeCode = (AwsEc2NetworkAclEntry -> Maybe IcmpTypeCode)
-> (AwsEc2NetworkAclEntry
    -> Maybe IcmpTypeCode -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry
     AwsEc2NetworkAclEntry
     (Maybe IcmpTypeCode)
     (Maybe IcmpTypeCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe IcmpTypeCode
icmpTypeCode :: Maybe IcmpTypeCode
$sel:icmpTypeCode:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe IcmpTypeCode
icmpTypeCode} -> Maybe IcmpTypeCode
icmpTypeCode) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe IcmpTypeCode
a -> AwsEc2NetworkAclEntry
s {$sel:icmpTypeCode:AwsEc2NetworkAclEntry' :: Maybe IcmpTypeCode
icmpTypeCode = Maybe IcmpTypeCode
a} :: AwsEc2NetworkAclEntry)

-- | The rule number. The rules are processed in order by their number.
awsEc2NetworkAclEntry_ruleNumber :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe Prelude.Int)
awsEc2NetworkAclEntry_ruleNumber :: (Maybe Int -> f (Maybe Int))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_ruleNumber = (AwsEc2NetworkAclEntry -> Maybe Int)
-> (AwsEc2NetworkAclEntry -> Maybe Int -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry AwsEc2NetworkAclEntry (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe Int
ruleNumber :: Maybe Int
$sel:ruleNumber:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Int
ruleNumber} -> Maybe Int
ruleNumber) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe Int
a -> AwsEc2NetworkAclEntry
s {$sel:ruleNumber:AwsEc2NetworkAclEntry' :: Maybe Int
ruleNumber = Maybe Int
a} :: AwsEc2NetworkAclEntry)

-- | Whether the rule is used to allow access or deny access.
awsEc2NetworkAclEntry_ruleAction :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe Prelude.Text)
awsEc2NetworkAclEntry_ruleAction :: (Maybe Text -> f (Maybe Text))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_ruleAction = (AwsEc2NetworkAclEntry -> Maybe Text)
-> (AwsEc2NetworkAclEntry -> Maybe Text -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry
     AwsEc2NetworkAclEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe Text
ruleAction :: Maybe Text
$sel:ruleAction:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
ruleAction} -> Maybe Text
ruleAction) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe Text
a -> AwsEc2NetworkAclEntry
s {$sel:ruleAction:AwsEc2NetworkAclEntry' :: Maybe Text
ruleAction = Maybe Text
a} :: AwsEc2NetworkAclEntry)

-- | The protocol that the rule applies to. To deny or allow access to all
-- protocols, use the value -1.
awsEc2NetworkAclEntry_protocol :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe Prelude.Text)
awsEc2NetworkAclEntry_protocol :: (Maybe Text -> f (Maybe Text))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_protocol = (AwsEc2NetworkAclEntry -> Maybe Text)
-> (AwsEc2NetworkAclEntry -> Maybe Text -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry
     AwsEc2NetworkAclEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe Text
protocol :: Maybe Text
$sel:protocol:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
protocol} -> Maybe Text
protocol) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe Text
a -> AwsEc2NetworkAclEntry
s {$sel:protocol:AwsEc2NetworkAclEntry' :: Maybe Text
protocol = Maybe Text
a} :: AwsEc2NetworkAclEntry)

-- | For TCP or UDP protocols, the range of ports that the rule applies to.
awsEc2NetworkAclEntry_portRange :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe PortRangeFromTo)
awsEc2NetworkAclEntry_portRange :: (Maybe PortRangeFromTo -> f (Maybe PortRangeFromTo))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_portRange = (AwsEc2NetworkAclEntry -> Maybe PortRangeFromTo)
-> (AwsEc2NetworkAclEntry
    -> Maybe PortRangeFromTo -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry
     AwsEc2NetworkAclEntry
     (Maybe PortRangeFromTo)
     (Maybe PortRangeFromTo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe PortRangeFromTo
portRange :: Maybe PortRangeFromTo
$sel:portRange:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe PortRangeFromTo
portRange} -> Maybe PortRangeFromTo
portRange) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe PortRangeFromTo
a -> AwsEc2NetworkAclEntry
s {$sel:portRange:AwsEc2NetworkAclEntry' :: Maybe PortRangeFromTo
portRange = Maybe PortRangeFromTo
a} :: AwsEc2NetworkAclEntry)

-- | The IPV4 network range for which to deny or allow access.
awsEc2NetworkAclEntry_cidrBlock :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe Prelude.Text)
awsEc2NetworkAclEntry_cidrBlock :: (Maybe Text -> f (Maybe Text))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_cidrBlock = (AwsEc2NetworkAclEntry -> Maybe Text)
-> (AwsEc2NetworkAclEntry -> Maybe Text -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry
     AwsEc2NetworkAclEntry
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe Text
cidrBlock :: Maybe Text
$sel:cidrBlock:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
cidrBlock} -> Maybe Text
cidrBlock) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe Text
a -> AwsEc2NetworkAclEntry
s {$sel:cidrBlock:AwsEc2NetworkAclEntry' :: Maybe Text
cidrBlock = Maybe Text
a} :: AwsEc2NetworkAclEntry)

-- | Whether the rule is an egress rule. An egress rule is a rule that
-- applies to traffic that leaves the subnet.
awsEc2NetworkAclEntry_egress :: Lens.Lens' AwsEc2NetworkAclEntry (Prelude.Maybe Prelude.Bool)
awsEc2NetworkAclEntry_egress :: (Maybe Bool -> f (Maybe Bool))
-> AwsEc2NetworkAclEntry -> f AwsEc2NetworkAclEntry
awsEc2NetworkAclEntry_egress = (AwsEc2NetworkAclEntry -> Maybe Bool)
-> (AwsEc2NetworkAclEntry -> Maybe Bool -> AwsEc2NetworkAclEntry)
-> Lens
     AwsEc2NetworkAclEntry
     AwsEc2NetworkAclEntry
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEc2NetworkAclEntry' {Maybe Bool
egress :: Maybe Bool
$sel:egress:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Bool
egress} -> Maybe Bool
egress) (\s :: AwsEc2NetworkAclEntry
s@AwsEc2NetworkAclEntry' {} Maybe Bool
a -> AwsEc2NetworkAclEntry
s {$sel:egress:AwsEc2NetworkAclEntry' :: Maybe Bool
egress = Maybe Bool
a} :: AwsEc2NetworkAclEntry)

instance Core.FromJSON AwsEc2NetworkAclEntry where
  parseJSON :: Value -> Parser AwsEc2NetworkAclEntry
parseJSON =
    String
-> (Object -> Parser AwsEc2NetworkAclEntry)
-> Value
-> Parser AwsEc2NetworkAclEntry
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEc2NetworkAclEntry"
      ( \Object
x ->
          Maybe Text
-> Maybe IcmpTypeCode
-> Maybe Int
-> Maybe Text
-> Maybe Text
-> Maybe PortRangeFromTo
-> Maybe Text
-> Maybe Bool
-> AwsEc2NetworkAclEntry
AwsEc2NetworkAclEntry'
            (Maybe Text
 -> Maybe IcmpTypeCode
 -> Maybe Int
 -> Maybe Text
 -> Maybe Text
 -> Maybe PortRangeFromTo
 -> Maybe Text
 -> Maybe Bool
 -> AwsEc2NetworkAclEntry)
-> Parser (Maybe Text)
-> Parser
     (Maybe IcmpTypeCode
      -> Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe PortRangeFromTo
      -> Maybe Text
      -> Maybe Bool
      -> AwsEc2NetworkAclEntry)
forall (f :: * -> *) a b. Functor 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
"Ipv6CidrBlock")
            Parser
  (Maybe IcmpTypeCode
   -> Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe PortRangeFromTo
   -> Maybe Text
   -> Maybe Bool
   -> AwsEc2NetworkAclEntry)
-> Parser (Maybe IcmpTypeCode)
-> Parser
     (Maybe Int
      -> Maybe Text
      -> Maybe Text
      -> Maybe PortRangeFromTo
      -> Maybe Text
      -> Maybe Bool
      -> AwsEc2NetworkAclEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IcmpTypeCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IcmpTypeCode")
            Parser
  (Maybe Int
   -> Maybe Text
   -> Maybe Text
   -> Maybe PortRangeFromTo
   -> Maybe Text
   -> Maybe Bool
   -> AwsEc2NetworkAclEntry)
-> Parser (Maybe Int)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe PortRangeFromTo
      -> Maybe Text
      -> Maybe Bool
      -> AwsEc2NetworkAclEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RuleNumber")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe PortRangeFromTo
   -> Maybe Text
   -> Maybe Bool
   -> AwsEc2NetworkAclEntry)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe PortRangeFromTo
      -> Maybe Text
      -> Maybe Bool
      -> AwsEc2NetworkAclEntry)
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
"RuleAction")
            Parser
  (Maybe Text
   -> Maybe PortRangeFromTo
   -> Maybe Text
   -> Maybe Bool
   -> AwsEc2NetworkAclEntry)
-> Parser (Maybe Text)
-> Parser
     (Maybe PortRangeFromTo
      -> Maybe Text -> Maybe Bool -> AwsEc2NetworkAclEntry)
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 PortRangeFromTo
   -> Maybe Text -> Maybe Bool -> AwsEc2NetworkAclEntry)
-> Parser (Maybe PortRangeFromTo)
-> Parser (Maybe Text -> Maybe Bool -> AwsEc2NetworkAclEntry)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe PortRangeFromTo)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PortRange")
            Parser (Maybe Text -> Maybe Bool -> AwsEc2NetworkAclEntry)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> AwsEc2NetworkAclEntry)
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
"CidrBlock")
            Parser (Maybe Bool -> AwsEc2NetworkAclEntry)
-> Parser (Maybe Bool) -> Parser AwsEc2NetworkAclEntry
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Egress")
      )

instance Prelude.Hashable AwsEc2NetworkAclEntry

instance Prelude.NFData AwsEc2NetworkAclEntry

instance Core.ToJSON AwsEc2NetworkAclEntry where
  toJSON :: AwsEc2NetworkAclEntry -> Value
toJSON AwsEc2NetworkAclEntry' {Maybe Bool
Maybe Int
Maybe Text
Maybe IcmpTypeCode
Maybe PortRangeFromTo
egress :: Maybe Bool
cidrBlock :: Maybe Text
portRange :: Maybe PortRangeFromTo
protocol :: Maybe Text
ruleAction :: Maybe Text
ruleNumber :: Maybe Int
icmpTypeCode :: Maybe IcmpTypeCode
ipv6CidrBlock :: Maybe Text
$sel:egress:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Bool
$sel:cidrBlock:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
$sel:portRange:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe PortRangeFromTo
$sel:protocol:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
$sel:ruleAction:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
$sel:ruleNumber:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Int
$sel:icmpTypeCode:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe IcmpTypeCode
$sel:ipv6CidrBlock:AwsEc2NetworkAclEntry' :: AwsEc2NetworkAclEntry -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Ipv6CidrBlock" 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
ipv6CidrBlock,
            (Text
"IcmpTypeCode" Text -> IcmpTypeCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IcmpTypeCode -> Pair) -> Maybe IcmpTypeCode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IcmpTypeCode
icmpTypeCode,
            (Text
"RuleNumber" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
ruleNumber,
            (Text
"RuleAction" 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
ruleAction,
            (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
"PortRange" Text -> PortRangeFromTo -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (PortRangeFromTo -> Pair) -> Maybe PortRangeFromTo -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe PortRangeFromTo
portRange,
            (Text
"CidrBlock" 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
cidrBlock,
            (Text
"Egress" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
egress
          ]
      )