{-# 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.IoT.Types.TransferData
-- 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.IoT.Types.TransferData where

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

-- | Data used to transfer a certificate to an Amazon Web Services account.
--
-- /See:/ 'newTransferData' smart constructor.
data TransferData = TransferData'
  { -- | The date the transfer took place.
    TransferData -> Maybe POSIX
transferDate :: Prelude.Maybe Core.POSIX,
    -- | The date the transfer was accepted.
    TransferData -> Maybe POSIX
acceptDate :: Prelude.Maybe Core.POSIX,
    -- | The transfer message.
    TransferData -> Maybe Text
transferMessage :: Prelude.Maybe Prelude.Text,
    -- | The date the transfer was rejected.
    TransferData -> Maybe POSIX
rejectDate :: Prelude.Maybe Core.POSIX,
    -- | The reason why the transfer was rejected.
    TransferData -> Maybe Text
rejectReason :: Prelude.Maybe Prelude.Text
  }
  deriving (TransferData -> TransferData -> Bool
(TransferData -> TransferData -> Bool)
-> (TransferData -> TransferData -> Bool) -> Eq TransferData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransferData -> TransferData -> Bool
$c/= :: TransferData -> TransferData -> Bool
== :: TransferData -> TransferData -> Bool
$c== :: TransferData -> TransferData -> Bool
Prelude.Eq, ReadPrec [TransferData]
ReadPrec TransferData
Int -> ReadS TransferData
ReadS [TransferData]
(Int -> ReadS TransferData)
-> ReadS [TransferData]
-> ReadPrec TransferData
-> ReadPrec [TransferData]
-> Read TransferData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransferData]
$creadListPrec :: ReadPrec [TransferData]
readPrec :: ReadPrec TransferData
$creadPrec :: ReadPrec TransferData
readList :: ReadS [TransferData]
$creadList :: ReadS [TransferData]
readsPrec :: Int -> ReadS TransferData
$creadsPrec :: Int -> ReadS TransferData
Prelude.Read, Int -> TransferData -> ShowS
[TransferData] -> ShowS
TransferData -> String
(Int -> TransferData -> ShowS)
-> (TransferData -> String)
-> ([TransferData] -> ShowS)
-> Show TransferData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransferData] -> ShowS
$cshowList :: [TransferData] -> ShowS
show :: TransferData -> String
$cshow :: TransferData -> String
showsPrec :: Int -> TransferData -> ShowS
$cshowsPrec :: Int -> TransferData -> ShowS
Prelude.Show, (forall x. TransferData -> Rep TransferData x)
-> (forall x. Rep TransferData x -> TransferData)
-> Generic TransferData
forall x. Rep TransferData x -> TransferData
forall x. TransferData -> Rep TransferData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TransferData x -> TransferData
$cfrom :: forall x. TransferData -> Rep TransferData x
Prelude.Generic)

-- |
-- Create a value of 'TransferData' 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:
--
-- 'transferDate', 'transferData_transferDate' - The date the transfer took place.
--
-- 'acceptDate', 'transferData_acceptDate' - The date the transfer was accepted.
--
-- 'transferMessage', 'transferData_transferMessage' - The transfer message.
--
-- 'rejectDate', 'transferData_rejectDate' - The date the transfer was rejected.
--
-- 'rejectReason', 'transferData_rejectReason' - The reason why the transfer was rejected.
newTransferData ::
  TransferData
newTransferData :: TransferData
newTransferData =
  TransferData' :: Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> TransferData
TransferData'
    { $sel:transferDate:TransferData' :: Maybe POSIX
transferDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:acceptDate:TransferData' :: Maybe POSIX
acceptDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:transferMessage:TransferData' :: Maybe Text
transferMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:rejectDate:TransferData' :: Maybe POSIX
rejectDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:rejectReason:TransferData' :: Maybe Text
rejectReason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The date the transfer took place.
transferData_transferDate :: Lens.Lens' TransferData (Prelude.Maybe Prelude.UTCTime)
transferData_transferDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TransferData -> f TransferData
transferData_transferDate = (TransferData -> Maybe POSIX)
-> (TransferData -> Maybe POSIX -> TransferData)
-> Lens TransferData TransferData (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferData' {Maybe POSIX
transferDate :: Maybe POSIX
$sel:transferDate:TransferData' :: TransferData -> Maybe POSIX
transferDate} -> Maybe POSIX
transferDate) (\s :: TransferData
s@TransferData' {} Maybe POSIX
a -> TransferData
s {$sel:transferDate:TransferData' :: Maybe POSIX
transferDate = Maybe POSIX
a} :: TransferData) ((Maybe POSIX -> f (Maybe POSIX))
 -> TransferData -> f TransferData)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TransferData
-> f TransferData
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 the transfer was accepted.
transferData_acceptDate :: Lens.Lens' TransferData (Prelude.Maybe Prelude.UTCTime)
transferData_acceptDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TransferData -> f TransferData
transferData_acceptDate = (TransferData -> Maybe POSIX)
-> (TransferData -> Maybe POSIX -> TransferData)
-> Lens TransferData TransferData (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferData' {Maybe POSIX
acceptDate :: Maybe POSIX
$sel:acceptDate:TransferData' :: TransferData -> Maybe POSIX
acceptDate} -> Maybe POSIX
acceptDate) (\s :: TransferData
s@TransferData' {} Maybe POSIX
a -> TransferData
s {$sel:acceptDate:TransferData' :: Maybe POSIX
acceptDate = Maybe POSIX
a} :: TransferData) ((Maybe POSIX -> f (Maybe POSIX))
 -> TransferData -> f TransferData)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TransferData
-> f TransferData
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 transfer message.
transferData_transferMessage :: Lens.Lens' TransferData (Prelude.Maybe Prelude.Text)
transferData_transferMessage :: (Maybe Text -> f (Maybe Text)) -> TransferData -> f TransferData
transferData_transferMessage = (TransferData -> Maybe Text)
-> (TransferData -> Maybe Text -> TransferData)
-> Lens TransferData TransferData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferData' {Maybe Text
transferMessage :: Maybe Text
$sel:transferMessage:TransferData' :: TransferData -> Maybe Text
transferMessage} -> Maybe Text
transferMessage) (\s :: TransferData
s@TransferData' {} Maybe Text
a -> TransferData
s {$sel:transferMessage:TransferData' :: Maybe Text
transferMessage = Maybe Text
a} :: TransferData)

-- | The date the transfer was rejected.
transferData_rejectDate :: Lens.Lens' TransferData (Prelude.Maybe Prelude.UTCTime)
transferData_rejectDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> TransferData -> f TransferData
transferData_rejectDate = (TransferData -> Maybe POSIX)
-> (TransferData -> Maybe POSIX -> TransferData)
-> Lens TransferData TransferData (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferData' {Maybe POSIX
rejectDate :: Maybe POSIX
$sel:rejectDate:TransferData' :: TransferData -> Maybe POSIX
rejectDate} -> Maybe POSIX
rejectDate) (\s :: TransferData
s@TransferData' {} Maybe POSIX
a -> TransferData
s {$sel:rejectDate:TransferData' :: Maybe POSIX
rejectDate = Maybe POSIX
a} :: TransferData) ((Maybe POSIX -> f (Maybe POSIX))
 -> TransferData -> f TransferData)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> TransferData
-> f TransferData
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 reason why the transfer was rejected.
transferData_rejectReason :: Lens.Lens' TransferData (Prelude.Maybe Prelude.Text)
transferData_rejectReason :: (Maybe Text -> f (Maybe Text)) -> TransferData -> f TransferData
transferData_rejectReason = (TransferData -> Maybe Text)
-> (TransferData -> Maybe Text -> TransferData)
-> Lens TransferData TransferData (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransferData' {Maybe Text
rejectReason :: Maybe Text
$sel:rejectReason:TransferData' :: TransferData -> Maybe Text
rejectReason} -> Maybe Text
rejectReason) (\s :: TransferData
s@TransferData' {} Maybe Text
a -> TransferData
s {$sel:rejectReason:TransferData' :: Maybe Text
rejectReason = Maybe Text
a} :: TransferData)

instance Core.FromJSON TransferData where
  parseJSON :: Value -> Parser TransferData
parseJSON =
    String
-> (Object -> Parser TransferData) -> Value -> Parser TransferData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TransferData"
      ( \Object
x ->
          Maybe POSIX
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> TransferData
TransferData'
            (Maybe POSIX
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> TransferData)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe POSIX
      -> Maybe Text -> Maybe POSIX -> Maybe Text -> TransferData)
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
"transferDate")
            Parser
  (Maybe POSIX
   -> Maybe Text -> Maybe POSIX -> Maybe Text -> TransferData)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> TransferData)
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
"acceptDate")
            Parser (Maybe Text -> Maybe POSIX -> Maybe Text -> TransferData)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> Maybe Text -> TransferData)
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
"transferMessage")
            Parser (Maybe POSIX -> Maybe Text -> TransferData)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> TransferData)
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
"rejectDate")
            Parser (Maybe Text -> TransferData)
-> Parser (Maybe Text) -> Parser TransferData
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
"rejectReason")
      )

instance Prelude.Hashable TransferData

instance Prelude.NFData TransferData