{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The device type.
--
-- /See:/ 'newDeviceType' smart constructor.
data DeviceType = DeviceType'
  { -- | The device attributes.
    DeviceType -> Maybe [AttributeType]
deviceAttributes :: Prelude.Maybe [AttributeType],
    -- | The creation date of the device.
    DeviceType -> Maybe POSIX
deviceCreateDate :: Prelude.Maybe Data.POSIX,
    -- | The device key.
    DeviceType -> Maybe Text
deviceKey :: Prelude.Maybe Prelude.Text,
    -- | The date when the device was last authenticated.
    DeviceType -> Maybe POSIX
deviceLastAuthenticatedDate :: Prelude.Maybe Data.POSIX,
    -- | The last modified date of the device.
    DeviceType -> Maybe POSIX
deviceLastModifiedDate :: Prelude.Maybe Data.POSIX
  }
  deriving (DeviceType -> DeviceType -> Bool
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
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. 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:
--
-- 'deviceAttributes', 'deviceType_deviceAttributes' - The device attributes.
--
-- 'deviceCreateDate', 'deviceType_deviceCreateDate' - The creation date of the device.
--
-- 'deviceKey', 'deviceType_deviceKey' - The device key.
--
-- 'deviceLastAuthenticatedDate', 'deviceType_deviceLastAuthenticatedDate' - The date when the device was last authenticated.
--
-- 'deviceLastModifiedDate', 'deviceType_deviceLastModifiedDate' - The last modified date of the device.
newDeviceType ::
  DeviceType
newDeviceType :: DeviceType
newDeviceType =
  DeviceType'
    { $sel:deviceAttributes:DeviceType' :: Maybe [AttributeType]
deviceAttributes = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceCreateDate:DeviceType' :: Maybe POSIX
deviceCreateDate = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceKey:DeviceType' :: Maybe Text
deviceKey = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceLastAuthenticatedDate:DeviceType' :: Maybe POSIX
deviceLastAuthenticatedDate = forall a. Maybe a
Prelude.Nothing,
      $sel:deviceLastModifiedDate:DeviceType' :: Maybe POSIX
deviceLastModifiedDate = forall a. Maybe a
Prelude.Nothing
    }

-- | The device attributes.
deviceType_deviceAttributes :: Lens.Lens' DeviceType (Prelude.Maybe [AttributeType])
deviceType_deviceAttributes :: Lens' DeviceType (Maybe [AttributeType])
deviceType_deviceAttributes = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The creation date of the device.
deviceType_deviceCreateDate :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.UTCTime)
deviceType_deviceCreateDate :: Lens' DeviceType (Maybe UTCTime)
deviceType_deviceCreateDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The device key.
deviceType_deviceKey :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.Text)
deviceType_deviceKey :: Lens' DeviceType (Maybe Text)
deviceType_deviceKey = 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 when the device was last authenticated.
deviceType_deviceLastAuthenticatedDate :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.UTCTime)
deviceType_deviceLastAuthenticatedDate :: Lens' DeviceType (Maybe UTCTime)
deviceType_deviceLastAuthenticatedDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The last modified date of the device.
deviceType_deviceLastModifiedDate :: Lens.Lens' DeviceType (Prelude.Maybe Prelude.UTCTime)
deviceType_deviceLastModifiedDate :: Lens' DeviceType (Maybe UTCTime)
deviceType_deviceLastModifiedDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

instance Prelude.Hashable DeviceType where
  hashWithSalt :: Int -> DeviceType -> Int
hashWithSalt Int
_salt DeviceType' {Maybe [AttributeType]
Maybe Text
Maybe POSIX
deviceLastModifiedDate :: Maybe POSIX
deviceLastAuthenticatedDate :: Maybe POSIX
deviceKey :: Maybe Text
deviceCreateDate :: Maybe POSIX
deviceAttributes :: Maybe [AttributeType]
$sel:deviceLastModifiedDate:DeviceType' :: DeviceType -> Maybe POSIX
$sel:deviceLastAuthenticatedDate:DeviceType' :: DeviceType -> Maybe POSIX
$sel:deviceKey:DeviceType' :: DeviceType -> Maybe Text
$sel:deviceCreateDate:DeviceType' :: DeviceType -> Maybe POSIX
$sel:deviceAttributes:DeviceType' :: DeviceType -> Maybe [AttributeType]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AttributeType]
deviceAttributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
deviceCreateDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
deviceKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
deviceLastAuthenticatedDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
deviceLastModifiedDate

instance Prelude.NFData DeviceType where
  rnf :: DeviceType -> ()
rnf DeviceType' {Maybe [AttributeType]
Maybe Text
Maybe POSIX
deviceLastModifiedDate :: Maybe POSIX
deviceLastAuthenticatedDate :: Maybe POSIX
deviceKey :: Maybe Text
deviceCreateDate :: Maybe POSIX
deviceAttributes :: Maybe [AttributeType]
$sel:deviceLastModifiedDate:DeviceType' :: DeviceType -> Maybe POSIX
$sel:deviceLastAuthenticatedDate:DeviceType' :: DeviceType -> Maybe POSIX
$sel:deviceKey:DeviceType' :: DeviceType -> Maybe Text
$sel:deviceCreateDate:DeviceType' :: DeviceType -> Maybe POSIX
$sel:deviceAttributes:DeviceType' :: DeviceType -> Maybe [AttributeType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AttributeType]
deviceAttributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
deviceCreateDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
deviceKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
deviceLastAuthenticatedDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
deviceLastModifiedDate