{-# 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.Lightsail.Types.InstancePortInfo
-- 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.Lightsail.Types.InstancePortInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Lightsail.Types.AccessDirection
import Amazonka.Lightsail.Types.NetworkProtocol
import Amazonka.Lightsail.Types.PortAccessType
import qualified Amazonka.Prelude as Prelude

-- | Describes information about ports for an Amazon Lightsail instance.
--
-- /See:/ 'newInstancePortInfo' smart constructor.
data InstancePortInfo = InstancePortInfo'
  { -- | The access direction (@inbound@ or @outbound@).
    --
    -- Lightsail currently supports only @inbound@ access direction.
    InstancePortInfo -> Maybe AccessDirection
accessDirection :: Prelude.Maybe AccessDirection,
    -- | The location from which access is allowed. For example,
    -- @Anywhere (0.0.0.0\/0)@, or @Custom@ if a specific IP address or range
    -- of IP addresses is allowed.
    InstancePortInfo -> Maybe Text
accessFrom :: Prelude.Maybe Prelude.Text,
    -- | The type of access (@Public@ or @Private@).
    InstancePortInfo -> Maybe PortAccessType
accessType :: Prelude.Maybe PortAccessType,
    -- | An alias that defines access for a preconfigured range of IP addresses.
    --
    -- The only alias currently supported is @lightsail-connect@, which allows
    -- IP addresses of the browser-based RDP\/SSH client in the Lightsail
    -- console to connect to your instance.
    InstancePortInfo -> Maybe [Text]
cidrListAliases :: Prelude.Maybe [Prelude.Text],
    -- | The IPv4 address, or range of IPv4 addresses (in CIDR notation) that are
    -- allowed to connect to an instance through the ports, and the protocol.
    --
    -- The @ipv6Cidrs@ parameter lists the IPv6 addresses that are allowed to
    -- connect to an instance.
    --
    -- For more information about CIDR block notation, see
    -- <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation Classless Inter-Domain Routing>
    -- on /Wikipedia/.
    InstancePortInfo -> Maybe [Text]
cidrs :: Prelude.Maybe [Prelude.Text],
    -- | The common name of the port information.
    InstancePortInfo -> Maybe Text
commonName :: Prelude.Maybe Prelude.Text,
    -- | The first port in a range of open ports on an instance.
    --
    -- Allowed ports:
    --
    -- -   TCP and UDP - @0@ to @65535@
    --
    -- -   ICMP - The ICMP type for IPv4 addresses. For example, specify @8@ as
    --     the @fromPort@ (ICMP type), and @-1@ as the @toPort@ (ICMP code), to
    --     enable ICMP Ping. For more information, see
    --     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages Control Messages>
    --     on /Wikipedia/.
    --
    -- -   ICMPv6 - The ICMP type for IPv6 addresses. For example, specify
    --     @128@ as the @fromPort@ (ICMPv6 type), and @0@ as @toPort@ (ICMPv6
    --     code). For more information, see
    --     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6 Internet Control Message Protocol for IPv6>.
    InstancePortInfo -> Maybe Int
fromPort :: Prelude.Maybe Prelude.Int,
    -- | The IPv6 address, or range of IPv6 addresses (in CIDR notation) that are
    -- allowed to connect to an instance through the ports, and the protocol.
    -- Only devices with an IPv6 address can connect to an instance through
    -- IPv6; otherwise, IPv4 should be used.
    --
    -- The @cidrs@ parameter lists the IPv4 addresses that are allowed to
    -- connect to an instance.
    --
    -- For more information about CIDR block notation, see
    -- <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation Classless Inter-Domain Routing>
    -- on /Wikipedia/.
    InstancePortInfo -> Maybe [Text]
ipv6Cidrs :: Prelude.Maybe [Prelude.Text],
    -- | The IP protocol name.
    --
    -- The name can be one of the following:
    --
    -- -   @tcp@ - Transmission Control Protocol (TCP) provides reliable,
    --     ordered, and error-checked delivery of streamed data between
    --     applications running on hosts communicating by an IP network. If you
    --     have an application that doesn\'t require reliable data stream
    --     service, use UDP instead.
    --
    -- -   @all@ - All transport layer protocol types. For more general
    --     information, see
    --     <https://en.wikipedia.org/wiki/Transport_layer Transport layer> on
    --     /Wikipedia/.
    --
    -- -   @udp@ - With User Datagram Protocol (UDP), computer applications can
    --     send messages (or datagrams) to other hosts on an Internet Protocol
    --     (IP) network. Prior communications are not required to set up
    --     transmission channels or data paths. Applications that don\'t
    --     require reliable data stream service can use UDP, which provides a
    --     connectionless datagram service that emphasizes reduced latency over
    --     reliability. If you do require reliable data stream service, use TCP
    --     instead.
    --
    -- -   @icmp@ - Internet Control Message Protocol (ICMP) is used to send
    --     error messages and operational information indicating success or
    --     failure when communicating with an instance. For example, an error
    --     is indicated when an instance could not be reached. When you specify
    --     @icmp@ as the @protocol@, you must specify the ICMP type using the
    --     @fromPort@ parameter, and ICMP code using the @toPort@ parameter.
    InstancePortInfo -> Maybe NetworkProtocol
protocol :: Prelude.Maybe NetworkProtocol,
    -- | The last port in a range of open ports on an instance.
    --
    -- Allowed ports:
    --
    -- -   TCP and UDP - @0@ to @65535@
    --
    -- -   ICMP - The ICMP code for IPv4 addresses. For example, specify @8@ as
    --     the @fromPort@ (ICMP type), and @-1@ as the @toPort@ (ICMP code), to
    --     enable ICMP Ping. For more information, see
    --     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages Control Messages>
    --     on /Wikipedia/.
    --
    -- -   ICMPv6 - The ICMP code for IPv6 addresses. For example, specify
    --     @128@ as the @fromPort@ (ICMPv6 type), and @0@ as @toPort@ (ICMPv6
    --     code). For more information, see
    --     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6 Internet Control Message Protocol for IPv6>.
    InstancePortInfo -> Maybe Int
toPort :: Prelude.Maybe Prelude.Int
  }
  deriving (InstancePortInfo -> InstancePortInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstancePortInfo -> InstancePortInfo -> Bool
$c/= :: InstancePortInfo -> InstancePortInfo -> Bool
== :: InstancePortInfo -> InstancePortInfo -> Bool
$c== :: InstancePortInfo -> InstancePortInfo -> Bool
Prelude.Eq, ReadPrec [InstancePortInfo]
ReadPrec InstancePortInfo
Int -> ReadS InstancePortInfo
ReadS [InstancePortInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstancePortInfo]
$creadListPrec :: ReadPrec [InstancePortInfo]
readPrec :: ReadPrec InstancePortInfo
$creadPrec :: ReadPrec InstancePortInfo
readList :: ReadS [InstancePortInfo]
$creadList :: ReadS [InstancePortInfo]
readsPrec :: Int -> ReadS InstancePortInfo
$creadsPrec :: Int -> ReadS InstancePortInfo
Prelude.Read, Int -> InstancePortInfo -> ShowS
[InstancePortInfo] -> ShowS
InstancePortInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstancePortInfo] -> ShowS
$cshowList :: [InstancePortInfo] -> ShowS
show :: InstancePortInfo -> String
$cshow :: InstancePortInfo -> String
showsPrec :: Int -> InstancePortInfo -> ShowS
$cshowsPrec :: Int -> InstancePortInfo -> ShowS
Prelude.Show, forall x. Rep InstancePortInfo x -> InstancePortInfo
forall x. InstancePortInfo -> Rep InstancePortInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstancePortInfo x -> InstancePortInfo
$cfrom :: forall x. InstancePortInfo -> Rep InstancePortInfo x
Prelude.Generic)

-- |
-- Create a value of 'InstancePortInfo' 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:
--
-- 'accessDirection', 'instancePortInfo_accessDirection' - The access direction (@inbound@ or @outbound@).
--
-- Lightsail currently supports only @inbound@ access direction.
--
-- 'accessFrom', 'instancePortInfo_accessFrom' - The location from which access is allowed. For example,
-- @Anywhere (0.0.0.0\/0)@, or @Custom@ if a specific IP address or range
-- of IP addresses is allowed.
--
-- 'accessType', 'instancePortInfo_accessType' - The type of access (@Public@ or @Private@).
--
-- 'cidrListAliases', 'instancePortInfo_cidrListAliases' - An alias that defines access for a preconfigured range of IP addresses.
--
-- The only alias currently supported is @lightsail-connect@, which allows
-- IP addresses of the browser-based RDP\/SSH client in the Lightsail
-- console to connect to your instance.
--
-- 'cidrs', 'instancePortInfo_cidrs' - The IPv4 address, or range of IPv4 addresses (in CIDR notation) that are
-- allowed to connect to an instance through the ports, and the protocol.
--
-- The @ipv6Cidrs@ parameter lists the IPv6 addresses that are allowed to
-- connect to an instance.
--
-- For more information about CIDR block notation, see
-- <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation Classless Inter-Domain Routing>
-- on /Wikipedia/.
--
-- 'commonName', 'instancePortInfo_commonName' - The common name of the port information.
--
-- 'fromPort', 'instancePortInfo_fromPort' - The first port in a range of open ports on an instance.
--
-- Allowed ports:
--
-- -   TCP and UDP - @0@ to @65535@
--
-- -   ICMP - The ICMP type for IPv4 addresses. For example, specify @8@ as
--     the @fromPort@ (ICMP type), and @-1@ as the @toPort@ (ICMP code), to
--     enable ICMP Ping. For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages Control Messages>
--     on /Wikipedia/.
--
-- -   ICMPv6 - The ICMP type for IPv6 addresses. For example, specify
--     @128@ as the @fromPort@ (ICMPv6 type), and @0@ as @toPort@ (ICMPv6
--     code). For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6 Internet Control Message Protocol for IPv6>.
--
-- 'ipv6Cidrs', 'instancePortInfo_ipv6Cidrs' - The IPv6 address, or range of IPv6 addresses (in CIDR notation) that are
-- allowed to connect to an instance through the ports, and the protocol.
-- Only devices with an IPv6 address can connect to an instance through
-- IPv6; otherwise, IPv4 should be used.
--
-- The @cidrs@ parameter lists the IPv4 addresses that are allowed to
-- connect to an instance.
--
-- For more information about CIDR block notation, see
-- <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation Classless Inter-Domain Routing>
-- on /Wikipedia/.
--
-- 'protocol', 'instancePortInfo_protocol' - The IP protocol name.
--
-- The name can be one of the following:
--
-- -   @tcp@ - Transmission Control Protocol (TCP) provides reliable,
--     ordered, and error-checked delivery of streamed data between
--     applications running on hosts communicating by an IP network. If you
--     have an application that doesn\'t require reliable data stream
--     service, use UDP instead.
--
-- -   @all@ - All transport layer protocol types. For more general
--     information, see
--     <https://en.wikipedia.org/wiki/Transport_layer Transport layer> on
--     /Wikipedia/.
--
-- -   @udp@ - With User Datagram Protocol (UDP), computer applications can
--     send messages (or datagrams) to other hosts on an Internet Protocol
--     (IP) network. Prior communications are not required to set up
--     transmission channels or data paths. Applications that don\'t
--     require reliable data stream service can use UDP, which provides a
--     connectionless datagram service that emphasizes reduced latency over
--     reliability. If you do require reliable data stream service, use TCP
--     instead.
--
-- -   @icmp@ - Internet Control Message Protocol (ICMP) is used to send
--     error messages and operational information indicating success or
--     failure when communicating with an instance. For example, an error
--     is indicated when an instance could not be reached. When you specify
--     @icmp@ as the @protocol@, you must specify the ICMP type using the
--     @fromPort@ parameter, and ICMP code using the @toPort@ parameter.
--
-- 'toPort', 'instancePortInfo_toPort' - The last port in a range of open ports on an instance.
--
-- Allowed ports:
--
-- -   TCP and UDP - @0@ to @65535@
--
-- -   ICMP - The ICMP code for IPv4 addresses. For example, specify @8@ as
--     the @fromPort@ (ICMP type), and @-1@ as the @toPort@ (ICMP code), to
--     enable ICMP Ping. For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages Control Messages>
--     on /Wikipedia/.
--
-- -   ICMPv6 - The ICMP code for IPv6 addresses. For example, specify
--     @128@ as the @fromPort@ (ICMPv6 type), and @0@ as @toPort@ (ICMPv6
--     code). For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6 Internet Control Message Protocol for IPv6>.
newInstancePortInfo ::
  InstancePortInfo
newInstancePortInfo :: InstancePortInfo
newInstancePortInfo =
  InstancePortInfo'
    { $sel:accessDirection:InstancePortInfo' :: Maybe AccessDirection
accessDirection =
        forall a. Maybe a
Prelude.Nothing,
      $sel:accessFrom:InstancePortInfo' :: Maybe Text
accessFrom = forall a. Maybe a
Prelude.Nothing,
      $sel:accessType:InstancePortInfo' :: Maybe PortAccessType
accessType = forall a. Maybe a
Prelude.Nothing,
      $sel:cidrListAliases:InstancePortInfo' :: Maybe [Text]
cidrListAliases = forall a. Maybe a
Prelude.Nothing,
      $sel:cidrs:InstancePortInfo' :: Maybe [Text]
cidrs = forall a. Maybe a
Prelude.Nothing,
      $sel:commonName:InstancePortInfo' :: Maybe Text
commonName = forall a. Maybe a
Prelude.Nothing,
      $sel:fromPort:InstancePortInfo' :: Maybe Int
fromPort = forall a. Maybe a
Prelude.Nothing,
      $sel:ipv6Cidrs:InstancePortInfo' :: Maybe [Text]
ipv6Cidrs = forall a. Maybe a
Prelude.Nothing,
      $sel:protocol:InstancePortInfo' :: Maybe NetworkProtocol
protocol = forall a. Maybe a
Prelude.Nothing,
      $sel:toPort:InstancePortInfo' :: Maybe Int
toPort = forall a. Maybe a
Prelude.Nothing
    }

-- | The access direction (@inbound@ or @outbound@).
--
-- Lightsail currently supports only @inbound@ access direction.
instancePortInfo_accessDirection :: Lens.Lens' InstancePortInfo (Prelude.Maybe AccessDirection)
instancePortInfo_accessDirection :: Lens' InstancePortInfo (Maybe AccessDirection)
instancePortInfo_accessDirection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe AccessDirection
accessDirection :: Maybe AccessDirection
$sel:accessDirection:InstancePortInfo' :: InstancePortInfo -> Maybe AccessDirection
accessDirection} -> Maybe AccessDirection
accessDirection) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe AccessDirection
a -> InstancePortInfo
s {$sel:accessDirection:InstancePortInfo' :: Maybe AccessDirection
accessDirection = Maybe AccessDirection
a} :: InstancePortInfo)

-- | The location from which access is allowed. For example,
-- @Anywhere (0.0.0.0\/0)@, or @Custom@ if a specific IP address or range
-- of IP addresses is allowed.
instancePortInfo_accessFrom :: Lens.Lens' InstancePortInfo (Prelude.Maybe Prelude.Text)
instancePortInfo_accessFrom :: Lens' InstancePortInfo (Maybe Text)
instancePortInfo_accessFrom = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe Text
accessFrom :: Maybe Text
$sel:accessFrom:InstancePortInfo' :: InstancePortInfo -> Maybe Text
accessFrom} -> Maybe Text
accessFrom) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe Text
a -> InstancePortInfo
s {$sel:accessFrom:InstancePortInfo' :: Maybe Text
accessFrom = Maybe Text
a} :: InstancePortInfo)

-- | The type of access (@Public@ or @Private@).
instancePortInfo_accessType :: Lens.Lens' InstancePortInfo (Prelude.Maybe PortAccessType)
instancePortInfo_accessType :: Lens' InstancePortInfo (Maybe PortAccessType)
instancePortInfo_accessType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe PortAccessType
accessType :: Maybe PortAccessType
$sel:accessType:InstancePortInfo' :: InstancePortInfo -> Maybe PortAccessType
accessType} -> Maybe PortAccessType
accessType) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe PortAccessType
a -> InstancePortInfo
s {$sel:accessType:InstancePortInfo' :: Maybe PortAccessType
accessType = Maybe PortAccessType
a} :: InstancePortInfo)

-- | An alias that defines access for a preconfigured range of IP addresses.
--
-- The only alias currently supported is @lightsail-connect@, which allows
-- IP addresses of the browser-based RDP\/SSH client in the Lightsail
-- console to connect to your instance.
instancePortInfo_cidrListAliases :: Lens.Lens' InstancePortInfo (Prelude.Maybe [Prelude.Text])
instancePortInfo_cidrListAliases :: Lens' InstancePortInfo (Maybe [Text])
instancePortInfo_cidrListAliases = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe [Text]
cidrListAliases :: Maybe [Text]
$sel:cidrListAliases:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
cidrListAliases} -> Maybe [Text]
cidrListAliases) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe [Text]
a -> InstancePortInfo
s {$sel:cidrListAliases:InstancePortInfo' :: Maybe [Text]
cidrListAliases = Maybe [Text]
a} :: InstancePortInfo) 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 IPv4 address, or range of IPv4 addresses (in CIDR notation) that are
-- allowed to connect to an instance through the ports, and the protocol.
--
-- The @ipv6Cidrs@ parameter lists the IPv6 addresses that are allowed to
-- connect to an instance.
--
-- For more information about CIDR block notation, see
-- <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation Classless Inter-Domain Routing>
-- on /Wikipedia/.
instancePortInfo_cidrs :: Lens.Lens' InstancePortInfo (Prelude.Maybe [Prelude.Text])
instancePortInfo_cidrs :: Lens' InstancePortInfo (Maybe [Text])
instancePortInfo_cidrs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe [Text]
cidrs :: Maybe [Text]
$sel:cidrs:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
cidrs} -> Maybe [Text]
cidrs) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe [Text]
a -> InstancePortInfo
s {$sel:cidrs:InstancePortInfo' :: Maybe [Text]
cidrs = Maybe [Text]
a} :: InstancePortInfo) 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 common name of the port information.
instancePortInfo_commonName :: Lens.Lens' InstancePortInfo (Prelude.Maybe Prelude.Text)
instancePortInfo_commonName :: Lens' InstancePortInfo (Maybe Text)
instancePortInfo_commonName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe Text
commonName :: Maybe Text
$sel:commonName:InstancePortInfo' :: InstancePortInfo -> Maybe Text
commonName} -> Maybe Text
commonName) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe Text
a -> InstancePortInfo
s {$sel:commonName:InstancePortInfo' :: Maybe Text
commonName = Maybe Text
a} :: InstancePortInfo)

-- | The first port in a range of open ports on an instance.
--
-- Allowed ports:
--
-- -   TCP and UDP - @0@ to @65535@
--
-- -   ICMP - The ICMP type for IPv4 addresses. For example, specify @8@ as
--     the @fromPort@ (ICMP type), and @-1@ as the @toPort@ (ICMP code), to
--     enable ICMP Ping. For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages Control Messages>
--     on /Wikipedia/.
--
-- -   ICMPv6 - The ICMP type for IPv6 addresses. For example, specify
--     @128@ as the @fromPort@ (ICMPv6 type), and @0@ as @toPort@ (ICMPv6
--     code). For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6 Internet Control Message Protocol for IPv6>.
instancePortInfo_fromPort :: Lens.Lens' InstancePortInfo (Prelude.Maybe Prelude.Int)
instancePortInfo_fromPort :: Lens' InstancePortInfo (Maybe Int)
instancePortInfo_fromPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe Int
fromPort :: Maybe Int
$sel:fromPort:InstancePortInfo' :: InstancePortInfo -> Maybe Int
fromPort} -> Maybe Int
fromPort) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe Int
a -> InstancePortInfo
s {$sel:fromPort:InstancePortInfo' :: Maybe Int
fromPort = Maybe Int
a} :: InstancePortInfo)

-- | The IPv6 address, or range of IPv6 addresses (in CIDR notation) that are
-- allowed to connect to an instance through the ports, and the protocol.
-- Only devices with an IPv6 address can connect to an instance through
-- IPv6; otherwise, IPv4 should be used.
--
-- The @cidrs@ parameter lists the IPv4 addresses that are allowed to
-- connect to an instance.
--
-- For more information about CIDR block notation, see
-- <https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing#CIDR_notation Classless Inter-Domain Routing>
-- on /Wikipedia/.
instancePortInfo_ipv6Cidrs :: Lens.Lens' InstancePortInfo (Prelude.Maybe [Prelude.Text])
instancePortInfo_ipv6Cidrs :: Lens' InstancePortInfo (Maybe [Text])
instancePortInfo_ipv6Cidrs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe [Text]
ipv6Cidrs :: Maybe [Text]
$sel:ipv6Cidrs:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
ipv6Cidrs} -> Maybe [Text]
ipv6Cidrs) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe [Text]
a -> InstancePortInfo
s {$sel:ipv6Cidrs:InstancePortInfo' :: Maybe [Text]
ipv6Cidrs = Maybe [Text]
a} :: InstancePortInfo) 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 IP protocol name.
--
-- The name can be one of the following:
--
-- -   @tcp@ - Transmission Control Protocol (TCP) provides reliable,
--     ordered, and error-checked delivery of streamed data between
--     applications running on hosts communicating by an IP network. If you
--     have an application that doesn\'t require reliable data stream
--     service, use UDP instead.
--
-- -   @all@ - All transport layer protocol types. For more general
--     information, see
--     <https://en.wikipedia.org/wiki/Transport_layer Transport layer> on
--     /Wikipedia/.
--
-- -   @udp@ - With User Datagram Protocol (UDP), computer applications can
--     send messages (or datagrams) to other hosts on an Internet Protocol
--     (IP) network. Prior communications are not required to set up
--     transmission channels or data paths. Applications that don\'t
--     require reliable data stream service can use UDP, which provides a
--     connectionless datagram service that emphasizes reduced latency over
--     reliability. If you do require reliable data stream service, use TCP
--     instead.
--
-- -   @icmp@ - Internet Control Message Protocol (ICMP) is used to send
--     error messages and operational information indicating success or
--     failure when communicating with an instance. For example, an error
--     is indicated when an instance could not be reached. When you specify
--     @icmp@ as the @protocol@, you must specify the ICMP type using the
--     @fromPort@ parameter, and ICMP code using the @toPort@ parameter.
instancePortInfo_protocol :: Lens.Lens' InstancePortInfo (Prelude.Maybe NetworkProtocol)
instancePortInfo_protocol :: Lens' InstancePortInfo (Maybe NetworkProtocol)
instancePortInfo_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe NetworkProtocol
protocol :: Maybe NetworkProtocol
$sel:protocol:InstancePortInfo' :: InstancePortInfo -> Maybe NetworkProtocol
protocol} -> Maybe NetworkProtocol
protocol) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe NetworkProtocol
a -> InstancePortInfo
s {$sel:protocol:InstancePortInfo' :: Maybe NetworkProtocol
protocol = Maybe NetworkProtocol
a} :: InstancePortInfo)

-- | The last port in a range of open ports on an instance.
--
-- Allowed ports:
--
-- -   TCP and UDP - @0@ to @65535@
--
-- -   ICMP - The ICMP code for IPv4 addresses. For example, specify @8@ as
--     the @fromPort@ (ICMP type), and @-1@ as the @toPort@ (ICMP code), to
--     enable ICMP Ping. For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol#Control_messages Control Messages>
--     on /Wikipedia/.
--
-- -   ICMPv6 - The ICMP code for IPv6 addresses. For example, specify
--     @128@ as the @fromPort@ (ICMPv6 type), and @0@ as @toPort@ (ICMPv6
--     code). For more information, see
--     <https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol_for_IPv6 Internet Control Message Protocol for IPv6>.
instancePortInfo_toPort :: Lens.Lens' InstancePortInfo (Prelude.Maybe Prelude.Int)
instancePortInfo_toPort :: Lens' InstancePortInfo (Maybe Int)
instancePortInfo_toPort = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstancePortInfo' {Maybe Int
toPort :: Maybe Int
$sel:toPort:InstancePortInfo' :: InstancePortInfo -> Maybe Int
toPort} -> Maybe Int
toPort) (\s :: InstancePortInfo
s@InstancePortInfo' {} Maybe Int
a -> InstancePortInfo
s {$sel:toPort:InstancePortInfo' :: Maybe Int
toPort = Maybe Int
a} :: InstancePortInfo)

instance Data.FromJSON InstancePortInfo where
  parseJSON :: Value -> Parser InstancePortInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InstancePortInfo"
      ( \Object
x ->
          Maybe AccessDirection
-> Maybe Text
-> Maybe PortAccessType
-> Maybe [Text]
-> Maybe [Text]
-> Maybe Text
-> Maybe Int
-> Maybe [Text]
-> Maybe NetworkProtocol
-> Maybe Int
-> InstancePortInfo
InstancePortInfo'
            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
"accessDirection")
            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
"accessFrom")
            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
"accessType")
            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
"cidrListAliases"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"cidrs" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"commonName")
            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
"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
"ipv6Cidrs" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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 InstancePortInfo where
  hashWithSalt :: Int -> InstancePortInfo -> Int
hashWithSalt Int
_salt InstancePortInfo' {Maybe Int
Maybe [Text]
Maybe Text
Maybe AccessDirection
Maybe NetworkProtocol
Maybe PortAccessType
toPort :: Maybe Int
protocol :: Maybe NetworkProtocol
ipv6Cidrs :: Maybe [Text]
fromPort :: Maybe Int
commonName :: Maybe Text
cidrs :: Maybe [Text]
cidrListAliases :: Maybe [Text]
accessType :: Maybe PortAccessType
accessFrom :: Maybe Text
accessDirection :: Maybe AccessDirection
$sel:toPort:InstancePortInfo' :: InstancePortInfo -> Maybe Int
$sel:protocol:InstancePortInfo' :: InstancePortInfo -> Maybe NetworkProtocol
$sel:ipv6Cidrs:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
$sel:fromPort:InstancePortInfo' :: InstancePortInfo -> Maybe Int
$sel:commonName:InstancePortInfo' :: InstancePortInfo -> Maybe Text
$sel:cidrs:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
$sel:cidrListAliases:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
$sel:accessType:InstancePortInfo' :: InstancePortInfo -> Maybe PortAccessType
$sel:accessFrom:InstancePortInfo' :: InstancePortInfo -> Maybe Text
$sel:accessDirection:InstancePortInfo' :: InstancePortInfo -> Maybe AccessDirection
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccessDirection
accessDirection
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accessFrom
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PortAccessType
accessType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
cidrListAliases
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
cidrs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
commonName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
fromPort
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ipv6Cidrs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NetworkProtocol
protocol
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
toPort

instance Prelude.NFData InstancePortInfo where
  rnf :: InstancePortInfo -> ()
rnf InstancePortInfo' {Maybe Int
Maybe [Text]
Maybe Text
Maybe AccessDirection
Maybe NetworkProtocol
Maybe PortAccessType
toPort :: Maybe Int
protocol :: Maybe NetworkProtocol
ipv6Cidrs :: Maybe [Text]
fromPort :: Maybe Int
commonName :: Maybe Text
cidrs :: Maybe [Text]
cidrListAliases :: Maybe [Text]
accessType :: Maybe PortAccessType
accessFrom :: Maybe Text
accessDirection :: Maybe AccessDirection
$sel:toPort:InstancePortInfo' :: InstancePortInfo -> Maybe Int
$sel:protocol:InstancePortInfo' :: InstancePortInfo -> Maybe NetworkProtocol
$sel:ipv6Cidrs:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
$sel:fromPort:InstancePortInfo' :: InstancePortInfo -> Maybe Int
$sel:commonName:InstancePortInfo' :: InstancePortInfo -> Maybe Text
$sel:cidrs:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
$sel:cidrListAliases:InstancePortInfo' :: InstancePortInfo -> Maybe [Text]
$sel:accessType:InstancePortInfo' :: InstancePortInfo -> Maybe PortAccessType
$sel:accessFrom:InstancePortInfo' :: InstancePortInfo -> Maybe Text
$sel:accessDirection:InstancePortInfo' :: InstancePortInfo -> Maybe AccessDirection
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AccessDirection
accessDirection
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accessFrom
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PortAccessType
accessType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
cidrListAliases
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
cidrs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
commonName
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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]
ipv6Cidrs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NetworkProtocol
protocol
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
toPort