{-# 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.EC2.Types.StaleIpPermission
-- 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.EC2.Types.StaleIpPermission where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import Amazonka.EC2.Types.UserIdGroupPair
import qualified Amazonka.Prelude as Prelude

-- | Describes a stale rule in a security group.
--
-- /See:/ 'newStaleIpPermission' smart constructor.
data StaleIpPermission = StaleIpPermission'
  { -- | The start of the port range for the TCP and UDP protocols, or an ICMP
    -- type number. A value of @-1@ indicates all ICMP types.
    StaleIpPermission -> Maybe Int
fromPort :: Prelude.Maybe Prelude.Int,
    -- | The IP protocol name (for @tcp@, @udp@, and @icmp@) or number (see
    -- <http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml Protocol Numbers)>.
    StaleIpPermission -> Maybe Text
ipProtocol :: Prelude.Maybe Prelude.Text,
    -- | The IP ranges. Not applicable for stale security group rules.
    StaleIpPermission -> Maybe [Text]
ipRanges :: Prelude.Maybe [Prelude.Text],
    -- | The prefix list IDs. Not applicable for stale security group rules.
    StaleIpPermission -> Maybe [Text]
prefixListIds :: Prelude.Maybe [Prelude.Text],
    -- | The end of the port range for the TCP and UDP protocols, or an ICMP type
    -- number. A value of @-1@ indicates all ICMP types.
    StaleIpPermission -> Maybe Int
toPort :: Prelude.Maybe Prelude.Int,
    -- | The security group pairs. Returns the ID of the referenced security
    -- group and VPC, and the ID and status of the VPC peering connection.
    StaleIpPermission -> Maybe [UserIdGroupPair]
userIdGroupPairs :: Prelude.Maybe [UserIdGroupPair]
  }
  deriving (StaleIpPermission -> StaleIpPermission -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StaleIpPermission -> StaleIpPermission -> Bool
$c/= :: StaleIpPermission -> StaleIpPermission -> Bool
== :: StaleIpPermission -> StaleIpPermission -> Bool
$c== :: StaleIpPermission -> StaleIpPermission -> Bool
Prelude.Eq, ReadPrec [StaleIpPermission]
ReadPrec StaleIpPermission
Int -> ReadS StaleIpPermission
ReadS [StaleIpPermission]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StaleIpPermission]
$creadListPrec :: ReadPrec [StaleIpPermission]
readPrec :: ReadPrec StaleIpPermission
$creadPrec :: ReadPrec StaleIpPermission
readList :: ReadS [StaleIpPermission]
$creadList :: ReadS [StaleIpPermission]
readsPrec :: Int -> ReadS StaleIpPermission
$creadsPrec :: Int -> ReadS StaleIpPermission
Prelude.Read, Int -> StaleIpPermission -> ShowS
[StaleIpPermission] -> ShowS
StaleIpPermission -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StaleIpPermission] -> ShowS
$cshowList :: [StaleIpPermission] -> ShowS
show :: StaleIpPermission -> String
$cshow :: StaleIpPermission -> String
showsPrec :: Int -> StaleIpPermission -> ShowS
$cshowsPrec :: Int -> StaleIpPermission -> ShowS
Prelude.Show, forall x. Rep StaleIpPermission x -> StaleIpPermission
forall x. StaleIpPermission -> Rep StaleIpPermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StaleIpPermission x -> StaleIpPermission
$cfrom :: forall x. StaleIpPermission -> Rep StaleIpPermission x
Prelude.Generic)

-- |
-- Create a value of 'StaleIpPermission' 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', 'staleIpPermission_fromPort' - The start of the port range for the TCP and UDP protocols, or an ICMP
-- type number. A value of @-1@ indicates all ICMP types.
--
-- 'ipProtocol', 'staleIpPermission_ipProtocol' - The IP protocol name (for @tcp@, @udp@, and @icmp@) or number (see
-- <http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml Protocol Numbers)>.
--
-- 'ipRanges', 'staleIpPermission_ipRanges' - The IP ranges. Not applicable for stale security group rules.
--
-- 'prefixListIds', 'staleIpPermission_prefixListIds' - The prefix list IDs. Not applicable for stale security group rules.
--
-- 'toPort', 'staleIpPermission_toPort' - The end of the port range for the TCP and UDP protocols, or an ICMP type
-- number. A value of @-1@ indicates all ICMP types.
--
-- 'userIdGroupPairs', 'staleIpPermission_userIdGroupPairs' - The security group pairs. Returns the ID of the referenced security
-- group and VPC, and the ID and status of the VPC peering connection.
newStaleIpPermission ::
  StaleIpPermission
newStaleIpPermission :: StaleIpPermission
newStaleIpPermission =
  StaleIpPermission'
    { $sel:fromPort:StaleIpPermission' :: Maybe Int
fromPort = forall a. Maybe a
Prelude.Nothing,
      $sel:ipProtocol:StaleIpPermission' :: Maybe Text
ipProtocol = forall a. Maybe a
Prelude.Nothing,
      $sel:ipRanges:StaleIpPermission' :: Maybe [Text]
ipRanges = forall a. Maybe a
Prelude.Nothing,
      $sel:prefixListIds:StaleIpPermission' :: Maybe [Text]
prefixListIds = forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:StaleIpPermission' :: Maybe Int
toPort = forall a. Maybe a
Prelude.Nothing,
      $sel:userIdGroupPairs:StaleIpPermission' :: Maybe [UserIdGroupPair]
userIdGroupPairs = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The IP protocol name (for @tcp@, @udp@, and @icmp@) or number (see
-- <http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml Protocol Numbers)>.
staleIpPermission_ipProtocol :: Lens.Lens' StaleIpPermission (Prelude.Maybe Prelude.Text)
staleIpPermission_ipProtocol :: Lens' StaleIpPermission (Maybe Text)
staleIpPermission_ipProtocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaleIpPermission' {Maybe Text
ipProtocol :: Maybe Text
$sel:ipProtocol:StaleIpPermission' :: StaleIpPermission -> Maybe Text
ipProtocol} -> Maybe Text
ipProtocol) (\s :: StaleIpPermission
s@StaleIpPermission' {} Maybe Text
a -> StaleIpPermission
s {$sel:ipProtocol:StaleIpPermission' :: Maybe Text
ipProtocol = Maybe Text
a} :: StaleIpPermission)

-- | The IP ranges. Not applicable for stale security group rules.
staleIpPermission_ipRanges :: Lens.Lens' StaleIpPermission (Prelude.Maybe [Prelude.Text])
staleIpPermission_ipRanges :: Lens' StaleIpPermission (Maybe [Text])
staleIpPermission_ipRanges = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaleIpPermission' {Maybe [Text]
ipRanges :: Maybe [Text]
$sel:ipRanges:StaleIpPermission' :: StaleIpPermission -> Maybe [Text]
ipRanges} -> Maybe [Text]
ipRanges) (\s :: StaleIpPermission
s@StaleIpPermission' {} Maybe [Text]
a -> StaleIpPermission
s {$sel:ipRanges:StaleIpPermission' :: Maybe [Text]
ipRanges = Maybe [Text]
a} :: StaleIpPermission) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The prefix list IDs. Not applicable for stale security group rules.
staleIpPermission_prefixListIds :: Lens.Lens' StaleIpPermission (Prelude.Maybe [Prelude.Text])
staleIpPermission_prefixListIds :: Lens' StaleIpPermission (Maybe [Text])
staleIpPermission_prefixListIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaleIpPermission' {Maybe [Text]
prefixListIds :: Maybe [Text]
$sel:prefixListIds:StaleIpPermission' :: StaleIpPermission -> Maybe [Text]
prefixListIds} -> Maybe [Text]
prefixListIds) (\s :: StaleIpPermission
s@StaleIpPermission' {} Maybe [Text]
a -> StaleIpPermission
s {$sel:prefixListIds:StaleIpPermission' :: Maybe [Text]
prefixListIds = Maybe [Text]
a} :: StaleIpPermission) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The end of the port range for the TCP and UDP protocols, or an ICMP type
-- number. A value of @-1@ indicates all ICMP types.
staleIpPermission_toPort :: Lens.Lens' StaleIpPermission (Prelude.Maybe Prelude.Int)
staleIpPermission_toPort :: Lens' StaleIpPermission (Maybe Int)
staleIpPermission_toPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaleIpPermission' {Maybe Int
toPort :: Maybe Int
$sel:toPort:StaleIpPermission' :: StaleIpPermission -> Maybe Int
toPort} -> Maybe Int
toPort) (\s :: StaleIpPermission
s@StaleIpPermission' {} Maybe Int
a -> StaleIpPermission
s {$sel:toPort:StaleIpPermission' :: Maybe Int
toPort = Maybe Int
a} :: StaleIpPermission)

-- | The security group pairs. Returns the ID of the referenced security
-- group and VPC, and the ID and status of the VPC peering connection.
staleIpPermission_userIdGroupPairs :: Lens.Lens' StaleIpPermission (Prelude.Maybe [UserIdGroupPair])
staleIpPermission_userIdGroupPairs :: Lens' StaleIpPermission (Maybe [UserIdGroupPair])
staleIpPermission_userIdGroupPairs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaleIpPermission' {Maybe [UserIdGroupPair]
userIdGroupPairs :: Maybe [UserIdGroupPair]
$sel:userIdGroupPairs:StaleIpPermission' :: StaleIpPermission -> Maybe [UserIdGroupPair]
userIdGroupPairs} -> Maybe [UserIdGroupPair]
userIdGroupPairs) (\s :: StaleIpPermission
s@StaleIpPermission' {} Maybe [UserIdGroupPair]
a -> StaleIpPermission
s {$sel:userIdGroupPairs:StaleIpPermission' :: Maybe [UserIdGroupPair]
userIdGroupPairs = Maybe [UserIdGroupPair]
a} :: StaleIpPermission) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML StaleIpPermission where
  parseXML :: [Node] -> Either String StaleIpPermission
parseXML [Node]
x =
    Maybe Int
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Int
-> Maybe [UserIdGroupPair]
-> StaleIpPermission
StaleIpPermission'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"fromPort")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ipProtocol")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"ipRanges"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"prefixListIds"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"toPort")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"groups"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )

instance Prelude.Hashable StaleIpPermission where
  hashWithSalt :: Int -> StaleIpPermission -> Int
hashWithSalt Int
_salt StaleIpPermission' {Maybe Int
Maybe [Text]
Maybe [UserIdGroupPair]
Maybe Text
userIdGroupPairs :: Maybe [UserIdGroupPair]
toPort :: Maybe Int
prefixListIds :: Maybe [Text]
ipRanges :: Maybe [Text]
ipProtocol :: Maybe Text
fromPort :: Maybe Int
$sel:userIdGroupPairs:StaleIpPermission' :: StaleIpPermission -> Maybe [UserIdGroupPair]
$sel:toPort:StaleIpPermission' :: StaleIpPermission -> Maybe Int
$sel:prefixListIds:StaleIpPermission' :: StaleIpPermission -> Maybe [Text]
$sel:ipRanges:StaleIpPermission' :: StaleIpPermission -> Maybe [Text]
$sel:ipProtocol:StaleIpPermission' :: StaleIpPermission -> Maybe Text
$sel:fromPort:StaleIpPermission' :: StaleIpPermission -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
fromPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ipProtocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ipRanges
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
prefixListIds
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
toPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [UserIdGroupPair]
userIdGroupPairs

instance Prelude.NFData StaleIpPermission where
  rnf :: StaleIpPermission -> ()
rnf StaleIpPermission' {Maybe Int
Maybe [Text]
Maybe [UserIdGroupPair]
Maybe Text
userIdGroupPairs :: Maybe [UserIdGroupPair]
toPort :: Maybe Int
prefixListIds :: Maybe [Text]
ipRanges :: Maybe [Text]
ipProtocol :: Maybe Text
fromPort :: Maybe Int
$sel:userIdGroupPairs:StaleIpPermission' :: StaleIpPermission -> Maybe [UserIdGroupPair]
$sel:toPort:StaleIpPermission' :: StaleIpPermission -> Maybe Int
$sel:prefixListIds:StaleIpPermission' :: StaleIpPermission -> Maybe [Text]
$sel:ipRanges:StaleIpPermission' :: StaleIpPermission -> Maybe [Text]
$sel:ipProtocol:StaleIpPermission' :: StaleIpPermission -> Maybe Text
$sel:fromPort:StaleIpPermission' :: StaleIpPermission -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
fromPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ipProtocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
ipRanges
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
prefixListIds
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
toPort
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [UserIdGroupPair]
userIdGroupPairs