{-# 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.CognitoSync.Types.Record
-- 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.CognitoSync.Types.Record where

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

-- | The basic data structure of a dataset.
--
-- /See:/ 'newRecord' smart constructor.
data Record = Record'
  { -- | The server sync count for this record.
    Record -> Maybe Integer
syncCount :: Prelude.Maybe Prelude.Integer,
    -- | The last modified date of the client device.
    Record -> Maybe POSIX
deviceLastModifiedDate :: Prelude.Maybe Core.POSIX,
    -- | The date on which the record was last modified.
    Record -> Maybe POSIX
lastModifiedDate :: Prelude.Maybe Core.POSIX,
    -- | The value for the record.
    Record -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The key for the record.
    Record -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The user\/device that made the last change to this record.
    Record -> Maybe Text
lastModifiedBy :: Prelude.Maybe Prelude.Text
  }
  deriving (Record -> Record -> Bool
(Record -> Record -> Bool)
-> (Record -> Record -> Bool) -> Eq Record
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Record -> Record -> Bool
$c/= :: Record -> Record -> Bool
== :: Record -> Record -> Bool
$c== :: Record -> Record -> Bool
Prelude.Eq, ReadPrec [Record]
ReadPrec Record
Int -> ReadS Record
ReadS [Record]
(Int -> ReadS Record)
-> ReadS [Record]
-> ReadPrec Record
-> ReadPrec [Record]
-> Read Record
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Record]
$creadListPrec :: ReadPrec [Record]
readPrec :: ReadPrec Record
$creadPrec :: ReadPrec Record
readList :: ReadS [Record]
$creadList :: ReadS [Record]
readsPrec :: Int -> ReadS Record
$creadsPrec :: Int -> ReadS Record
Prelude.Read, Int -> Record -> ShowS
[Record] -> ShowS
Record -> String
(Int -> Record -> ShowS)
-> (Record -> String) -> ([Record] -> ShowS) -> Show Record
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Record] -> ShowS
$cshowList :: [Record] -> ShowS
show :: Record -> String
$cshow :: Record -> String
showsPrec :: Int -> Record -> ShowS
$cshowsPrec :: Int -> Record -> ShowS
Prelude.Show, (forall x. Record -> Rep Record x)
-> (forall x. Rep Record x -> Record) -> Generic Record
forall x. Rep Record x -> Record
forall x. Record -> Rep Record x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Record x -> Record
$cfrom :: forall x. Record -> Rep Record x
Prelude.Generic)

-- |
-- Create a value of 'Record' 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:
--
-- 'syncCount', 'record_syncCount' - The server sync count for this record.
--
-- 'deviceLastModifiedDate', 'record_deviceLastModifiedDate' - The last modified date of the client device.
--
-- 'lastModifiedDate', 'record_lastModifiedDate' - The date on which the record was last modified.
--
-- 'value', 'record_value' - The value for the record.
--
-- 'key', 'record_key' - The key for the record.
--
-- 'lastModifiedBy', 'record_lastModifiedBy' - The user\/device that made the last change to this record.
newRecord ::
  Record
newRecord :: Record
newRecord =
  Record' :: Maybe Integer
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Record
Record'
    { $sel:syncCount:Record' :: Maybe Integer
syncCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:deviceLastModifiedDate:Record' :: Maybe POSIX
deviceLastModifiedDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedDate:Record' :: Maybe POSIX
lastModifiedDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:value:Record' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:Record' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedBy:Record' :: Maybe Text
lastModifiedBy = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The server sync count for this record.
record_syncCount :: Lens.Lens' Record (Prelude.Maybe Prelude.Integer)
record_syncCount :: (Maybe Integer -> f (Maybe Integer)) -> Record -> f Record
record_syncCount = (Record -> Maybe Integer)
-> (Record -> Maybe Integer -> Record)
-> Lens Record Record (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe Integer
syncCount :: Maybe Integer
$sel:syncCount:Record' :: Record -> Maybe Integer
syncCount} -> Maybe Integer
syncCount) (\s :: Record
s@Record' {} Maybe Integer
a -> Record
s {$sel:syncCount:Record' :: Maybe Integer
syncCount = Maybe Integer
a} :: Record)

-- | The last modified date of the client device.
record_deviceLastModifiedDate :: Lens.Lens' Record (Prelude.Maybe Prelude.UTCTime)
record_deviceLastModifiedDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Record -> f Record
record_deviceLastModifiedDate = (Record -> Maybe POSIX)
-> (Record -> Maybe POSIX -> Record)
-> Lens Record Record (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe POSIX
deviceLastModifiedDate :: Maybe POSIX
$sel:deviceLastModifiedDate:Record' :: Record -> Maybe POSIX
deviceLastModifiedDate} -> Maybe POSIX
deviceLastModifiedDate) (\s :: Record
s@Record' {} Maybe POSIX
a -> Record
s {$sel:deviceLastModifiedDate:Record' :: Maybe POSIX
deviceLastModifiedDate = Maybe POSIX
a} :: Record) ((Maybe POSIX -> f (Maybe POSIX)) -> Record -> f Record)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Record
-> f Record
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 date on which the record was last modified.
record_lastModifiedDate :: Lens.Lens' Record (Prelude.Maybe Prelude.UTCTime)
record_lastModifiedDate :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Record -> f Record
record_lastModifiedDate = (Record -> Maybe POSIX)
-> (Record -> Maybe POSIX -> Record)
-> Lens Record Record (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe POSIX
lastModifiedDate :: Maybe POSIX
$sel:lastModifiedDate:Record' :: Record -> Maybe POSIX
lastModifiedDate} -> Maybe POSIX
lastModifiedDate) (\s :: Record
s@Record' {} Maybe POSIX
a -> Record
s {$sel:lastModifiedDate:Record' :: Maybe POSIX
lastModifiedDate = Maybe POSIX
a} :: Record) ((Maybe POSIX -> f (Maybe POSIX)) -> Record -> f Record)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Record
-> f Record
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 value for the record.
record_value :: Lens.Lens' Record (Prelude.Maybe Prelude.Text)
record_value :: (Maybe Text -> f (Maybe Text)) -> Record -> f Record
record_value = (Record -> Maybe Text)
-> (Record -> Maybe Text -> Record)
-> Lens Record Record (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe Text
value :: Maybe Text
$sel:value:Record' :: Record -> Maybe Text
value} -> Maybe Text
value) (\s :: Record
s@Record' {} Maybe Text
a -> Record
s {$sel:value:Record' :: Maybe Text
value = Maybe Text
a} :: Record)

-- | The key for the record.
record_key :: Lens.Lens' Record (Prelude.Maybe Prelude.Text)
record_key :: (Maybe Text -> f (Maybe Text)) -> Record -> f Record
record_key = (Record -> Maybe Text)
-> (Record -> Maybe Text -> Record)
-> Lens Record Record (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe Text
key :: Maybe Text
$sel:key:Record' :: Record -> Maybe Text
key} -> Maybe Text
key) (\s :: Record
s@Record' {} Maybe Text
a -> Record
s {$sel:key:Record' :: Maybe Text
key = Maybe Text
a} :: Record)

-- | The user\/device that made the last change to this record.
record_lastModifiedBy :: Lens.Lens' Record (Prelude.Maybe Prelude.Text)
record_lastModifiedBy :: (Maybe Text -> f (Maybe Text)) -> Record -> f Record
record_lastModifiedBy = (Record -> Maybe Text)
-> (Record -> Maybe Text -> Record)
-> Lens Record Record (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe Text
lastModifiedBy :: Maybe Text
$sel:lastModifiedBy:Record' :: Record -> Maybe Text
lastModifiedBy} -> Maybe Text
lastModifiedBy) (\s :: Record
s@Record' {} Maybe Text
a -> Record
s {$sel:lastModifiedBy:Record' :: Maybe Text
lastModifiedBy = Maybe Text
a} :: Record)

instance Core.FromJSON Record where
  parseJSON :: Value -> Parser Record
parseJSON =
    String -> (Object -> Parser Record) -> Value -> Parser Record
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Record"
      ( \Object
x ->
          Maybe Integer
-> Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Record
Record'
            (Maybe Integer
 -> Maybe POSIX
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Record)
-> Parser (Maybe Integer)
-> Parser
     (Maybe POSIX
      -> Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Record)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SyncCount")
            Parser
  (Maybe POSIX
   -> Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Record)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Record)
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
"DeviceLastModifiedDate")
            Parser
  (Maybe POSIX -> Maybe Text -> Maybe Text -> Maybe Text -> Record)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> Record)
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
"LastModifiedDate")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> Record)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Record)
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
"Value")
            Parser (Maybe Text -> Maybe Text -> Record)
-> Parser (Maybe Text) -> Parser (Maybe Text -> Record)
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
"Key")
            Parser (Maybe Text -> Record)
-> Parser (Maybe Text) -> Parser Record
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
"LastModifiedBy")
      )

instance Prelude.Hashable Record

instance Prelude.NFData Record