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

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

-- | Specifies the user context data captured at the time of an event
-- request.
--
-- /See:/ 'newEventContextDataType' smart constructor.
data EventContextDataType = EventContextDataType'
  { -- | The user\'s IP address.
    EventContextDataType -> Maybe Text
ipAddress :: Prelude.Maybe Prelude.Text,
    -- | The user\'s country.
    EventContextDataType -> Maybe Text
country :: Prelude.Maybe Prelude.Text,
    -- | The user\'s city.
    EventContextDataType -> Maybe Text
city :: Prelude.Maybe Prelude.Text,
    -- | The user\'s device name.
    EventContextDataType -> Maybe Text
deviceName :: Prelude.Maybe Prelude.Text,
    -- | The user\'s time zone.
    EventContextDataType -> Maybe Text
timezone :: Prelude.Maybe Prelude.Text
  }
  deriving (EventContextDataType -> EventContextDataType -> Bool
(EventContextDataType -> EventContextDataType -> Bool)
-> (EventContextDataType -> EventContextDataType -> Bool)
-> Eq EventContextDataType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventContextDataType -> EventContextDataType -> Bool
$c/= :: EventContextDataType -> EventContextDataType -> Bool
== :: EventContextDataType -> EventContextDataType -> Bool
$c== :: EventContextDataType -> EventContextDataType -> Bool
Prelude.Eq, ReadPrec [EventContextDataType]
ReadPrec EventContextDataType
Int -> ReadS EventContextDataType
ReadS [EventContextDataType]
(Int -> ReadS EventContextDataType)
-> ReadS [EventContextDataType]
-> ReadPrec EventContextDataType
-> ReadPrec [EventContextDataType]
-> Read EventContextDataType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventContextDataType]
$creadListPrec :: ReadPrec [EventContextDataType]
readPrec :: ReadPrec EventContextDataType
$creadPrec :: ReadPrec EventContextDataType
readList :: ReadS [EventContextDataType]
$creadList :: ReadS [EventContextDataType]
readsPrec :: Int -> ReadS EventContextDataType
$creadsPrec :: Int -> ReadS EventContextDataType
Prelude.Read, Int -> EventContextDataType -> ShowS
[EventContextDataType] -> ShowS
EventContextDataType -> String
(Int -> EventContextDataType -> ShowS)
-> (EventContextDataType -> String)
-> ([EventContextDataType] -> ShowS)
-> Show EventContextDataType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventContextDataType] -> ShowS
$cshowList :: [EventContextDataType] -> ShowS
show :: EventContextDataType -> String
$cshow :: EventContextDataType -> String
showsPrec :: Int -> EventContextDataType -> ShowS
$cshowsPrec :: Int -> EventContextDataType -> ShowS
Prelude.Show, (forall x. EventContextDataType -> Rep EventContextDataType x)
-> (forall x. Rep EventContextDataType x -> EventContextDataType)
-> Generic EventContextDataType
forall x. Rep EventContextDataType x -> EventContextDataType
forall x. EventContextDataType -> Rep EventContextDataType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventContextDataType x -> EventContextDataType
$cfrom :: forall x. EventContextDataType -> Rep EventContextDataType x
Prelude.Generic)

-- |
-- Create a value of 'EventContextDataType' 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:
--
-- 'ipAddress', 'eventContextDataType_ipAddress' - The user\'s IP address.
--
-- 'country', 'eventContextDataType_country' - The user\'s country.
--
-- 'city', 'eventContextDataType_city' - The user\'s city.
--
-- 'deviceName', 'eventContextDataType_deviceName' - The user\'s device name.
--
-- 'timezone', 'eventContextDataType_timezone' - The user\'s time zone.
newEventContextDataType ::
  EventContextDataType
newEventContextDataType :: EventContextDataType
newEventContextDataType =
  EventContextDataType' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> EventContextDataType
EventContextDataType'
    { $sel:ipAddress:EventContextDataType' :: Maybe Text
ipAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:country:EventContextDataType' :: Maybe Text
country = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:city:EventContextDataType' :: Maybe Text
city = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceName:EventContextDataType' :: Maybe Text
deviceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timezone:EventContextDataType' :: Maybe Text
timezone = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The user\'s IP address.
eventContextDataType_ipAddress :: Lens.Lens' EventContextDataType (Prelude.Maybe Prelude.Text)
eventContextDataType_ipAddress :: (Maybe Text -> f (Maybe Text))
-> EventContextDataType -> f EventContextDataType
eventContextDataType_ipAddress = (EventContextDataType -> Maybe Text)
-> (EventContextDataType -> Maybe Text -> EventContextDataType)
-> Lens
     EventContextDataType EventContextDataType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventContextDataType' {Maybe Text
ipAddress :: Maybe Text
$sel:ipAddress:EventContextDataType' :: EventContextDataType -> Maybe Text
ipAddress} -> Maybe Text
ipAddress) (\s :: EventContextDataType
s@EventContextDataType' {} Maybe Text
a -> EventContextDataType
s {$sel:ipAddress:EventContextDataType' :: Maybe Text
ipAddress = Maybe Text
a} :: EventContextDataType)

-- | The user\'s country.
eventContextDataType_country :: Lens.Lens' EventContextDataType (Prelude.Maybe Prelude.Text)
eventContextDataType_country :: (Maybe Text -> f (Maybe Text))
-> EventContextDataType -> f EventContextDataType
eventContextDataType_country = (EventContextDataType -> Maybe Text)
-> (EventContextDataType -> Maybe Text -> EventContextDataType)
-> Lens
     EventContextDataType EventContextDataType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventContextDataType' {Maybe Text
country :: Maybe Text
$sel:country:EventContextDataType' :: EventContextDataType -> Maybe Text
country} -> Maybe Text
country) (\s :: EventContextDataType
s@EventContextDataType' {} Maybe Text
a -> EventContextDataType
s {$sel:country:EventContextDataType' :: Maybe Text
country = Maybe Text
a} :: EventContextDataType)

-- | The user\'s city.
eventContextDataType_city :: Lens.Lens' EventContextDataType (Prelude.Maybe Prelude.Text)
eventContextDataType_city :: (Maybe Text -> f (Maybe Text))
-> EventContextDataType -> f EventContextDataType
eventContextDataType_city = (EventContextDataType -> Maybe Text)
-> (EventContextDataType -> Maybe Text -> EventContextDataType)
-> Lens
     EventContextDataType EventContextDataType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventContextDataType' {Maybe Text
city :: Maybe Text
$sel:city:EventContextDataType' :: EventContextDataType -> Maybe Text
city} -> Maybe Text
city) (\s :: EventContextDataType
s@EventContextDataType' {} Maybe Text
a -> EventContextDataType
s {$sel:city:EventContextDataType' :: Maybe Text
city = Maybe Text
a} :: EventContextDataType)

-- | The user\'s device name.
eventContextDataType_deviceName :: Lens.Lens' EventContextDataType (Prelude.Maybe Prelude.Text)
eventContextDataType_deviceName :: (Maybe Text -> f (Maybe Text))
-> EventContextDataType -> f EventContextDataType
eventContextDataType_deviceName = (EventContextDataType -> Maybe Text)
-> (EventContextDataType -> Maybe Text -> EventContextDataType)
-> Lens
     EventContextDataType EventContextDataType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventContextDataType' {Maybe Text
deviceName :: Maybe Text
$sel:deviceName:EventContextDataType' :: EventContextDataType -> Maybe Text
deviceName} -> Maybe Text
deviceName) (\s :: EventContextDataType
s@EventContextDataType' {} Maybe Text
a -> EventContextDataType
s {$sel:deviceName:EventContextDataType' :: Maybe Text
deviceName = Maybe Text
a} :: EventContextDataType)

-- | The user\'s time zone.
eventContextDataType_timezone :: Lens.Lens' EventContextDataType (Prelude.Maybe Prelude.Text)
eventContextDataType_timezone :: (Maybe Text -> f (Maybe Text))
-> EventContextDataType -> f EventContextDataType
eventContextDataType_timezone = (EventContextDataType -> Maybe Text)
-> (EventContextDataType -> Maybe Text -> EventContextDataType)
-> Lens
     EventContextDataType EventContextDataType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventContextDataType' {Maybe Text
timezone :: Maybe Text
$sel:timezone:EventContextDataType' :: EventContextDataType -> Maybe Text
timezone} -> Maybe Text
timezone) (\s :: EventContextDataType
s@EventContextDataType' {} Maybe Text
a -> EventContextDataType
s {$sel:timezone:EventContextDataType' :: Maybe Text
timezone = Maybe Text
a} :: EventContextDataType)

instance Core.FromJSON EventContextDataType where
  parseJSON :: Value -> Parser EventContextDataType
parseJSON =
    String
-> (Object -> Parser EventContextDataType)
-> Value
-> Parser EventContextDataType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EventContextDataType"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> EventContextDataType
EventContextDataType'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> EventContextDataType)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Text -> EventContextDataType)
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
"IpAddress")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Text -> EventContextDataType)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> EventContextDataType)
forall (f :: * -> *) a b. Applicative f => 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
"Country")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> EventContextDataType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> EventContextDataType)
forall (f :: * -> *) a b. Applicative f => 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
"City")
            Parser (Maybe Text -> Maybe Text -> EventContextDataType)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> EventContextDataType)
forall (f :: * -> *) a b. Applicative f => 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
"DeviceName")
            Parser (Maybe Text -> EventContextDataType)
-> Parser (Maybe Text) -> Parser EventContextDataType
forall (f :: * -> *) a b. Applicative f => 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
"Timezone")
      )

instance Prelude.Hashable EventContextDataType

instance Prelude.NFData EventContextDataType