{-# 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.GlobalAccelerator.Types.IpSet
-- 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.GlobalAccelerator.Types.IpSet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GlobalAccelerator.Types.IpAddressFamily
import qualified Amazonka.Prelude as Prelude

-- | A complex type for the set of IP addresses for an accelerator.
--
-- /See:/ 'newIpSet' smart constructor.
data IpSet = IpSet'
  { -- | The types of IP addresses included in this IP set.
    IpSet -> Maybe IpAddressFamily
ipAddressFamily :: Prelude.Maybe IpAddressFamily,
    -- | The array of IP addresses in the IP address set. An IP address set can
    -- have a maximum of two IP addresses.
    IpSet -> Maybe [Text]
ipAddresses :: Prelude.Maybe [Prelude.Text],
    -- | IpFamily is deprecated and has been replaced by IpAddressFamily.
    IpSet -> Maybe Text
ipFamily :: Prelude.Maybe Prelude.Text
  }
  deriving (IpSet -> IpSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IpSet -> IpSet -> Bool
$c/= :: IpSet -> IpSet -> Bool
== :: IpSet -> IpSet -> Bool
$c== :: IpSet -> IpSet -> Bool
Prelude.Eq, ReadPrec [IpSet]
ReadPrec IpSet
Int -> ReadS IpSet
ReadS [IpSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IpSet]
$creadListPrec :: ReadPrec [IpSet]
readPrec :: ReadPrec IpSet
$creadPrec :: ReadPrec IpSet
readList :: ReadS [IpSet]
$creadList :: ReadS [IpSet]
readsPrec :: Int -> ReadS IpSet
$creadsPrec :: Int -> ReadS IpSet
Prelude.Read, Int -> IpSet -> ShowS
[IpSet] -> ShowS
IpSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IpSet] -> ShowS
$cshowList :: [IpSet] -> ShowS
show :: IpSet -> String
$cshow :: IpSet -> String
showsPrec :: Int -> IpSet -> ShowS
$cshowsPrec :: Int -> IpSet -> ShowS
Prelude.Show, forall x. Rep IpSet x -> IpSet
forall x. IpSet -> Rep IpSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IpSet x -> IpSet
$cfrom :: forall x. IpSet -> Rep IpSet x
Prelude.Generic)

-- |
-- Create a value of 'IpSet' 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:
--
-- 'ipAddressFamily', 'ipSet_ipAddressFamily' - The types of IP addresses included in this IP set.
--
-- 'ipAddresses', 'ipSet_ipAddresses' - The array of IP addresses in the IP address set. An IP address set can
-- have a maximum of two IP addresses.
--
-- 'ipFamily', 'ipSet_ipFamily' - IpFamily is deprecated and has been replaced by IpAddressFamily.
newIpSet ::
  IpSet
newIpSet :: IpSet
newIpSet =
  IpSet'
    { $sel:ipAddressFamily:IpSet' :: Maybe IpAddressFamily
ipAddressFamily = forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddresses:IpSet' :: Maybe [Text]
ipAddresses = forall a. Maybe a
Prelude.Nothing,
      $sel:ipFamily:IpSet' :: Maybe Text
ipFamily = forall a. Maybe a
Prelude.Nothing
    }

-- | The types of IP addresses included in this IP set.
ipSet_ipAddressFamily :: Lens.Lens' IpSet (Prelude.Maybe IpAddressFamily)
ipSet_ipAddressFamily :: Lens' IpSet (Maybe IpAddressFamily)
ipSet_ipAddressFamily = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpSet' {Maybe IpAddressFamily
ipAddressFamily :: Maybe IpAddressFamily
$sel:ipAddressFamily:IpSet' :: IpSet -> Maybe IpAddressFamily
ipAddressFamily} -> Maybe IpAddressFamily
ipAddressFamily) (\s :: IpSet
s@IpSet' {} Maybe IpAddressFamily
a -> IpSet
s {$sel:ipAddressFamily:IpSet' :: Maybe IpAddressFamily
ipAddressFamily = Maybe IpAddressFamily
a} :: IpSet)

-- | The array of IP addresses in the IP address set. An IP address set can
-- have a maximum of two IP addresses.
ipSet_ipAddresses :: Lens.Lens' IpSet (Prelude.Maybe [Prelude.Text])
ipSet_ipAddresses :: Lens' IpSet (Maybe [Text])
ipSet_ipAddresses = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpSet' {Maybe [Text]
ipAddresses :: Maybe [Text]
$sel:ipAddresses:IpSet' :: IpSet -> Maybe [Text]
ipAddresses} -> Maybe [Text]
ipAddresses) (\s :: IpSet
s@IpSet' {} Maybe [Text]
a -> IpSet
s {$sel:ipAddresses:IpSet' :: Maybe [Text]
ipAddresses = Maybe [Text]
a} :: IpSet) 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

-- | IpFamily is deprecated and has been replaced by IpAddressFamily.
ipSet_ipFamily :: Lens.Lens' IpSet (Prelude.Maybe Prelude.Text)
ipSet_ipFamily :: Lens' IpSet (Maybe Text)
ipSet_ipFamily = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IpSet' {Maybe Text
ipFamily :: Maybe Text
$sel:ipFamily:IpSet' :: IpSet -> Maybe Text
ipFamily} -> Maybe Text
ipFamily) (\s :: IpSet
s@IpSet' {} Maybe Text
a -> IpSet
s {$sel:ipFamily:IpSet' :: Maybe Text
ipFamily = Maybe Text
a} :: IpSet)

instance Data.FromJSON IpSet where
  parseJSON :: Value -> Parser IpSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"IpSet"
      ( \Object
x ->
          Maybe IpAddressFamily -> Maybe [Text] -> Maybe Text -> IpSet
IpSet'
            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
"IpAddressFamily")
            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
"IpAddresses" 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
"IpFamily")
      )

instance Prelude.Hashable IpSet where
  hashWithSalt :: Int -> IpSet -> Int
hashWithSalt Int
_salt IpSet' {Maybe [Text]
Maybe Text
Maybe IpAddressFamily
ipFamily :: Maybe Text
ipAddresses :: Maybe [Text]
ipAddressFamily :: Maybe IpAddressFamily
$sel:ipFamily:IpSet' :: IpSet -> Maybe Text
$sel:ipAddresses:IpSet' :: IpSet -> Maybe [Text]
$sel:ipAddressFamily:IpSet' :: IpSet -> Maybe IpAddressFamily
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IpAddressFamily
ipAddressFamily
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
ipAddresses
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ipFamily

instance Prelude.NFData IpSet where
  rnf :: IpSet -> ()
rnf IpSet' {Maybe [Text]
Maybe Text
Maybe IpAddressFamily
ipFamily :: Maybe Text
ipAddresses :: Maybe [Text]
ipAddressFamily :: Maybe IpAddressFamily
$sel:ipFamily:IpSet' :: IpSet -> Maybe Text
$sel:ipAddresses:IpSet' :: IpSet -> Maybe [Text]
$sel:ipAddressFamily:IpSet' :: IpSet -> Maybe IpAddressFamily
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe IpAddressFamily
ipAddressFamily
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
ipAddresses
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ipFamily