{-# 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.CognitoIdentityProvider.Types.RiskExceptionConfigurationType
-- 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.CognitoIdentityProvider.Types.RiskExceptionConfigurationType where

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

-- | The type of the configuration to override the risk decision.
--
-- /See:/ 'newRiskExceptionConfigurationType' smart constructor.
data RiskExceptionConfigurationType = RiskExceptionConfigurationType'
  { -- | Risk detection is not performed on the IP addresses in the range list.
    -- The IP range is in CIDR notation.
    RiskExceptionConfigurationType -> Maybe [Text]
skippedIPRangeList :: Prelude.Maybe [Prelude.Text],
    -- | Overrides the risk decision to always block the pre-authentication
    -- requests. The IP range is in CIDR notation: a compact representation of
    -- an IP address and its associated routing prefix.
    RiskExceptionConfigurationType -> Maybe [Text]
blockedIPRangeList :: Prelude.Maybe [Prelude.Text]
  }
  deriving (RiskExceptionConfigurationType
-> RiskExceptionConfigurationType -> Bool
(RiskExceptionConfigurationType
 -> RiskExceptionConfigurationType -> Bool)
-> (RiskExceptionConfigurationType
    -> RiskExceptionConfigurationType -> Bool)
-> Eq RiskExceptionConfigurationType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RiskExceptionConfigurationType
-> RiskExceptionConfigurationType -> Bool
$c/= :: RiskExceptionConfigurationType
-> RiskExceptionConfigurationType -> Bool
== :: RiskExceptionConfigurationType
-> RiskExceptionConfigurationType -> Bool
$c== :: RiskExceptionConfigurationType
-> RiskExceptionConfigurationType -> Bool
Prelude.Eq, ReadPrec [RiskExceptionConfigurationType]
ReadPrec RiskExceptionConfigurationType
Int -> ReadS RiskExceptionConfigurationType
ReadS [RiskExceptionConfigurationType]
(Int -> ReadS RiskExceptionConfigurationType)
-> ReadS [RiskExceptionConfigurationType]
-> ReadPrec RiskExceptionConfigurationType
-> ReadPrec [RiskExceptionConfigurationType]
-> Read RiskExceptionConfigurationType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RiskExceptionConfigurationType]
$creadListPrec :: ReadPrec [RiskExceptionConfigurationType]
readPrec :: ReadPrec RiskExceptionConfigurationType
$creadPrec :: ReadPrec RiskExceptionConfigurationType
readList :: ReadS [RiskExceptionConfigurationType]
$creadList :: ReadS [RiskExceptionConfigurationType]
readsPrec :: Int -> ReadS RiskExceptionConfigurationType
$creadsPrec :: Int -> ReadS RiskExceptionConfigurationType
Prelude.Read, Int -> RiskExceptionConfigurationType -> ShowS
[RiskExceptionConfigurationType] -> ShowS
RiskExceptionConfigurationType -> String
(Int -> RiskExceptionConfigurationType -> ShowS)
-> (RiskExceptionConfigurationType -> String)
-> ([RiskExceptionConfigurationType] -> ShowS)
-> Show RiskExceptionConfigurationType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RiskExceptionConfigurationType] -> ShowS
$cshowList :: [RiskExceptionConfigurationType] -> ShowS
show :: RiskExceptionConfigurationType -> String
$cshow :: RiskExceptionConfigurationType -> String
showsPrec :: Int -> RiskExceptionConfigurationType -> ShowS
$cshowsPrec :: Int -> RiskExceptionConfigurationType -> ShowS
Prelude.Show, (forall x.
 RiskExceptionConfigurationType
 -> Rep RiskExceptionConfigurationType x)
-> (forall x.
    Rep RiskExceptionConfigurationType x
    -> RiskExceptionConfigurationType)
-> Generic RiskExceptionConfigurationType
forall x.
Rep RiskExceptionConfigurationType x
-> RiskExceptionConfigurationType
forall x.
RiskExceptionConfigurationType
-> Rep RiskExceptionConfigurationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RiskExceptionConfigurationType x
-> RiskExceptionConfigurationType
$cfrom :: forall x.
RiskExceptionConfigurationType
-> Rep RiskExceptionConfigurationType x
Prelude.Generic)

-- |
-- Create a value of 'RiskExceptionConfigurationType' 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:
--
-- 'skippedIPRangeList', 'riskExceptionConfigurationType_skippedIPRangeList' - Risk detection is not performed on the IP addresses in the range list.
-- The IP range is in CIDR notation.
--
-- 'blockedIPRangeList', 'riskExceptionConfigurationType_blockedIPRangeList' - Overrides the risk decision to always block the pre-authentication
-- requests. The IP range is in CIDR notation: a compact representation of
-- an IP address and its associated routing prefix.
newRiskExceptionConfigurationType ::
  RiskExceptionConfigurationType
newRiskExceptionConfigurationType :: RiskExceptionConfigurationType
newRiskExceptionConfigurationType =
  RiskExceptionConfigurationType' :: Maybe [Text] -> Maybe [Text] -> RiskExceptionConfigurationType
RiskExceptionConfigurationType'
    { $sel:skippedIPRangeList:RiskExceptionConfigurationType' :: Maybe [Text]
skippedIPRangeList =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:blockedIPRangeList:RiskExceptionConfigurationType' :: Maybe [Text]
blockedIPRangeList = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | Risk detection is not performed on the IP addresses in the range list.
-- The IP range is in CIDR notation.
riskExceptionConfigurationType_skippedIPRangeList :: Lens.Lens' RiskExceptionConfigurationType (Prelude.Maybe [Prelude.Text])
riskExceptionConfigurationType_skippedIPRangeList :: (Maybe [Text] -> f (Maybe [Text]))
-> RiskExceptionConfigurationType
-> f RiskExceptionConfigurationType
riskExceptionConfigurationType_skippedIPRangeList = (RiskExceptionConfigurationType -> Maybe [Text])
-> (RiskExceptionConfigurationType
    -> Maybe [Text] -> RiskExceptionConfigurationType)
-> Lens
     RiskExceptionConfigurationType
     RiskExceptionConfigurationType
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RiskExceptionConfigurationType' {Maybe [Text]
skippedIPRangeList :: Maybe [Text]
$sel:skippedIPRangeList:RiskExceptionConfigurationType' :: RiskExceptionConfigurationType -> Maybe [Text]
skippedIPRangeList} -> Maybe [Text]
skippedIPRangeList) (\s :: RiskExceptionConfigurationType
s@RiskExceptionConfigurationType' {} Maybe [Text]
a -> RiskExceptionConfigurationType
s {$sel:skippedIPRangeList:RiskExceptionConfigurationType' :: Maybe [Text]
skippedIPRangeList = Maybe [Text]
a} :: RiskExceptionConfigurationType) ((Maybe [Text] -> f (Maybe [Text]))
 -> RiskExceptionConfigurationType
 -> f RiskExceptionConfigurationType)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RiskExceptionConfigurationType
-> f RiskExceptionConfigurationType
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

-- | Overrides the risk decision to always block the pre-authentication
-- requests. The IP range is in CIDR notation: a compact representation of
-- an IP address and its associated routing prefix.
riskExceptionConfigurationType_blockedIPRangeList :: Lens.Lens' RiskExceptionConfigurationType (Prelude.Maybe [Prelude.Text])
riskExceptionConfigurationType_blockedIPRangeList :: (Maybe [Text] -> f (Maybe [Text]))
-> RiskExceptionConfigurationType
-> f RiskExceptionConfigurationType
riskExceptionConfigurationType_blockedIPRangeList = (RiskExceptionConfigurationType -> Maybe [Text])
-> (RiskExceptionConfigurationType
    -> Maybe [Text] -> RiskExceptionConfigurationType)
-> Lens
     RiskExceptionConfigurationType
     RiskExceptionConfigurationType
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RiskExceptionConfigurationType' {Maybe [Text]
blockedIPRangeList :: Maybe [Text]
$sel:blockedIPRangeList:RiskExceptionConfigurationType' :: RiskExceptionConfigurationType -> Maybe [Text]
blockedIPRangeList} -> Maybe [Text]
blockedIPRangeList) (\s :: RiskExceptionConfigurationType
s@RiskExceptionConfigurationType' {} Maybe [Text]
a -> RiskExceptionConfigurationType
s {$sel:blockedIPRangeList:RiskExceptionConfigurationType' :: Maybe [Text]
blockedIPRangeList = Maybe [Text]
a} :: RiskExceptionConfigurationType) ((Maybe [Text] -> f (Maybe [Text]))
 -> RiskExceptionConfigurationType
 -> f RiskExceptionConfigurationType)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> RiskExceptionConfigurationType
-> f RiskExceptionConfigurationType
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 RiskExceptionConfigurationType where
  parseJSON :: Value -> Parser RiskExceptionConfigurationType
parseJSON =
    String
-> (Object -> Parser RiskExceptionConfigurationType)
-> Value
-> Parser RiskExceptionConfigurationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RiskExceptionConfigurationType"
      ( \Object
x ->
          Maybe [Text] -> Maybe [Text] -> RiskExceptionConfigurationType
RiskExceptionConfigurationType'
            (Maybe [Text] -> Maybe [Text] -> RiskExceptionConfigurationType)
-> Parser (Maybe [Text])
-> Parser (Maybe [Text] -> RiskExceptionConfigurationType)
forall (f :: * -> *) a b. Functor 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
"SkippedIPRangeList"
                            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
                        )
            Parser (Maybe [Text] -> RiskExceptionConfigurationType)
-> Parser (Maybe [Text]) -> Parser RiskExceptionConfigurationType
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
"BlockedIPRangeList"
                            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
    RiskExceptionConfigurationType

instance
  Prelude.NFData
    RiskExceptionConfigurationType

instance Core.ToJSON RiskExceptionConfigurationType where
  toJSON :: RiskExceptionConfigurationType -> Value
toJSON RiskExceptionConfigurationType' {Maybe [Text]
blockedIPRangeList :: Maybe [Text]
skippedIPRangeList :: Maybe [Text]
$sel:blockedIPRangeList:RiskExceptionConfigurationType' :: RiskExceptionConfigurationType -> Maybe [Text]
$sel:skippedIPRangeList:RiskExceptionConfigurationType' :: RiskExceptionConfigurationType -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SkippedIPRangeList" 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]
skippedIPRangeList,
            (Text
"BlockedIPRangeList" 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]
blockedIPRangeList
          ]
      )