{-# 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.InputWhitelistRule
-- 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.InputWhitelistRule where

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

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

-- |
-- Create a value of 'InputWhitelistRule' 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', 'inputWhitelistRule_cidr' - The IPv4 CIDR that\'s whitelisted.
newInputWhitelistRule ::
  InputWhitelistRule
newInputWhitelistRule :: InputWhitelistRule
newInputWhitelistRule =
  InputWhitelistRule' :: Maybe Text -> InputWhitelistRule
InputWhitelistRule' {$sel:cidr:InputWhitelistRule' :: Maybe Text
cidr = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The IPv4 CIDR that\'s whitelisted.
inputWhitelistRule_cidr :: Lens.Lens' InputWhitelistRule (Prelude.Maybe Prelude.Text)
inputWhitelistRule_cidr :: (Maybe Text -> f (Maybe Text))
-> InputWhitelistRule -> f InputWhitelistRule
inputWhitelistRule_cidr = (InputWhitelistRule -> Maybe Text)
-> (InputWhitelistRule -> Maybe Text -> InputWhitelistRule)
-> Lens
     InputWhitelistRule InputWhitelistRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputWhitelistRule' {Maybe Text
cidr :: Maybe Text
$sel:cidr:InputWhitelistRule' :: InputWhitelistRule -> Maybe Text
cidr} -> Maybe Text
cidr) (\s :: InputWhitelistRule
s@InputWhitelistRule' {} Maybe Text
a -> InputWhitelistRule
s {$sel:cidr:InputWhitelistRule' :: Maybe Text
cidr = Maybe Text
a} :: InputWhitelistRule)

instance Core.FromJSON InputWhitelistRule where
  parseJSON :: Value -> Parser InputWhitelistRule
parseJSON =
    String
-> (Object -> Parser InputWhitelistRule)
-> Value
-> Parser InputWhitelistRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputWhitelistRule"
      ( \Object
x ->
          Maybe Text -> InputWhitelistRule
InputWhitelistRule' (Maybe Text -> InputWhitelistRule)
-> Parser (Maybe Text) -> Parser InputWhitelistRule
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
"cidr")
      )

instance Prelude.Hashable InputWhitelistRule

instance Prelude.NFData InputWhitelistRule