{-# 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.CodeGuruProfiler.Types.ProfileTime
-- 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.CodeGuruProfiler.Types.ProfileTime where

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

-- | Contains the start time of a profile.
--
-- /See:/ 'newProfileTime' smart constructor.
data ProfileTime = ProfileTime'
  { -- | The start time of a profile. It is specified using the ISO 8601 format.
    -- For example, 2020-06-01T13:15:02.001Z represents 1 millisecond past June
    -- 1, 2020 1:15:02 PM UTC.
    ProfileTime -> Maybe POSIX
start :: Prelude.Maybe Core.POSIX
  }
  deriving (ProfileTime -> ProfileTime -> Bool
(ProfileTime -> ProfileTime -> Bool)
-> (ProfileTime -> ProfileTime -> Bool) -> Eq ProfileTime
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProfileTime -> ProfileTime -> Bool
$c/= :: ProfileTime -> ProfileTime -> Bool
== :: ProfileTime -> ProfileTime -> Bool
$c== :: ProfileTime -> ProfileTime -> Bool
Prelude.Eq, ReadPrec [ProfileTime]
ReadPrec ProfileTime
Int -> ReadS ProfileTime
ReadS [ProfileTime]
(Int -> ReadS ProfileTime)
-> ReadS [ProfileTime]
-> ReadPrec ProfileTime
-> ReadPrec [ProfileTime]
-> Read ProfileTime
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProfileTime]
$creadListPrec :: ReadPrec [ProfileTime]
readPrec :: ReadPrec ProfileTime
$creadPrec :: ReadPrec ProfileTime
readList :: ReadS [ProfileTime]
$creadList :: ReadS [ProfileTime]
readsPrec :: Int -> ReadS ProfileTime
$creadsPrec :: Int -> ReadS ProfileTime
Prelude.Read, Int -> ProfileTime -> ShowS
[ProfileTime] -> ShowS
ProfileTime -> String
(Int -> ProfileTime -> ShowS)
-> (ProfileTime -> String)
-> ([ProfileTime] -> ShowS)
-> Show ProfileTime
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProfileTime] -> ShowS
$cshowList :: [ProfileTime] -> ShowS
show :: ProfileTime -> String
$cshow :: ProfileTime -> String
showsPrec :: Int -> ProfileTime -> ShowS
$cshowsPrec :: Int -> ProfileTime -> ShowS
Prelude.Show, (forall x. ProfileTime -> Rep ProfileTime x)
-> (forall x. Rep ProfileTime x -> ProfileTime)
-> Generic ProfileTime
forall x. Rep ProfileTime x -> ProfileTime
forall x. ProfileTime -> Rep ProfileTime x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProfileTime x -> ProfileTime
$cfrom :: forall x. ProfileTime -> Rep ProfileTime x
Prelude.Generic)

-- |
-- Create a value of 'ProfileTime' 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:
--
-- 'start', 'profileTime_start' - The start time of a profile. It is specified using the ISO 8601 format.
-- For example, 2020-06-01T13:15:02.001Z represents 1 millisecond past June
-- 1, 2020 1:15:02 PM UTC.
newProfileTime ::
  ProfileTime
newProfileTime :: ProfileTime
newProfileTime =
  ProfileTime' :: Maybe POSIX -> ProfileTime
ProfileTime' {$sel:start:ProfileTime' :: Maybe POSIX
start = Maybe POSIX
forall a. Maybe a
Prelude.Nothing}

-- | The start time of a profile. It is specified using the ISO 8601 format.
-- For example, 2020-06-01T13:15:02.001Z represents 1 millisecond past June
-- 1, 2020 1:15:02 PM UTC.
profileTime_start :: Lens.Lens' ProfileTime (Prelude.Maybe Prelude.UTCTime)
profileTime_start :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ProfileTime -> f ProfileTime
profileTime_start = (ProfileTime -> Maybe POSIX)
-> (ProfileTime -> Maybe POSIX -> ProfileTime)
-> Lens ProfileTime ProfileTime (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProfileTime' {Maybe POSIX
start :: Maybe POSIX
$sel:start:ProfileTime' :: ProfileTime -> Maybe POSIX
start} -> Maybe POSIX
start) (\s :: ProfileTime
s@ProfileTime' {} Maybe POSIX
a -> ProfileTime
s {$sel:start:ProfileTime' :: Maybe POSIX
start = Maybe POSIX
a} :: ProfileTime) ((Maybe POSIX -> f (Maybe POSIX)) -> ProfileTime -> f ProfileTime)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ProfileTime
-> f ProfileTime
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 ProfileTime where
  parseJSON :: Value -> Parser ProfileTime
parseJSON =
    String
-> (Object -> Parser ProfileTime) -> Value -> Parser ProfileTime
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProfileTime"
      ( \Object
x ->
          Maybe POSIX -> ProfileTime
ProfileTime' (Maybe POSIX -> ProfileTime)
-> Parser (Maybe POSIX) -> Parser ProfileTime
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
"start")
      )

instance Prelude.Hashable ProfileTime

instance Prelude.NFData ProfileTime