{-# 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.FMS.Types.SecurityGroupRuleDescription
-- 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.FMS.Types.SecurityGroupRuleDescription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Describes a set of permissions for a security group rule.
--
-- /See:/ 'newSecurityGroupRuleDescription' smart constructor.
data SecurityGroupRuleDescription = SecurityGroupRuleDescription'
  { -- | The start of the port range for the TCP and UDP protocols, or an
    -- ICMP\/ICMPv6 type number. A value of @-1@ indicates all ICMP\/ICMPv6
    -- types.
    SecurityGroupRuleDescription -> Maybe Natural
fromPort :: Prelude.Maybe Prelude.Natural,
    -- | The IPv4 ranges for the security group rule.
    SecurityGroupRuleDescription -> Maybe Text
iPV4Range :: Prelude.Maybe Prelude.Text,
    -- | The IPv6 ranges for the security group rule.
    SecurityGroupRuleDescription -> Maybe Text
iPV6Range :: Prelude.Maybe Prelude.Text,
    -- | The ID of the prefix list for the security group rule.
    SecurityGroupRuleDescription -> Maybe Text
prefixListId :: Prelude.Maybe Prelude.Text,
    -- | The IP protocol name (@tcp@, @udp@, @icmp@, @icmpv6@) or number.
    SecurityGroupRuleDescription -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | The end of the port range for the TCP and UDP protocols, or an
    -- ICMP\/ICMPv6 code. A value of @-1@ indicates all ICMP\/ICMPv6 codes.
    SecurityGroupRuleDescription -> Maybe Natural
toPort :: Prelude.Maybe Prelude.Natural
  }
  deriving (SecurityGroupRuleDescription
-> SecurityGroupRuleDescription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecurityGroupRuleDescription
-> SecurityGroupRuleDescription -> Bool
$c/= :: SecurityGroupRuleDescription
-> SecurityGroupRuleDescription -> Bool
== :: SecurityGroupRuleDescription
-> SecurityGroupRuleDescription -> Bool
$c== :: SecurityGroupRuleDescription
-> SecurityGroupRuleDescription -> Bool
Prelude.Eq, ReadPrec [SecurityGroupRuleDescription]
ReadPrec SecurityGroupRuleDescription
Int -> ReadS SecurityGroupRuleDescription
ReadS [SecurityGroupRuleDescription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecurityGroupRuleDescription]
$creadListPrec :: ReadPrec [SecurityGroupRuleDescription]
readPrec :: ReadPrec SecurityGroupRuleDescription
$creadPrec :: ReadPrec SecurityGroupRuleDescription
readList :: ReadS [SecurityGroupRuleDescription]
$creadList :: ReadS [SecurityGroupRuleDescription]
readsPrec :: Int -> ReadS SecurityGroupRuleDescription
$creadsPrec :: Int -> ReadS SecurityGroupRuleDescription
Prelude.Read, Int -> SecurityGroupRuleDescription -> ShowS
[SecurityGroupRuleDescription] -> ShowS
SecurityGroupRuleDescription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecurityGroupRuleDescription] -> ShowS
$cshowList :: [SecurityGroupRuleDescription] -> ShowS
show :: SecurityGroupRuleDescription -> String
$cshow :: SecurityGroupRuleDescription -> String
showsPrec :: Int -> SecurityGroupRuleDescription -> ShowS
$cshowsPrec :: Int -> SecurityGroupRuleDescription -> ShowS
Prelude.Show, forall x.
Rep SecurityGroupRuleDescription x -> SecurityGroupRuleDescription
forall x.
SecurityGroupRuleDescription -> Rep SecurityGroupRuleDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SecurityGroupRuleDescription x -> SecurityGroupRuleDescription
$cfrom :: forall x.
SecurityGroupRuleDescription -> Rep SecurityGroupRuleDescription x
Prelude.Generic)

-- |
-- Create a value of 'SecurityGroupRuleDescription' 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:
--
-- 'fromPort', 'securityGroupRuleDescription_fromPort' - The start of the port range for the TCP and UDP protocols, or an
-- ICMP\/ICMPv6 type number. A value of @-1@ indicates all ICMP\/ICMPv6
-- types.
--
-- 'iPV4Range', 'securityGroupRuleDescription_iPV4Range' - The IPv4 ranges for the security group rule.
--
-- 'iPV6Range', 'securityGroupRuleDescription_iPV6Range' - The IPv6 ranges for the security group rule.
--
-- 'prefixListId', 'securityGroupRuleDescription_prefixListId' - The ID of the prefix list for the security group rule.
--
-- 'protocol', 'securityGroupRuleDescription_protocol' - The IP protocol name (@tcp@, @udp@, @icmp@, @icmpv6@) or number.
--
-- 'toPort', 'securityGroupRuleDescription_toPort' - The end of the port range for the TCP and UDP protocols, or an
-- ICMP\/ICMPv6 code. A value of @-1@ indicates all ICMP\/ICMPv6 codes.
newSecurityGroupRuleDescription ::
  SecurityGroupRuleDescription
newSecurityGroupRuleDescription :: SecurityGroupRuleDescription
newSecurityGroupRuleDescription =
  SecurityGroupRuleDescription'
    { $sel:fromPort:SecurityGroupRuleDescription' :: Maybe Natural
fromPort =
        forall a. Maybe a
Prelude.Nothing,
      $sel:iPV4Range:SecurityGroupRuleDescription' :: Maybe Text
iPV4Range = forall a. Maybe a
Prelude.Nothing,
      $sel:iPV6Range:SecurityGroupRuleDescription' :: Maybe Text
iPV6Range = forall a. Maybe a
Prelude.Nothing,
      $sel:prefixListId:SecurityGroupRuleDescription' :: Maybe Text
prefixListId = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:SecurityGroupRuleDescription' :: Maybe Text
protocol = forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:SecurityGroupRuleDescription' :: Maybe Natural
toPort = forall a. Maybe a
Prelude.Nothing
    }

-- | The start of the port range for the TCP and UDP protocols, or an
-- ICMP\/ICMPv6 type number. A value of @-1@ indicates all ICMP\/ICMPv6
-- types.
securityGroupRuleDescription_fromPort :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Natural)
securityGroupRuleDescription_fromPort :: Lens' SecurityGroupRuleDescription (Maybe Natural)
securityGroupRuleDescription_fromPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupRuleDescription' {Maybe Natural
fromPort :: Maybe Natural
$sel:fromPort:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Natural
fromPort} -> Maybe Natural
fromPort) (\s :: SecurityGroupRuleDescription
s@SecurityGroupRuleDescription' {} Maybe Natural
a -> SecurityGroupRuleDescription
s {$sel:fromPort:SecurityGroupRuleDescription' :: Maybe Natural
fromPort = Maybe Natural
a} :: SecurityGroupRuleDescription)

-- | The IPv4 ranges for the security group rule.
securityGroupRuleDescription_iPV4Range :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_iPV4Range :: Lens' SecurityGroupRuleDescription (Maybe Text)
securityGroupRuleDescription_iPV4Range = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupRuleDescription' {Maybe Text
iPV4Range :: Maybe Text
$sel:iPV4Range:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
iPV4Range} -> Maybe Text
iPV4Range) (\s :: SecurityGroupRuleDescription
s@SecurityGroupRuleDescription' {} Maybe Text
a -> SecurityGroupRuleDescription
s {$sel:iPV4Range:SecurityGroupRuleDescription' :: Maybe Text
iPV4Range = Maybe Text
a} :: SecurityGroupRuleDescription)

-- | The IPv6 ranges for the security group rule.
securityGroupRuleDescription_iPV6Range :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_iPV6Range :: Lens' SecurityGroupRuleDescription (Maybe Text)
securityGroupRuleDescription_iPV6Range = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupRuleDescription' {Maybe Text
iPV6Range :: Maybe Text
$sel:iPV6Range:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
iPV6Range} -> Maybe Text
iPV6Range) (\s :: SecurityGroupRuleDescription
s@SecurityGroupRuleDescription' {} Maybe Text
a -> SecurityGroupRuleDescription
s {$sel:iPV6Range:SecurityGroupRuleDescription' :: Maybe Text
iPV6Range = Maybe Text
a} :: SecurityGroupRuleDescription)

-- | The ID of the prefix list for the security group rule.
securityGroupRuleDescription_prefixListId :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_prefixListId :: Lens' SecurityGroupRuleDescription (Maybe Text)
securityGroupRuleDescription_prefixListId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupRuleDescription' {Maybe Text
prefixListId :: Maybe Text
$sel:prefixListId:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
prefixListId} -> Maybe Text
prefixListId) (\s :: SecurityGroupRuleDescription
s@SecurityGroupRuleDescription' {} Maybe Text
a -> SecurityGroupRuleDescription
s {$sel:prefixListId:SecurityGroupRuleDescription' :: Maybe Text
prefixListId = Maybe Text
a} :: SecurityGroupRuleDescription)

-- | The IP protocol name (@tcp@, @udp@, @icmp@, @icmpv6@) or number.
securityGroupRuleDescription_protocol :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_protocol :: Lens' SecurityGroupRuleDescription (Maybe Text)
securityGroupRuleDescription_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupRuleDescription' {Maybe Text
protocol :: Maybe Text
$sel:protocol:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
protocol} -> Maybe Text
protocol) (\s :: SecurityGroupRuleDescription
s@SecurityGroupRuleDescription' {} Maybe Text
a -> SecurityGroupRuleDescription
s {$sel:protocol:SecurityGroupRuleDescription' :: Maybe Text
protocol = Maybe Text
a} :: SecurityGroupRuleDescription)

-- | The end of the port range for the TCP and UDP protocols, or an
-- ICMP\/ICMPv6 code. A value of @-1@ indicates all ICMP\/ICMPv6 codes.
securityGroupRuleDescription_toPort :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Natural)
securityGroupRuleDescription_toPort :: Lens' SecurityGroupRuleDescription (Maybe Natural)
securityGroupRuleDescription_toPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityGroupRuleDescription' {Maybe Natural
toPort :: Maybe Natural
$sel:toPort:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Natural
toPort} -> Maybe Natural
toPort) (\s :: SecurityGroupRuleDescription
s@SecurityGroupRuleDescription' {} Maybe Natural
a -> SecurityGroupRuleDescription
s {$sel:toPort:SecurityGroupRuleDescription' :: Maybe Natural
toPort = Maybe Natural
a} :: SecurityGroupRuleDescription)

instance Data.FromJSON SecurityGroupRuleDescription where
  parseJSON :: Value -> Parser SecurityGroupRuleDescription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SecurityGroupRuleDescription"
      ( \Object
x ->
          Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> SecurityGroupRuleDescription
SecurityGroupRuleDescription'
            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
"FromPort")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IPV4Range")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IPV6Range")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"PrefixListId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Protocol")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ToPort")
      )

instance
  Prelude.Hashable
    SecurityGroupRuleDescription
  where
  hashWithSalt :: Int -> SecurityGroupRuleDescription -> Int
hashWithSalt Int
_salt SecurityGroupRuleDescription' {Maybe Natural
Maybe Text
toPort :: Maybe Natural
protocol :: Maybe Text
prefixListId :: Maybe Text
iPV6Range :: Maybe Text
iPV4Range :: Maybe Text
fromPort :: Maybe Natural
$sel:toPort:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Natural
$sel:protocol:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:prefixListId:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:iPV6Range:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:iPV4Range:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:fromPort:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
fromPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iPV4Range
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iPV6Range
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefixListId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
protocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
toPort

instance Prelude.NFData SecurityGroupRuleDescription where
  rnf :: SecurityGroupRuleDescription -> ()
rnf SecurityGroupRuleDescription' {Maybe Natural
Maybe Text
toPort :: Maybe Natural
protocol :: Maybe Text
prefixListId :: Maybe Text
iPV6Range :: Maybe Text
iPV4Range :: Maybe Text
fromPort :: Maybe Natural
$sel:toPort:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Natural
$sel:protocol:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:prefixListId:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:iPV6Range:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:iPV4Range:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Text
$sel:fromPort:SecurityGroupRuleDescription' :: SecurityGroupRuleDescription -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
fromPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iPV4Range
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iPV6Range
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefixListId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
toPort