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

import Amazonka.CognitoIdentityProvider.Types.RiskDecisionType
import Amazonka.CognitoIdentityProvider.Types.RiskLevelType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The event risk type.
--
-- /See:/ 'newEventRiskType' smart constructor.
data EventRiskType = EventRiskType'
  { -- | Indicates whether compromised credentials were detected during an
    -- authentication event.
    EventRiskType -> Maybe Bool
compromisedCredentialsDetected :: Prelude.Maybe Prelude.Bool,
    -- | The risk level.
    EventRiskType -> Maybe RiskLevelType
riskLevel :: Prelude.Maybe RiskLevelType,
    -- | The risk decision.
    EventRiskType -> Maybe RiskDecisionType
riskDecision :: Prelude.Maybe RiskDecisionType
  }
  deriving (EventRiskType -> EventRiskType -> Bool
(EventRiskType -> EventRiskType -> Bool)
-> (EventRiskType -> EventRiskType -> Bool) -> Eq EventRiskType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventRiskType -> EventRiskType -> Bool
$c/= :: EventRiskType -> EventRiskType -> Bool
== :: EventRiskType -> EventRiskType -> Bool
$c== :: EventRiskType -> EventRiskType -> Bool
Prelude.Eq, ReadPrec [EventRiskType]
ReadPrec EventRiskType
Int -> ReadS EventRiskType
ReadS [EventRiskType]
(Int -> ReadS EventRiskType)
-> ReadS [EventRiskType]
-> ReadPrec EventRiskType
-> ReadPrec [EventRiskType]
-> Read EventRiskType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventRiskType]
$creadListPrec :: ReadPrec [EventRiskType]
readPrec :: ReadPrec EventRiskType
$creadPrec :: ReadPrec EventRiskType
readList :: ReadS [EventRiskType]
$creadList :: ReadS [EventRiskType]
readsPrec :: Int -> ReadS EventRiskType
$creadsPrec :: Int -> ReadS EventRiskType
Prelude.Read, Int -> EventRiskType -> ShowS
[EventRiskType] -> ShowS
EventRiskType -> String
(Int -> EventRiskType -> ShowS)
-> (EventRiskType -> String)
-> ([EventRiskType] -> ShowS)
-> Show EventRiskType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventRiskType] -> ShowS
$cshowList :: [EventRiskType] -> ShowS
show :: EventRiskType -> String
$cshow :: EventRiskType -> String
showsPrec :: Int -> EventRiskType -> ShowS
$cshowsPrec :: Int -> EventRiskType -> ShowS
Prelude.Show, (forall x. EventRiskType -> Rep EventRiskType x)
-> (forall x. Rep EventRiskType x -> EventRiskType)
-> Generic EventRiskType
forall x. Rep EventRiskType x -> EventRiskType
forall x. EventRiskType -> Rep EventRiskType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventRiskType x -> EventRiskType
$cfrom :: forall x. EventRiskType -> Rep EventRiskType x
Prelude.Generic)

-- |
-- Create a value of 'EventRiskType' 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:
--
-- 'compromisedCredentialsDetected', 'eventRiskType_compromisedCredentialsDetected' - Indicates whether compromised credentials were detected during an
-- authentication event.
--
-- 'riskLevel', 'eventRiskType_riskLevel' - The risk level.
--
-- 'riskDecision', 'eventRiskType_riskDecision' - The risk decision.
newEventRiskType ::
  EventRiskType
newEventRiskType :: EventRiskType
newEventRiskType =
  EventRiskType' :: Maybe Bool
-> Maybe RiskLevelType -> Maybe RiskDecisionType -> EventRiskType
EventRiskType'
    { $sel:compromisedCredentialsDetected:EventRiskType' :: Maybe Bool
compromisedCredentialsDetected =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:riskLevel:EventRiskType' :: Maybe RiskLevelType
riskLevel = Maybe RiskLevelType
forall a. Maybe a
Prelude.Nothing,
      $sel:riskDecision:EventRiskType' :: Maybe RiskDecisionType
riskDecision = Maybe RiskDecisionType
forall a. Maybe a
Prelude.Nothing
    }

-- | Indicates whether compromised credentials were detected during an
-- authentication event.
eventRiskType_compromisedCredentialsDetected :: Lens.Lens' EventRiskType (Prelude.Maybe Prelude.Bool)
eventRiskType_compromisedCredentialsDetected :: (Maybe Bool -> f (Maybe Bool)) -> EventRiskType -> f EventRiskType
eventRiskType_compromisedCredentialsDetected = (EventRiskType -> Maybe Bool)
-> (EventRiskType -> Maybe Bool -> EventRiskType)
-> Lens EventRiskType EventRiskType (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventRiskType' {Maybe Bool
compromisedCredentialsDetected :: Maybe Bool
$sel:compromisedCredentialsDetected:EventRiskType' :: EventRiskType -> Maybe Bool
compromisedCredentialsDetected} -> Maybe Bool
compromisedCredentialsDetected) (\s :: EventRiskType
s@EventRiskType' {} Maybe Bool
a -> EventRiskType
s {$sel:compromisedCredentialsDetected:EventRiskType' :: Maybe Bool
compromisedCredentialsDetected = Maybe Bool
a} :: EventRiskType)

-- | The risk level.
eventRiskType_riskLevel :: Lens.Lens' EventRiskType (Prelude.Maybe RiskLevelType)
eventRiskType_riskLevel :: (Maybe RiskLevelType -> f (Maybe RiskLevelType))
-> EventRiskType -> f EventRiskType
eventRiskType_riskLevel = (EventRiskType -> Maybe RiskLevelType)
-> (EventRiskType -> Maybe RiskLevelType -> EventRiskType)
-> Lens
     EventRiskType
     EventRiskType
     (Maybe RiskLevelType)
     (Maybe RiskLevelType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventRiskType' {Maybe RiskLevelType
riskLevel :: Maybe RiskLevelType
$sel:riskLevel:EventRiskType' :: EventRiskType -> Maybe RiskLevelType
riskLevel} -> Maybe RiskLevelType
riskLevel) (\s :: EventRiskType
s@EventRiskType' {} Maybe RiskLevelType
a -> EventRiskType
s {$sel:riskLevel:EventRiskType' :: Maybe RiskLevelType
riskLevel = Maybe RiskLevelType
a} :: EventRiskType)

-- | The risk decision.
eventRiskType_riskDecision :: Lens.Lens' EventRiskType (Prelude.Maybe RiskDecisionType)
eventRiskType_riskDecision :: (Maybe RiskDecisionType -> f (Maybe RiskDecisionType))
-> EventRiskType -> f EventRiskType
eventRiskType_riskDecision = (EventRiskType -> Maybe RiskDecisionType)
-> (EventRiskType -> Maybe RiskDecisionType -> EventRiskType)
-> Lens
     EventRiskType
     EventRiskType
     (Maybe RiskDecisionType)
     (Maybe RiskDecisionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventRiskType' {Maybe RiskDecisionType
riskDecision :: Maybe RiskDecisionType
$sel:riskDecision:EventRiskType' :: EventRiskType -> Maybe RiskDecisionType
riskDecision} -> Maybe RiskDecisionType
riskDecision) (\s :: EventRiskType
s@EventRiskType' {} Maybe RiskDecisionType
a -> EventRiskType
s {$sel:riskDecision:EventRiskType' :: Maybe RiskDecisionType
riskDecision = Maybe RiskDecisionType
a} :: EventRiskType)

instance Core.FromJSON EventRiskType where
  parseJSON :: Value -> Parser EventRiskType
parseJSON =
    String
-> (Object -> Parser EventRiskType)
-> Value
-> Parser EventRiskType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventRiskType"
      ( \Object
x ->
          Maybe Bool
-> Maybe RiskLevelType -> Maybe RiskDecisionType -> EventRiskType
EventRiskType'
            (Maybe Bool
 -> Maybe RiskLevelType -> Maybe RiskDecisionType -> EventRiskType)
-> Parser (Maybe Bool)
-> Parser
     (Maybe RiskLevelType -> Maybe RiskDecisionType -> EventRiskType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CompromisedCredentialsDetected")
            Parser
  (Maybe RiskLevelType -> Maybe RiskDecisionType -> EventRiskType)
-> Parser (Maybe RiskLevelType)
-> Parser (Maybe RiskDecisionType -> EventRiskType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RiskLevelType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RiskLevel")
            Parser (Maybe RiskDecisionType -> EventRiskType)
-> Parser (Maybe RiskDecisionType) -> Parser EventRiskType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RiskDecisionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RiskDecision")
      )

instance Prelude.Hashable EventRiskType

instance Prelude.NFData EventRiskType