{-# 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.PrefixList
-- 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.PrefixList 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 prefixes for Amazon Web Services services.
--
-- /See:/ 'newPrefixList' smart constructor.
data PrefixList = PrefixList'
  { -- | The IP address range of the Amazon Web Service.
    PrefixList -> Maybe [Text]
cidrs :: Prelude.Maybe [Prelude.Text],
    -- | The ID of the prefix.
    PrefixList -> Maybe Text
prefixListId :: Prelude.Maybe Prelude.Text,
    -- | The name of the prefix.
    PrefixList -> Maybe Text
prefixListName :: Prelude.Maybe Prelude.Text
  }
  deriving (PrefixList -> PrefixList -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PrefixList -> PrefixList -> Bool
$c/= :: PrefixList -> PrefixList -> Bool
== :: PrefixList -> PrefixList -> Bool
$c== :: PrefixList -> PrefixList -> Bool
Prelude.Eq, ReadPrec [PrefixList]
ReadPrec PrefixList
Int -> ReadS PrefixList
ReadS [PrefixList]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PrefixList]
$creadListPrec :: ReadPrec [PrefixList]
readPrec :: ReadPrec PrefixList
$creadPrec :: ReadPrec PrefixList
readList :: ReadS [PrefixList]
$creadList :: ReadS [PrefixList]
readsPrec :: Int -> ReadS PrefixList
$creadsPrec :: Int -> ReadS PrefixList
Prelude.Read, Int -> PrefixList -> ShowS
[PrefixList] -> ShowS
PrefixList -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PrefixList] -> ShowS
$cshowList :: [PrefixList] -> ShowS
show :: PrefixList -> String
$cshow :: PrefixList -> String
showsPrec :: Int -> PrefixList -> ShowS
$cshowsPrec :: Int -> PrefixList -> ShowS
Prelude.Show, forall x. Rep PrefixList x -> PrefixList
forall x. PrefixList -> Rep PrefixList x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PrefixList x -> PrefixList
$cfrom :: forall x. PrefixList -> Rep PrefixList x
Prelude.Generic)

-- |
-- Create a value of 'PrefixList' 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:
--
-- 'cidrs', 'prefixList_cidrs' - The IP address range of the Amazon Web Service.
--
-- 'prefixListId', 'prefixList_prefixListId' - The ID of the prefix.
--
-- 'prefixListName', 'prefixList_prefixListName' - The name of the prefix.
newPrefixList ::
  PrefixList
newPrefixList :: PrefixList
newPrefixList =
  PrefixList'
    { $sel:cidrs:PrefixList' :: Maybe [Text]
cidrs = forall a. Maybe a
Prelude.Nothing,
      $sel:prefixListId:PrefixList' :: Maybe Text
prefixListId = forall a. Maybe a
Prelude.Nothing,
      $sel:prefixListName:PrefixList' :: Maybe Text
prefixListName = forall a. Maybe a
Prelude.Nothing
    }

-- | The IP address range of the Amazon Web Service.
prefixList_cidrs :: Lens.Lens' PrefixList (Prelude.Maybe [Prelude.Text])
prefixList_cidrs :: Lens' PrefixList (Maybe [Text])
prefixList_cidrs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefixList' {Maybe [Text]
cidrs :: Maybe [Text]
$sel:cidrs:PrefixList' :: PrefixList -> Maybe [Text]
cidrs} -> Maybe [Text]
cidrs) (\s :: PrefixList
s@PrefixList' {} Maybe [Text]
a -> PrefixList
s {$sel:cidrs:PrefixList' :: Maybe [Text]
cidrs = Maybe [Text]
a} :: PrefixList) 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 ID of the prefix.
prefixList_prefixListId :: Lens.Lens' PrefixList (Prelude.Maybe Prelude.Text)
prefixList_prefixListId :: Lens' PrefixList (Maybe Text)
prefixList_prefixListId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefixList' {Maybe Text
prefixListId :: Maybe Text
$sel:prefixListId:PrefixList' :: PrefixList -> Maybe Text
prefixListId} -> Maybe Text
prefixListId) (\s :: PrefixList
s@PrefixList' {} Maybe Text
a -> PrefixList
s {$sel:prefixListId:PrefixList' :: Maybe Text
prefixListId = Maybe Text
a} :: PrefixList)

-- | The name of the prefix.
prefixList_prefixListName :: Lens.Lens' PrefixList (Prelude.Maybe Prelude.Text)
prefixList_prefixListName :: Lens' PrefixList (Maybe Text)
prefixList_prefixListName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PrefixList' {Maybe Text
prefixListName :: Maybe Text
$sel:prefixListName:PrefixList' :: PrefixList -> Maybe Text
prefixListName} -> Maybe Text
prefixListName) (\s :: PrefixList
s@PrefixList' {} Maybe Text
a -> PrefixList
s {$sel:prefixListName:PrefixList' :: Maybe Text
prefixListName = Maybe Text
a} :: PrefixList)

instance Data.FromXML PrefixList where
  parseXML :: [Node] -> Either String PrefixList
parseXML [Node]
x =
    Maybe [Text] -> Maybe Text -> Maybe Text -> PrefixList
PrefixList'
      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
"cidrSet"
                      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
"prefixListId")
      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
"prefixListName")

instance Prelude.Hashable PrefixList where
  hashWithSalt :: Int -> PrefixList -> Int
hashWithSalt Int
_salt PrefixList' {Maybe [Text]
Maybe Text
prefixListName :: Maybe Text
prefixListId :: Maybe Text
cidrs :: Maybe [Text]
$sel:prefixListName:PrefixList' :: PrefixList -> Maybe Text
$sel:prefixListId:PrefixList' :: PrefixList -> Maybe Text
$sel:cidrs:PrefixList' :: PrefixList -> Maybe [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
cidrs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefixListId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefixListName

instance Prelude.NFData PrefixList where
  rnf :: PrefixList -> ()
rnf PrefixList' {Maybe [Text]
Maybe Text
prefixListName :: Maybe Text
prefixListId :: Maybe Text
cidrs :: Maybe [Text]
$sel:prefixListName:PrefixList' :: PrefixList -> Maybe Text
$sel:prefixListId:PrefixList' :: PrefixList -> Maybe Text
$sel:cidrs:PrefixList' :: PrefixList -> Maybe [Text]
..} =
    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
prefixListId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefixListName