{-# 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.IpamPoolAllocation
-- 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.IpamPoolAllocation 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.IpamPoolAllocationResourceType
import qualified Amazonka.Prelude as Prelude

-- | In IPAM, an allocation is a CIDR assignment from an IPAM pool to another
-- resource or IPAM pool.
--
-- /See:/ 'newIpamPoolAllocation' smart constructor.
data IpamPoolAllocation = IpamPoolAllocation'
  { -- | The CIDR for the allocation. A CIDR is a representation of an IP address
    -- and its associated network mask (or netmask) and refers to a range of IP
    -- addresses. An IPv4 CIDR example is @10.24.34.0\/23@. An IPv6 CIDR
    -- example is @2001:DB8::\/32@.
    IpamPoolAllocation -> Maybe Text
cidr :: Prelude.Maybe Prelude.Text,
    -- | A description of the pool allocation.
    IpamPoolAllocation -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The ID of an allocation.
    IpamPoolAllocation -> Maybe Text
ipamPoolAllocationId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the resource.
    IpamPoolAllocation -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The owner of the resource.
    IpamPoolAllocation -> Maybe Text
resourceOwner :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region of the resource.
    IpamPoolAllocation -> Maybe Text
resourceRegion :: Prelude.Maybe Prelude.Text,
    -- | The type of the resource.
    IpamPoolAllocation -> Maybe IpamPoolAllocationResourceType
resourceType :: Prelude.Maybe IpamPoolAllocationResourceType
  }
  deriving (IpamPoolAllocation -> IpamPoolAllocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IpamPoolAllocation -> IpamPoolAllocation -> Bool
$c/= :: IpamPoolAllocation -> IpamPoolAllocation -> Bool
== :: IpamPoolAllocation -> IpamPoolAllocation -> Bool
$c== :: IpamPoolAllocation -> IpamPoolAllocation -> Bool
Prelude.Eq, ReadPrec [IpamPoolAllocation]
ReadPrec IpamPoolAllocation
Int -> ReadS IpamPoolAllocation
ReadS [IpamPoolAllocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IpamPoolAllocation]
$creadListPrec :: ReadPrec [IpamPoolAllocation]
readPrec :: ReadPrec IpamPoolAllocation
$creadPrec :: ReadPrec IpamPoolAllocation
readList :: ReadS [IpamPoolAllocation]
$creadList :: ReadS [IpamPoolAllocation]
readsPrec :: Int -> ReadS IpamPoolAllocation
$creadsPrec :: Int -> ReadS IpamPoolAllocation
Prelude.Read, Int -> IpamPoolAllocation -> ShowS
[IpamPoolAllocation] -> ShowS
IpamPoolAllocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IpamPoolAllocation] -> ShowS
$cshowList :: [IpamPoolAllocation] -> ShowS
show :: IpamPoolAllocation -> String
$cshow :: IpamPoolAllocation -> String
showsPrec :: Int -> IpamPoolAllocation -> ShowS
$cshowsPrec :: Int -> IpamPoolAllocation -> ShowS
Prelude.Show, forall x. Rep IpamPoolAllocation x -> IpamPoolAllocation
forall x. IpamPoolAllocation -> Rep IpamPoolAllocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpamPoolAllocation x -> IpamPoolAllocation
$cfrom :: forall x. IpamPoolAllocation -> Rep IpamPoolAllocation x
Prelude.Generic)

-- |
-- Create a value of 'IpamPoolAllocation' 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:
--
-- 'cidr', 'ipamPoolAllocation_cidr' - The CIDR for the allocation. A CIDR is a representation of an IP address
-- and its associated network mask (or netmask) and refers to a range of IP
-- addresses. An IPv4 CIDR example is @10.24.34.0\/23@. An IPv6 CIDR
-- example is @2001:DB8::\/32@.
--
-- 'description', 'ipamPoolAllocation_description' - A description of the pool allocation.
--
-- 'ipamPoolAllocationId', 'ipamPoolAllocation_ipamPoolAllocationId' - The ID of an allocation.
--
-- 'resourceId', 'ipamPoolAllocation_resourceId' - The ID of the resource.
--
-- 'resourceOwner', 'ipamPoolAllocation_resourceOwner' - The owner of the resource.
--
-- 'resourceRegion', 'ipamPoolAllocation_resourceRegion' - The Amazon Web Services Region of the resource.
--
-- 'resourceType', 'ipamPoolAllocation_resourceType' - The type of the resource.
newIpamPoolAllocation ::
  IpamPoolAllocation
newIpamPoolAllocation :: IpamPoolAllocation
newIpamPoolAllocation =
  IpamPoolAllocation'
    { $sel:cidr:IpamPoolAllocation' :: Maybe Text
cidr = forall a. Maybe a
Prelude.Nothing,
      $sel:description:IpamPoolAllocation' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:ipamPoolAllocationId:IpamPoolAllocation' :: Maybe Text
ipamPoolAllocationId = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceId:IpamPoolAllocation' :: Maybe Text
resourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceOwner:IpamPoolAllocation' :: Maybe Text
resourceOwner = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceRegion:IpamPoolAllocation' :: Maybe Text
resourceRegion = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:IpamPoolAllocation' :: Maybe IpamPoolAllocationResourceType
resourceType = forall a. Maybe a
Prelude.Nothing
    }

-- | The CIDR for the allocation. A CIDR is a representation of an IP address
-- and its associated network mask (or netmask) and refers to a range of IP
-- addresses. An IPv4 CIDR example is @10.24.34.0\/23@. An IPv6 CIDR
-- example is @2001:DB8::\/32@.
ipamPoolAllocation_cidr :: Lens.Lens' IpamPoolAllocation (Prelude.Maybe Prelude.Text)
ipamPoolAllocation_cidr :: Lens' IpamPoolAllocation (Maybe Text)
ipamPoolAllocation_cidr = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpamPoolAllocation' {Maybe Text
cidr :: Maybe Text
$sel:cidr:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
cidr} -> Maybe Text
cidr) (\s :: IpamPoolAllocation
s@IpamPoolAllocation' {} Maybe Text
a -> IpamPoolAllocation
s {$sel:cidr:IpamPoolAllocation' :: Maybe Text
cidr = Maybe Text
a} :: IpamPoolAllocation)

-- | A description of the pool allocation.
ipamPoolAllocation_description :: Lens.Lens' IpamPoolAllocation (Prelude.Maybe Prelude.Text)
ipamPoolAllocation_description :: Lens' IpamPoolAllocation (Maybe Text)
ipamPoolAllocation_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpamPoolAllocation' {Maybe Text
description :: Maybe Text
$sel:description:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
description} -> Maybe Text
description) (\s :: IpamPoolAllocation
s@IpamPoolAllocation' {} Maybe Text
a -> IpamPoolAllocation
s {$sel:description:IpamPoolAllocation' :: Maybe Text
description = Maybe Text
a} :: IpamPoolAllocation)

-- | The ID of an allocation.
ipamPoolAllocation_ipamPoolAllocationId :: Lens.Lens' IpamPoolAllocation (Prelude.Maybe Prelude.Text)
ipamPoolAllocation_ipamPoolAllocationId :: Lens' IpamPoolAllocation (Maybe Text)
ipamPoolAllocation_ipamPoolAllocationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpamPoolAllocation' {Maybe Text
ipamPoolAllocationId :: Maybe Text
$sel:ipamPoolAllocationId:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
ipamPoolAllocationId} -> Maybe Text
ipamPoolAllocationId) (\s :: IpamPoolAllocation
s@IpamPoolAllocation' {} Maybe Text
a -> IpamPoolAllocation
s {$sel:ipamPoolAllocationId:IpamPoolAllocation' :: Maybe Text
ipamPoolAllocationId = Maybe Text
a} :: IpamPoolAllocation)

-- | The ID of the resource.
ipamPoolAllocation_resourceId :: Lens.Lens' IpamPoolAllocation (Prelude.Maybe Prelude.Text)
ipamPoolAllocation_resourceId :: Lens' IpamPoolAllocation (Maybe Text)
ipamPoolAllocation_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpamPoolAllocation' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: IpamPoolAllocation
s@IpamPoolAllocation' {} Maybe Text
a -> IpamPoolAllocation
s {$sel:resourceId:IpamPoolAllocation' :: Maybe Text
resourceId = Maybe Text
a} :: IpamPoolAllocation)

-- | The owner of the resource.
ipamPoolAllocation_resourceOwner :: Lens.Lens' IpamPoolAllocation (Prelude.Maybe Prelude.Text)
ipamPoolAllocation_resourceOwner :: Lens' IpamPoolAllocation (Maybe Text)
ipamPoolAllocation_resourceOwner = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpamPoolAllocation' {Maybe Text
resourceOwner :: Maybe Text
$sel:resourceOwner:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
resourceOwner} -> Maybe Text
resourceOwner) (\s :: IpamPoolAllocation
s@IpamPoolAllocation' {} Maybe Text
a -> IpamPoolAllocation
s {$sel:resourceOwner:IpamPoolAllocation' :: Maybe Text
resourceOwner = Maybe Text
a} :: IpamPoolAllocation)

-- | The Amazon Web Services Region of the resource.
ipamPoolAllocation_resourceRegion :: Lens.Lens' IpamPoolAllocation (Prelude.Maybe Prelude.Text)
ipamPoolAllocation_resourceRegion :: Lens' IpamPoolAllocation (Maybe Text)
ipamPoolAllocation_resourceRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpamPoolAllocation' {Maybe Text
resourceRegion :: Maybe Text
$sel:resourceRegion:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
resourceRegion} -> Maybe Text
resourceRegion) (\s :: IpamPoolAllocation
s@IpamPoolAllocation' {} Maybe Text
a -> IpamPoolAllocation
s {$sel:resourceRegion:IpamPoolAllocation' :: Maybe Text
resourceRegion = Maybe Text
a} :: IpamPoolAllocation)

-- | The type of the resource.
ipamPoolAllocation_resourceType :: Lens.Lens' IpamPoolAllocation (Prelude.Maybe IpamPoolAllocationResourceType)
ipamPoolAllocation_resourceType :: Lens' IpamPoolAllocation (Maybe IpamPoolAllocationResourceType)
ipamPoolAllocation_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpamPoolAllocation' {Maybe IpamPoolAllocationResourceType
resourceType :: Maybe IpamPoolAllocationResourceType
$sel:resourceType:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe IpamPoolAllocationResourceType
resourceType} -> Maybe IpamPoolAllocationResourceType
resourceType) (\s :: IpamPoolAllocation
s@IpamPoolAllocation' {} Maybe IpamPoolAllocationResourceType
a -> IpamPoolAllocation
s {$sel:resourceType:IpamPoolAllocation' :: Maybe IpamPoolAllocationResourceType
resourceType = Maybe IpamPoolAllocationResourceType
a} :: IpamPoolAllocation)

instance Data.FromXML IpamPoolAllocation where
  parseXML :: [Node] -> Either String IpamPoolAllocation
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe IpamPoolAllocationResourceType
-> IpamPoolAllocation
IpamPoolAllocation'
      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
"cidr")
      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
"description")
      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
"ipamPoolAllocationId")
      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
"resourceId")
      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
"resourceOwner")
      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
"resourceRegion")
      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
"resourceType")

instance Prelude.Hashable IpamPoolAllocation where
  hashWithSalt :: Int -> IpamPoolAllocation -> Int
hashWithSalt Int
_salt IpamPoolAllocation' {Maybe Text
Maybe IpamPoolAllocationResourceType
resourceType :: Maybe IpamPoolAllocationResourceType
resourceRegion :: Maybe Text
resourceOwner :: Maybe Text
resourceId :: Maybe Text
ipamPoolAllocationId :: Maybe Text
description :: Maybe Text
cidr :: Maybe Text
$sel:resourceType:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe IpamPoolAllocationResourceType
$sel:resourceRegion:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:resourceOwner:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:resourceId:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:ipamPoolAllocationId:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:description:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:cidr:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
cidr
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ipamPoolAllocationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceOwner
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceRegion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IpamPoolAllocationResourceType
resourceType

instance Prelude.NFData IpamPoolAllocation where
  rnf :: IpamPoolAllocation -> ()
rnf IpamPoolAllocation' {Maybe Text
Maybe IpamPoolAllocationResourceType
resourceType :: Maybe IpamPoolAllocationResourceType
resourceRegion :: Maybe Text
resourceOwner :: Maybe Text
resourceId :: Maybe Text
ipamPoolAllocationId :: Maybe Text
description :: Maybe Text
cidr :: Maybe Text
$sel:resourceType:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe IpamPoolAllocationResourceType
$sel:resourceRegion:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:resourceOwner:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:resourceId:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:ipamPoolAllocationId:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:description:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
$sel:cidr:IpamPoolAllocation' :: IpamPoolAllocation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cidr
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ipamPoolAllocationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceOwner
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceRegion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IpamPoolAllocationResourceType
resourceType