{-# 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.NetworkFirewall.Types.CIDRSummary
-- 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.NetworkFirewall.Types.CIDRSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkFirewall.Types.IPSetMetadata
import qualified Amazonka.Prelude as Prelude

-- | Summarizes the CIDR blocks used by the IP set references in a firewall.
-- Network Firewall calculates the number of CIDRs by taking an aggregated
-- count of all CIDRs used by the IP sets you are referencing.
--
-- /See:/ 'newCIDRSummary' smart constructor.
data CIDRSummary = CIDRSummary'
  { -- | The number of CIDR blocks available for use by the IP set references in
    -- a firewall.
    CIDRSummary -> Maybe Natural
availableCIDRCount :: Prelude.Maybe Prelude.Natural,
    -- | The list of the IP set references used by a firewall.
    CIDRSummary -> Maybe (HashMap Text IPSetMetadata)
iPSetReferences :: Prelude.Maybe (Prelude.HashMap Prelude.Text IPSetMetadata),
    -- | The number of CIDR blocks used by the IP set references in a firewall.
    CIDRSummary -> Maybe Natural
utilizedCIDRCount :: Prelude.Maybe Prelude.Natural
  }
  deriving (CIDRSummary -> CIDRSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CIDRSummary -> CIDRSummary -> Bool
$c/= :: CIDRSummary -> CIDRSummary -> Bool
== :: CIDRSummary -> CIDRSummary -> Bool
$c== :: CIDRSummary -> CIDRSummary -> Bool
Prelude.Eq, ReadPrec [CIDRSummary]
ReadPrec CIDRSummary
Int -> ReadS CIDRSummary
ReadS [CIDRSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CIDRSummary]
$creadListPrec :: ReadPrec [CIDRSummary]
readPrec :: ReadPrec CIDRSummary
$creadPrec :: ReadPrec CIDRSummary
readList :: ReadS [CIDRSummary]
$creadList :: ReadS [CIDRSummary]
readsPrec :: Int -> ReadS CIDRSummary
$creadsPrec :: Int -> ReadS CIDRSummary
Prelude.Read, Int -> CIDRSummary -> ShowS
[CIDRSummary] -> ShowS
CIDRSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CIDRSummary] -> ShowS
$cshowList :: [CIDRSummary] -> ShowS
show :: CIDRSummary -> String
$cshow :: CIDRSummary -> String
showsPrec :: Int -> CIDRSummary -> ShowS
$cshowsPrec :: Int -> CIDRSummary -> ShowS
Prelude.Show, forall x. Rep CIDRSummary x -> CIDRSummary
forall x. CIDRSummary -> Rep CIDRSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CIDRSummary x -> CIDRSummary
$cfrom :: forall x. CIDRSummary -> Rep CIDRSummary x
Prelude.Generic)

-- |
-- Create a value of 'CIDRSummary' 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:
--
-- 'availableCIDRCount', 'cIDRSummary_availableCIDRCount' - The number of CIDR blocks available for use by the IP set references in
-- a firewall.
--
-- 'iPSetReferences', 'cIDRSummary_iPSetReferences' - The list of the IP set references used by a firewall.
--
-- 'utilizedCIDRCount', 'cIDRSummary_utilizedCIDRCount' - The number of CIDR blocks used by the IP set references in a firewall.
newCIDRSummary ::
  CIDRSummary
newCIDRSummary :: CIDRSummary
newCIDRSummary =
  CIDRSummary'
    { $sel:availableCIDRCount:CIDRSummary' :: Maybe Natural
availableCIDRCount = forall a. Maybe a
Prelude.Nothing,
      $sel:iPSetReferences:CIDRSummary' :: Maybe (HashMap Text IPSetMetadata)
iPSetReferences = forall a. Maybe a
Prelude.Nothing,
      $sel:utilizedCIDRCount:CIDRSummary' :: Maybe Natural
utilizedCIDRCount = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of CIDR blocks available for use by the IP set references in
-- a firewall.
cIDRSummary_availableCIDRCount :: Lens.Lens' CIDRSummary (Prelude.Maybe Prelude.Natural)
cIDRSummary_availableCIDRCount :: Lens' CIDRSummary (Maybe Natural)
cIDRSummary_availableCIDRCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CIDRSummary' {Maybe Natural
availableCIDRCount :: Maybe Natural
$sel:availableCIDRCount:CIDRSummary' :: CIDRSummary -> Maybe Natural
availableCIDRCount} -> Maybe Natural
availableCIDRCount) (\s :: CIDRSummary
s@CIDRSummary' {} Maybe Natural
a -> CIDRSummary
s {$sel:availableCIDRCount:CIDRSummary' :: Maybe Natural
availableCIDRCount = Maybe Natural
a} :: CIDRSummary)

-- | The list of the IP set references used by a firewall.
cIDRSummary_iPSetReferences :: Lens.Lens' CIDRSummary (Prelude.Maybe (Prelude.HashMap Prelude.Text IPSetMetadata))
cIDRSummary_iPSetReferences :: Lens' CIDRSummary (Maybe (HashMap Text IPSetMetadata))
cIDRSummary_iPSetReferences = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CIDRSummary' {Maybe (HashMap Text IPSetMetadata)
iPSetReferences :: Maybe (HashMap Text IPSetMetadata)
$sel:iPSetReferences:CIDRSummary' :: CIDRSummary -> Maybe (HashMap Text IPSetMetadata)
iPSetReferences} -> Maybe (HashMap Text IPSetMetadata)
iPSetReferences) (\s :: CIDRSummary
s@CIDRSummary' {} Maybe (HashMap Text IPSetMetadata)
a -> CIDRSummary
s {$sel:iPSetReferences:CIDRSummary' :: Maybe (HashMap Text IPSetMetadata)
iPSetReferences = Maybe (HashMap Text IPSetMetadata)
a} :: CIDRSummary) 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 number of CIDR blocks used by the IP set references in a firewall.
cIDRSummary_utilizedCIDRCount :: Lens.Lens' CIDRSummary (Prelude.Maybe Prelude.Natural)
cIDRSummary_utilizedCIDRCount :: Lens' CIDRSummary (Maybe Natural)
cIDRSummary_utilizedCIDRCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CIDRSummary' {Maybe Natural
utilizedCIDRCount :: Maybe Natural
$sel:utilizedCIDRCount:CIDRSummary' :: CIDRSummary -> Maybe Natural
utilizedCIDRCount} -> Maybe Natural
utilizedCIDRCount) (\s :: CIDRSummary
s@CIDRSummary' {} Maybe Natural
a -> CIDRSummary
s {$sel:utilizedCIDRCount:CIDRSummary' :: Maybe Natural
utilizedCIDRCount = Maybe Natural
a} :: CIDRSummary)

instance Data.FromJSON CIDRSummary where
  parseJSON :: Value -> Parser CIDRSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CIDRSummary"
      ( \Object
x ->
          Maybe Natural
-> Maybe (HashMap Text IPSetMetadata)
-> Maybe Natural
-> CIDRSummary
CIDRSummary'
            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
"AvailableCIDRCount")
            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
"IPSetReferences"
                            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
"UtilizedCIDRCount")
      )

instance Prelude.Hashable CIDRSummary where
  hashWithSalt :: Int -> CIDRSummary -> Int
hashWithSalt Int
_salt CIDRSummary' {Maybe Natural
Maybe (HashMap Text IPSetMetadata)
utilizedCIDRCount :: Maybe Natural
iPSetReferences :: Maybe (HashMap Text IPSetMetadata)
availableCIDRCount :: Maybe Natural
$sel:utilizedCIDRCount:CIDRSummary' :: CIDRSummary -> Maybe Natural
$sel:iPSetReferences:CIDRSummary' :: CIDRSummary -> Maybe (HashMap Text IPSetMetadata)
$sel:availableCIDRCount:CIDRSummary' :: CIDRSummary -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
availableCIDRCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text IPSetMetadata)
iPSetReferences
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
utilizedCIDRCount

instance Prelude.NFData CIDRSummary where
  rnf :: CIDRSummary -> ()
rnf CIDRSummary' {Maybe Natural
Maybe (HashMap Text IPSetMetadata)
utilizedCIDRCount :: Maybe Natural
iPSetReferences :: Maybe (HashMap Text IPSetMetadata)
availableCIDRCount :: Maybe Natural
$sel:utilizedCIDRCount:CIDRSummary' :: CIDRSummary -> Maybe Natural
$sel:iPSetReferences:CIDRSummary' :: CIDRSummary -> Maybe (HashMap Text IPSetMetadata)
$sel:availableCIDRCount:CIDRSummary' :: CIDRSummary -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
availableCIDRCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text IPSetMetadata)
iPSetReferences
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
utilizedCIDRCount