{-# 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.PublicIpv4PoolRange
-- 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.PublicIpv4PoolRange 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 qualified Amazonka.Prelude as Prelude

-- | Describes an address range of an IPv4 address pool.
--
-- /See:/ 'newPublicIpv4PoolRange' smart constructor.
data PublicIpv4PoolRange = PublicIpv4PoolRange'
  { -- | The number of addresses in the range.
    PublicIpv4PoolRange -> Maybe Int
addressCount :: Prelude.Maybe Prelude.Int,
    -- | The number of available addresses in the range.
    PublicIpv4PoolRange -> Maybe Int
availableAddressCount :: Prelude.Maybe Prelude.Int,
    -- | The first IP address in the range.
    PublicIpv4PoolRange -> Maybe Text
firstAddress :: Prelude.Maybe Prelude.Text,
    -- | The last IP address in the range.
    PublicIpv4PoolRange -> Maybe Text
lastAddress :: Prelude.Maybe Prelude.Text
  }
  deriving (PublicIpv4PoolRange -> PublicIpv4PoolRange -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PublicIpv4PoolRange -> PublicIpv4PoolRange -> Bool
$c/= :: PublicIpv4PoolRange -> PublicIpv4PoolRange -> Bool
== :: PublicIpv4PoolRange -> PublicIpv4PoolRange -> Bool
$c== :: PublicIpv4PoolRange -> PublicIpv4PoolRange -> Bool
Prelude.Eq, ReadPrec [PublicIpv4PoolRange]
ReadPrec PublicIpv4PoolRange
Int -> ReadS PublicIpv4PoolRange
ReadS [PublicIpv4PoolRange]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PublicIpv4PoolRange]
$creadListPrec :: ReadPrec [PublicIpv4PoolRange]
readPrec :: ReadPrec PublicIpv4PoolRange
$creadPrec :: ReadPrec PublicIpv4PoolRange
readList :: ReadS [PublicIpv4PoolRange]
$creadList :: ReadS [PublicIpv4PoolRange]
readsPrec :: Int -> ReadS PublicIpv4PoolRange
$creadsPrec :: Int -> ReadS PublicIpv4PoolRange
Prelude.Read, Int -> PublicIpv4PoolRange -> ShowS
[PublicIpv4PoolRange] -> ShowS
PublicIpv4PoolRange -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PublicIpv4PoolRange] -> ShowS
$cshowList :: [PublicIpv4PoolRange] -> ShowS
show :: PublicIpv4PoolRange -> String
$cshow :: PublicIpv4PoolRange -> String
showsPrec :: Int -> PublicIpv4PoolRange -> ShowS
$cshowsPrec :: Int -> PublicIpv4PoolRange -> ShowS
Prelude.Show, forall x. Rep PublicIpv4PoolRange x -> PublicIpv4PoolRange
forall x. PublicIpv4PoolRange -> Rep PublicIpv4PoolRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PublicIpv4PoolRange x -> PublicIpv4PoolRange
$cfrom :: forall x. PublicIpv4PoolRange -> Rep PublicIpv4PoolRange x
Prelude.Generic)

-- |
-- Create a value of 'PublicIpv4PoolRange' 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:
--
-- 'addressCount', 'publicIpv4PoolRange_addressCount' - The number of addresses in the range.
--
-- 'availableAddressCount', 'publicIpv4PoolRange_availableAddressCount' - The number of available addresses in the range.
--
-- 'firstAddress', 'publicIpv4PoolRange_firstAddress' - The first IP address in the range.
--
-- 'lastAddress', 'publicIpv4PoolRange_lastAddress' - The last IP address in the range.
newPublicIpv4PoolRange ::
  PublicIpv4PoolRange
newPublicIpv4PoolRange :: PublicIpv4PoolRange
newPublicIpv4PoolRange =
  PublicIpv4PoolRange'
    { $sel:addressCount:PublicIpv4PoolRange' :: Maybe Int
addressCount =
        forall a. Maybe a
Prelude.Nothing,
      $sel:availableAddressCount:PublicIpv4PoolRange' :: Maybe Int
availableAddressCount = forall a. Maybe a
Prelude.Nothing,
      $sel:firstAddress:PublicIpv4PoolRange' :: Maybe Text
firstAddress = forall a. Maybe a
Prelude.Nothing,
      $sel:lastAddress:PublicIpv4PoolRange' :: Maybe Text
lastAddress = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of addresses in the range.
publicIpv4PoolRange_addressCount :: Lens.Lens' PublicIpv4PoolRange (Prelude.Maybe Prelude.Int)
publicIpv4PoolRange_addressCount :: Lens' PublicIpv4PoolRange (Maybe Int)
publicIpv4PoolRange_addressCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicIpv4PoolRange' {Maybe Int
addressCount :: Maybe Int
$sel:addressCount:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Int
addressCount} -> Maybe Int
addressCount) (\s :: PublicIpv4PoolRange
s@PublicIpv4PoolRange' {} Maybe Int
a -> PublicIpv4PoolRange
s {$sel:addressCount:PublicIpv4PoolRange' :: Maybe Int
addressCount = Maybe Int
a} :: PublicIpv4PoolRange)

-- | The number of available addresses in the range.
publicIpv4PoolRange_availableAddressCount :: Lens.Lens' PublicIpv4PoolRange (Prelude.Maybe Prelude.Int)
publicIpv4PoolRange_availableAddressCount :: Lens' PublicIpv4PoolRange (Maybe Int)
publicIpv4PoolRange_availableAddressCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicIpv4PoolRange' {Maybe Int
availableAddressCount :: Maybe Int
$sel:availableAddressCount:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Int
availableAddressCount} -> Maybe Int
availableAddressCount) (\s :: PublicIpv4PoolRange
s@PublicIpv4PoolRange' {} Maybe Int
a -> PublicIpv4PoolRange
s {$sel:availableAddressCount:PublicIpv4PoolRange' :: Maybe Int
availableAddressCount = Maybe Int
a} :: PublicIpv4PoolRange)

-- | The first IP address in the range.
publicIpv4PoolRange_firstAddress :: Lens.Lens' PublicIpv4PoolRange (Prelude.Maybe Prelude.Text)
publicIpv4PoolRange_firstAddress :: Lens' PublicIpv4PoolRange (Maybe Text)
publicIpv4PoolRange_firstAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicIpv4PoolRange' {Maybe Text
firstAddress :: Maybe Text
$sel:firstAddress:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Text
firstAddress} -> Maybe Text
firstAddress) (\s :: PublicIpv4PoolRange
s@PublicIpv4PoolRange' {} Maybe Text
a -> PublicIpv4PoolRange
s {$sel:firstAddress:PublicIpv4PoolRange' :: Maybe Text
firstAddress = Maybe Text
a} :: PublicIpv4PoolRange)

-- | The last IP address in the range.
publicIpv4PoolRange_lastAddress :: Lens.Lens' PublicIpv4PoolRange (Prelude.Maybe Prelude.Text)
publicIpv4PoolRange_lastAddress :: Lens' PublicIpv4PoolRange (Maybe Text)
publicIpv4PoolRange_lastAddress = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PublicIpv4PoolRange' {Maybe Text
lastAddress :: Maybe Text
$sel:lastAddress:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Text
lastAddress} -> Maybe Text
lastAddress) (\s :: PublicIpv4PoolRange
s@PublicIpv4PoolRange' {} Maybe Text
a -> PublicIpv4PoolRange
s {$sel:lastAddress:PublicIpv4PoolRange' :: Maybe Text
lastAddress = Maybe Text
a} :: PublicIpv4PoolRange)

instance Data.FromXML PublicIpv4PoolRange where
  parseXML :: [Node] -> Either String PublicIpv4PoolRange
parseXML [Node]
x =
    Maybe Int
-> Maybe Int -> Maybe Text -> Maybe Text -> PublicIpv4PoolRange
PublicIpv4PoolRange'
      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
"addressCount")
      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
"availableAddressCount")
      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
"firstAddress")
      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
"lastAddress")

instance Prelude.Hashable PublicIpv4PoolRange where
  hashWithSalt :: Int -> PublicIpv4PoolRange -> Int
hashWithSalt Int
_salt PublicIpv4PoolRange' {Maybe Int
Maybe Text
lastAddress :: Maybe Text
firstAddress :: Maybe Text
availableAddressCount :: Maybe Int
addressCount :: Maybe Int
$sel:lastAddress:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Text
$sel:firstAddress:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Text
$sel:availableAddressCount:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Int
$sel:addressCount:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
addressCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
availableAddressCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
firstAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
lastAddress

instance Prelude.NFData PublicIpv4PoolRange where
  rnf :: PublicIpv4PoolRange -> ()
rnf PublicIpv4PoolRange' {Maybe Int
Maybe Text
lastAddress :: Maybe Text
firstAddress :: Maybe Text
availableAddressCount :: Maybe Int
addressCount :: Maybe Int
$sel:lastAddress:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Text
$sel:firstAddress:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Text
$sel:availableAddressCount:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Int
$sel:addressCount:PublicIpv4PoolRange' :: PublicIpv4PoolRange -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
addressCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
availableAddressCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
firstAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
lastAddress