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

import Amazonka.CognitoIdentityProvider.Types.AttributeType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The device type.
--
-- /See:/ 'newDeviceType' smart constructor.
data DeviceType = DeviceType'
  { -- | The last modified date of the device.
    DeviceType -> Maybe POSIX
deviceLastModifiedDate :: Prelude.Maybe Core.POSIX,
    -- | The creation date of the device.
    DeviceType -> Maybe POSIX
deviceCreateDate :: Prelude.Maybe Core.POSIX,
    -- | The device attributes.
    DeviceType -> Maybe [AttributeType]
deviceAttributes :: Prelude.Maybe [AttributeType],
    -- | The device key.
    DeviceType -> Maybe Text
deviceKey :: Prelude.Maybe Prelude.Text,
    -- | The date in which the device was last authenticated.
    DeviceType -> Maybe POSIX
deviceLastAuthenticatedDate :: Prelude.Maybe Core.POSIX
  }
  deriving (DeviceType -> DeviceType -> Bool
(DeviceType -> DeviceType -> Bool)
-> (DeviceType -> DeviceType -> Bool) -> Eq DeviceType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceType -> DeviceType -> Bool
$c/= :: DeviceType -> DeviceType -> Bool
== :: DeviceType -> DeviceType -> Bool
$c== :: DeviceType -> DeviceType -> Bool
Prelude.Eq, Int -> DeviceType -> ShowS
[DeviceType] -> ShowS
DeviceType -> String
(Int -> DeviceType -> ShowS)
-> (DeviceType -> String)
-> ([DeviceType] -> ShowS)
-> Show DeviceType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceType] -> ShowS
$cshowList :: [DeviceType] -> ShowS
show :: DeviceType -> String
$cshow :: DeviceType -> String
showsPrec :: Int -> DeviceType -> ShowS
$cshowsPrec :: Int -> DeviceType -> ShowS
Prelude.Show, (forall x. DeviceType -> Rep DeviceType x)
-> (forall x. Rep DeviceType x -> DeviceType) -> Generic DeviceType
forall x. Rep DeviceType x -> DeviceType
forall x. DeviceType -> Rep DeviceType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeviceType x -> DeviceType
$cfrom :: forall x. DeviceType -> Rep DeviceType x
Prelude.Generic)

-- |
-- Create a value of 'DeviceType' 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:
--
-- 'deviceLastModifiedDate', 'deviceType_deviceLastModifiedDate' - The last modified date of the device.
--
-- 'deviceCreateDate', 'deviceType_deviceCreateDate' - The creation date of the device.
--
-- 'deviceAttributes', 'deviceType_deviceAttributes' - The device attributes.
--
-- 'deviceKey', 'deviceType_deviceKey' - The device key.
--
-- 'deviceLastAuthenticatedDate', 'deviceType_deviceLastAuthenticatedDate' - The date in which the device was last authenticated.
newDeviceType ::
  DeviceType
newDeviceType :: DeviceType
newDeviceType =
  DeviceType' :: Maybe POSIX
-> Maybe POSIX
-> Maybe [AttributeType]
-> Maybe Text
-> Maybe POSIX
-> DeviceType
DeviceType'
    { $sel:deviceLastModifiedDate:DeviceType' :: Maybe POSIX
deviceLastModifiedDate =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceCreateDate:DeviceType' :: Maybe POSIX
deviceCreateDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceAttributes:DeviceType' :: Maybe [AttributeType]
deviceAttributes = Maybe [AttributeType]
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceKey:DeviceType' :: Maybe Text
deviceKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceLastAuthenticatedDate:DeviceType' :: Maybe POSIX
deviceLastAuthenticatedDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The last modified date of the device.
deviceType_deviceLastModifiedDate :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.UTCTime)
deviceType_deviceLastModifiedDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> DeviceType -> f DeviceType
deviceType_deviceLastModifiedDate = (DeviceType -> Maybe POSIX)
-> (DeviceType -> Maybe POSIX -> DeviceType)
-> Lens DeviceType DeviceType (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceType' {Maybe POSIX
deviceLastModifiedDate :: Maybe POSIX
$sel:deviceLastModifiedDate:DeviceType' :: DeviceType -> Maybe POSIX
deviceLastModifiedDate} -> Maybe POSIX
deviceLastModifiedDate) (\s :: DeviceType
s@DeviceType' {} Maybe POSIX
a -> DeviceType
s {$sel:deviceLastModifiedDate:DeviceType' :: Maybe POSIX
deviceLastModifiedDate = Maybe POSIX
a} :: DeviceType) ((Maybe POSIX -> f (Maybe POSIX)) -> DeviceType -> f DeviceType)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DeviceType
-> f DeviceType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The creation date of the device.
deviceType_deviceCreateDate :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.UTCTime)
deviceType_deviceCreateDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> DeviceType -> f DeviceType
deviceType_deviceCreateDate = (DeviceType -> Maybe POSIX)
-> (DeviceType -> Maybe POSIX -> DeviceType)
-> Lens DeviceType DeviceType (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceType' {Maybe POSIX
deviceCreateDate :: Maybe POSIX
$sel:deviceCreateDate:DeviceType' :: DeviceType -> Maybe POSIX
deviceCreateDate} -> Maybe POSIX
deviceCreateDate) (\s :: DeviceType
s@DeviceType' {} Maybe POSIX
a -> DeviceType
s {$sel:deviceCreateDate:DeviceType' :: Maybe POSIX
deviceCreateDate = Maybe POSIX
a} :: DeviceType) ((Maybe POSIX -> f (Maybe POSIX)) -> DeviceType -> f DeviceType)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DeviceType
-> f DeviceType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The device attributes.
deviceType_deviceAttributes :: Lens.Lens' DeviceType (Prelude.Maybe [AttributeType])
deviceType_deviceAttributes :: (Maybe [AttributeType] -> f (Maybe [AttributeType]))
-> DeviceType -> f DeviceType
deviceType_deviceAttributes = (DeviceType -> Maybe [AttributeType])
-> (DeviceType -> Maybe [AttributeType] -> DeviceType)
-> Lens
     DeviceType
     DeviceType
     (Maybe [AttributeType])
     (Maybe [AttributeType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceType' {Maybe [AttributeType]
deviceAttributes :: Maybe [AttributeType]
$sel:deviceAttributes:DeviceType' :: DeviceType -> Maybe [AttributeType]
deviceAttributes} -> Maybe [AttributeType]
deviceAttributes) (\s :: DeviceType
s@DeviceType' {} Maybe [AttributeType]
a -> DeviceType
s {$sel:deviceAttributes:DeviceType' :: Maybe [AttributeType]
deviceAttributes = Maybe [AttributeType]
a} :: DeviceType) ((Maybe [AttributeType] -> f (Maybe [AttributeType]))
 -> DeviceType -> f DeviceType)
-> ((Maybe [AttributeType] -> f (Maybe [AttributeType]))
    -> Maybe [AttributeType] -> f (Maybe [AttributeType]))
-> (Maybe [AttributeType] -> f (Maybe [AttributeType]))
-> DeviceType
-> f DeviceType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AttributeType] [AttributeType] [AttributeType] [AttributeType]
-> Iso
     (Maybe [AttributeType])
     (Maybe [AttributeType])
     (Maybe [AttributeType])
     (Maybe [AttributeType])
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
  [AttributeType] [AttributeType] [AttributeType] [AttributeType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The device key.
deviceType_deviceKey :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.Text)
deviceType_deviceKey :: (Maybe Text -> f (Maybe Text)) -> DeviceType -> f DeviceType
deviceType_deviceKey = (DeviceType -> Maybe Text)
-> (DeviceType -> Maybe Text -> DeviceType)
-> Lens DeviceType DeviceType (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceType' {Maybe Text
deviceKey :: Maybe Text
$sel:deviceKey:DeviceType' :: DeviceType -> Maybe Text
deviceKey} -> Maybe Text
deviceKey) (\s :: DeviceType
s@DeviceType' {} Maybe Text
a -> DeviceType
s {$sel:deviceKey:DeviceType' :: Maybe Text
deviceKey = Maybe Text
a} :: DeviceType)

-- | The date in which the device was last authenticated.
deviceType_deviceLastAuthenticatedDate :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.UTCTime)
deviceType_deviceLastAuthenticatedDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> DeviceType -> f DeviceType
deviceType_deviceLastAuthenticatedDate = (DeviceType -> Maybe POSIX)
-> (DeviceType -> Maybe POSIX -> DeviceType)
-> Lens DeviceType DeviceType (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceType' {Maybe POSIX
deviceLastAuthenticatedDate :: Maybe POSIX
$sel:deviceLastAuthenticatedDate:DeviceType' :: DeviceType -> Maybe POSIX
deviceLastAuthenticatedDate} -> Maybe POSIX
deviceLastAuthenticatedDate) (\s :: DeviceType
s@DeviceType' {} Maybe POSIX
a -> DeviceType
s {$sel:deviceLastAuthenticatedDate:DeviceType' :: Maybe POSIX
deviceLastAuthenticatedDate = Maybe POSIX
a} :: DeviceType) ((Maybe POSIX -> f (Maybe POSIX)) -> DeviceType -> f DeviceType)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DeviceType
-> f DeviceType
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON DeviceType where
  parseJSON :: Value -> Parser DeviceType
parseJSON =
    String
-> (Object -> Parser DeviceType) -> Value -> Parser DeviceType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeviceType"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe [AttributeType]
-> Maybe Text
-> Maybe POSIX
-> DeviceType
DeviceType'
            (Maybe POSIX
 -> Maybe POSIX
 -> Maybe [AttributeType]
 -> Maybe Text
 -> Maybe POSIX
 -> DeviceType)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Maybe [AttributeType]
      -> Maybe Text
      -> Maybe POSIX
      -> DeviceType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeviceLastModifiedDate")
            Parser
  (Maybe POSIX
   -> Maybe [AttributeType]
   -> Maybe Text
   -> Maybe POSIX
   -> DeviceType)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe [AttributeType] -> Maybe Text -> Maybe POSIX -> DeviceType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeviceCreateDate")
            Parser
  (Maybe [AttributeType] -> Maybe Text -> Maybe POSIX -> DeviceType)
-> Parser (Maybe [AttributeType])
-> Parser (Maybe Text -> Maybe POSIX -> DeviceType)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [AttributeType]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeviceAttributes"
                            Parser (Maybe (Maybe [AttributeType]))
-> Maybe [AttributeType] -> Parser (Maybe [AttributeType])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AttributeType]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Maybe POSIX -> DeviceType)
-> Parser (Maybe Text) -> Parser (Maybe POSIX -> DeviceType)
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
"DeviceKey")
            Parser (Maybe POSIX -> DeviceType)
-> Parser (Maybe POSIX) -> Parser DeviceType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DeviceLastAuthenticatedDate")
      )

instance Prelude.Hashable DeviceType

instance Prelude.NFData DeviceType