{-# 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.MediaLive.Types.InputWhitelistRuleCidr
-- 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.MediaLive.Types.InputWhitelistRuleCidr where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An IPv4 CIDR to whitelist.
--
-- /See:/ 'newInputWhitelistRuleCidr' smart constructor.
data InputWhitelistRuleCidr = InputWhitelistRuleCidr'
  { -- | The IPv4 CIDR to whitelist.
    InputWhitelistRuleCidr -> Maybe Text
cidr :: Prelude.Maybe Prelude.Text
  }
  deriving (InputWhitelistRuleCidr -> InputWhitelistRuleCidr -> Bool
(InputWhitelistRuleCidr -> InputWhitelistRuleCidr -> Bool)
-> (InputWhitelistRuleCidr -> InputWhitelistRuleCidr -> Bool)
-> Eq InputWhitelistRuleCidr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputWhitelistRuleCidr -> InputWhitelistRuleCidr -> Bool
$c/= :: InputWhitelistRuleCidr -> InputWhitelistRuleCidr -> Bool
== :: InputWhitelistRuleCidr -> InputWhitelistRuleCidr -> Bool
$c== :: InputWhitelistRuleCidr -> InputWhitelistRuleCidr -> Bool
Prelude.Eq, ReadPrec [InputWhitelistRuleCidr]
ReadPrec InputWhitelistRuleCidr
Int -> ReadS InputWhitelistRuleCidr
ReadS [InputWhitelistRuleCidr]
(Int -> ReadS InputWhitelistRuleCidr)
-> ReadS [InputWhitelistRuleCidr]
-> ReadPrec InputWhitelistRuleCidr
-> ReadPrec [InputWhitelistRuleCidr]
-> Read InputWhitelistRuleCidr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputWhitelistRuleCidr]
$creadListPrec :: ReadPrec [InputWhitelistRuleCidr]
readPrec :: ReadPrec InputWhitelistRuleCidr
$creadPrec :: ReadPrec InputWhitelistRuleCidr
readList :: ReadS [InputWhitelistRuleCidr]
$creadList :: ReadS [InputWhitelistRuleCidr]
readsPrec :: Int -> ReadS InputWhitelistRuleCidr
$creadsPrec :: Int -> ReadS InputWhitelistRuleCidr
Prelude.Read, Int -> InputWhitelistRuleCidr -> ShowS
[InputWhitelistRuleCidr] -> ShowS
InputWhitelistRuleCidr -> String
(Int -> InputWhitelistRuleCidr -> ShowS)
-> (InputWhitelistRuleCidr -> String)
-> ([InputWhitelistRuleCidr] -> ShowS)
-> Show InputWhitelistRuleCidr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputWhitelistRuleCidr] -> ShowS
$cshowList :: [InputWhitelistRuleCidr] -> ShowS
show :: InputWhitelistRuleCidr -> String
$cshow :: InputWhitelistRuleCidr -> String
showsPrec :: Int -> InputWhitelistRuleCidr -> ShowS
$cshowsPrec :: Int -> InputWhitelistRuleCidr -> ShowS
Prelude.Show, (forall x. InputWhitelistRuleCidr -> Rep InputWhitelistRuleCidr x)
-> (forall x.
    Rep InputWhitelistRuleCidr x -> InputWhitelistRuleCidr)
-> Generic InputWhitelistRuleCidr
forall x. Rep InputWhitelistRuleCidr x -> InputWhitelistRuleCidr
forall x. InputWhitelistRuleCidr -> Rep InputWhitelistRuleCidr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputWhitelistRuleCidr x -> InputWhitelistRuleCidr
$cfrom :: forall x. InputWhitelistRuleCidr -> Rep InputWhitelistRuleCidr x
Prelude.Generic)

-- |
-- Create a value of 'InputWhitelistRuleCidr' 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', 'inputWhitelistRuleCidr_cidr' - The IPv4 CIDR to whitelist.
newInputWhitelistRuleCidr ::
  InputWhitelistRuleCidr
newInputWhitelistRuleCidr :: InputWhitelistRuleCidr
newInputWhitelistRuleCidr =
  InputWhitelistRuleCidr' :: Maybe Text -> InputWhitelistRuleCidr
InputWhitelistRuleCidr' {$sel:cidr:InputWhitelistRuleCidr' :: Maybe Text
cidr = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The IPv4 CIDR to whitelist.
inputWhitelistRuleCidr_cidr :: Lens.Lens' InputWhitelistRuleCidr (Prelude.Maybe Prelude.Text)
inputWhitelistRuleCidr_cidr :: (Maybe Text -> f (Maybe Text))
-> InputWhitelistRuleCidr -> f InputWhitelistRuleCidr
inputWhitelistRuleCidr_cidr = (InputWhitelistRuleCidr -> Maybe Text)
-> (InputWhitelistRuleCidr -> Maybe Text -> InputWhitelistRuleCidr)
-> Lens
     InputWhitelistRuleCidr
     InputWhitelistRuleCidr
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputWhitelistRuleCidr' {Maybe Text
cidr :: Maybe Text
$sel:cidr:InputWhitelistRuleCidr' :: InputWhitelistRuleCidr -> Maybe Text
cidr} -> Maybe Text
cidr) (\s :: InputWhitelistRuleCidr
s@InputWhitelistRuleCidr' {} Maybe Text
a -> InputWhitelistRuleCidr
s {$sel:cidr:InputWhitelistRuleCidr' :: Maybe Text
cidr = Maybe Text
a} :: InputWhitelistRuleCidr)

instance Prelude.Hashable InputWhitelistRuleCidr

instance Prelude.NFData InputWhitelistRuleCidr

instance Core.ToJSON InputWhitelistRuleCidr where
  toJSON :: InputWhitelistRuleCidr -> Value
toJSON InputWhitelistRuleCidr' {Maybe Text
cidr :: Maybe Text
$sel:cidr:InputWhitelistRuleCidr' :: InputWhitelistRuleCidr -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"cidr" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
cidr]
      )