{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.GlobalAccelerator.Types.IpSet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Text
ipFamily :: Prelude.Maybe Prelude.Text,
    -- | 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]
  }
  deriving (IpSet -> IpSet -> Bool
(IpSet -> IpSet -> Bool) -> (IpSet -> IpSet -> Bool) -> Eq IpSet
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]
(Int -> ReadS IpSet)
-> ReadS [IpSet]
-> ReadPrec IpSet
-> ReadPrec [IpSet]
-> Read 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
(Int -> IpSet -> ShowS)
-> (IpSet -> String) -> ([IpSet] -> ShowS) -> Show IpSet
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. IpSet -> Rep IpSet x)
-> (forall x. Rep IpSet x -> IpSet) -> Generic IpSet
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:
--
-- 'ipFamily', 'ipSet_ipFamily' - 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.
newIpSet ::
  IpSet
newIpSet :: IpSet
newIpSet =
  IpSet' :: Maybe Text -> Maybe [Text] -> IpSet
IpSet'
    { $sel:ipFamily:IpSet' :: Maybe Text
ipFamily = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ipAddresses:IpSet' :: Maybe [Text]
ipAddresses = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The types of IP addresses included in this IP set.
ipSet_ipFamily :: Lens.Lens' IpSet (Prelude.Maybe Prelude.Text)
ipSet_ipFamily :: (Maybe Text -> f (Maybe Text)) -> IpSet -> f IpSet
ipSet_ipFamily = (IpSet -> Maybe Text)
-> (IpSet -> Maybe Text -> IpSet)
-> Lens IpSet IpSet (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe [Text] -> f (Maybe [Text])) -> IpSet -> f IpSet
ipSet_ipAddresses = (IpSet -> Maybe [Text])
-> (IpSet -> Maybe [Text] -> IpSet)
-> Lens IpSet IpSet (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text])) -> IpSet -> f IpSet)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> IpSet
-> f IpSet
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON IpSet where
  parseJSON :: Value -> Parser IpSet
parseJSON =
    String -> (Object -> Parser IpSet) -> Value -> Parser IpSet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"IpSet"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> IpSet
IpSet'
            (Maybe Text -> Maybe [Text] -> IpSet)
-> Parser (Maybe Text) -> Parser (Maybe [Text] -> IpSet)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IpFamily")
            Parser (Maybe [Text] -> IpSet)
-> Parser (Maybe [Text]) -> Parser IpSet
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IpAddresses" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable IpSet

instance Prelude.NFData IpSet