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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 IP protocol name (@tcp@, @udp@, @icmp@, @icmpv6@) or number.
    SecurityGroupRuleDescription -> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | The IPv4 ranges for the security group rule.
    SecurityGroupRuleDescription -> Maybe Text
iPV4Range :: Prelude.Maybe Prelude.Text,
    -- | The ID of the prefix list for the security group rule.
    SecurityGroupRuleDescription -> Maybe Text
prefixListId :: 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,
    -- | The IPv6 ranges for the security group rule.
    SecurityGroupRuleDescription -> Maybe Text
iPV6Range :: Prelude.Maybe Prelude.Text
  }
  deriving (SecurityGroupRuleDescription
-> SecurityGroupRuleDescription -> Bool
(SecurityGroupRuleDescription
 -> SecurityGroupRuleDescription -> Bool)
-> (SecurityGroupRuleDescription
    -> SecurityGroupRuleDescription -> Bool)
-> Eq SecurityGroupRuleDescription
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]
(Int -> ReadS SecurityGroupRuleDescription)
-> ReadS [SecurityGroupRuleDescription]
-> ReadPrec SecurityGroupRuleDescription
-> ReadPrec [SecurityGroupRuleDescription]
-> Read 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
(Int -> SecurityGroupRuleDescription -> ShowS)
-> (SecurityGroupRuleDescription -> String)
-> ([SecurityGroupRuleDescription] -> ShowS)
-> Show SecurityGroupRuleDescription
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.
 SecurityGroupRuleDescription -> Rep SecurityGroupRuleDescription x)
-> (forall x.
    Rep SecurityGroupRuleDescription x -> SecurityGroupRuleDescription)
-> Generic SecurityGroupRuleDescription
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.
--
-- 'protocol', 'securityGroupRuleDescription_protocol' - The IP protocol name (@tcp@, @udp@, @icmp@, @icmpv6@) or number.
--
-- 'iPV4Range', 'securityGroupRuleDescription_iPV4Range' - The IPv4 ranges for the security group rule.
--
-- 'prefixListId', 'securityGroupRuleDescription_prefixListId' - The ID of the prefix list for the security group rule.
--
-- '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.
--
-- 'iPV6Range', 'securityGroupRuleDescription_iPV6Range' - The IPv6 ranges for the security group rule.
newSecurityGroupRuleDescription ::
  SecurityGroupRuleDescription
newSecurityGroupRuleDescription :: SecurityGroupRuleDescription
newSecurityGroupRuleDescription =
  SecurityGroupRuleDescription' :: Maybe Natural
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Maybe Text
-> SecurityGroupRuleDescription
SecurityGroupRuleDescription'
    { $sel:fromPort:SecurityGroupRuleDescription' :: Maybe Natural
fromPort =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:SecurityGroupRuleDescription' :: Maybe Text
protocol = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iPV4Range:SecurityGroupRuleDescription' :: Maybe Text
iPV4Range = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:prefixListId:SecurityGroupRuleDescription' :: Maybe Text
prefixListId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:SecurityGroupRuleDescription' :: Maybe Natural
toPort = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:iPV6Range:SecurityGroupRuleDescription' :: Maybe Text
iPV6Range = Maybe Text
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 :: (Maybe Natural -> f (Maybe Natural))
-> SecurityGroupRuleDescription -> f SecurityGroupRuleDescription
securityGroupRuleDescription_fromPort = (SecurityGroupRuleDescription -> Maybe Natural)
-> (SecurityGroupRuleDescription
    -> Maybe Natural -> SecurityGroupRuleDescription)
-> Lens
     SecurityGroupRuleDescription
     SecurityGroupRuleDescription
     (Maybe Natural)
     (Maybe Natural)
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 IP protocol name (@tcp@, @udp@, @icmp@, @icmpv6@) or number.
securityGroupRuleDescription_protocol :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_protocol :: (Maybe Text -> f (Maybe Text))
-> SecurityGroupRuleDescription -> f SecurityGroupRuleDescription
securityGroupRuleDescription_protocol = (SecurityGroupRuleDescription -> Maybe Text)
-> (SecurityGroupRuleDescription
    -> Maybe Text -> SecurityGroupRuleDescription)
-> Lens
     SecurityGroupRuleDescription
     SecurityGroupRuleDescription
     (Maybe Text)
     (Maybe Text)
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 IPv4 ranges for the security group rule.
securityGroupRuleDescription_iPV4Range :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_iPV4Range :: (Maybe Text -> f (Maybe Text))
-> SecurityGroupRuleDescription -> f SecurityGroupRuleDescription
securityGroupRuleDescription_iPV4Range = (SecurityGroupRuleDescription -> Maybe Text)
-> (SecurityGroupRuleDescription
    -> Maybe Text -> SecurityGroupRuleDescription)
-> Lens
     SecurityGroupRuleDescription
     SecurityGroupRuleDescription
     (Maybe Text)
     (Maybe Text)
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 ID of the prefix list for the security group rule.
securityGroupRuleDescription_prefixListId :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_prefixListId :: (Maybe Text -> f (Maybe Text))
-> SecurityGroupRuleDescription -> f SecurityGroupRuleDescription
securityGroupRuleDescription_prefixListId = (SecurityGroupRuleDescription -> Maybe Text)
-> (SecurityGroupRuleDescription
    -> Maybe Text -> SecurityGroupRuleDescription)
-> Lens
     SecurityGroupRuleDescription
     SecurityGroupRuleDescription
     (Maybe Text)
     (Maybe Text)
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 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 :: (Maybe Natural -> f (Maybe Natural))
-> SecurityGroupRuleDescription -> f SecurityGroupRuleDescription
securityGroupRuleDescription_toPort = (SecurityGroupRuleDescription -> Maybe Natural)
-> (SecurityGroupRuleDescription
    -> Maybe Natural -> SecurityGroupRuleDescription)
-> Lens
     SecurityGroupRuleDescription
     SecurityGroupRuleDescription
     (Maybe Natural)
     (Maybe Natural)
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)

-- | The IPv6 ranges for the security group rule.
securityGroupRuleDescription_iPV6Range :: Lens.Lens' SecurityGroupRuleDescription (Prelude.Maybe Prelude.Text)
securityGroupRuleDescription_iPV6Range :: (Maybe Text -> f (Maybe Text))
-> SecurityGroupRuleDescription -> f SecurityGroupRuleDescription
securityGroupRuleDescription_iPV6Range = (SecurityGroupRuleDescription -> Maybe Text)
-> (SecurityGroupRuleDescription
    -> Maybe Text -> SecurityGroupRuleDescription)
-> Lens
     SecurityGroupRuleDescription
     SecurityGroupRuleDescription
     (Maybe Text)
     (Maybe Text)
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)

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

instance
  Prelude.Hashable
    SecurityGroupRuleDescription

instance Prelude.NFData SecurityGroupRuleDescription