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

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

-- | Specifies the time period of which violation events occurred between.
--
-- /See:/ 'newViolationEventOccurrenceRange' smart constructor.
data ViolationEventOccurrenceRange = ViolationEventOccurrenceRange'
  { -- | The start date and time of a time period in which violation events
    -- occurred.
    ViolationEventOccurrenceRange -> POSIX
startTime :: Core.POSIX,
    -- | The end date and time of a time period in which violation events
    -- occurred.
    ViolationEventOccurrenceRange -> POSIX
endTime :: Core.POSIX
  }
  deriving (ViolationEventOccurrenceRange
-> ViolationEventOccurrenceRange -> Bool
(ViolationEventOccurrenceRange
 -> ViolationEventOccurrenceRange -> Bool)
-> (ViolationEventOccurrenceRange
    -> ViolationEventOccurrenceRange -> Bool)
-> Eq ViolationEventOccurrenceRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ViolationEventOccurrenceRange
-> ViolationEventOccurrenceRange -> Bool
$c/= :: ViolationEventOccurrenceRange
-> ViolationEventOccurrenceRange -> Bool
== :: ViolationEventOccurrenceRange
-> ViolationEventOccurrenceRange -> Bool
$c== :: ViolationEventOccurrenceRange
-> ViolationEventOccurrenceRange -> Bool
Prelude.Eq, ReadPrec [ViolationEventOccurrenceRange]
ReadPrec ViolationEventOccurrenceRange
Int -> ReadS ViolationEventOccurrenceRange
ReadS [ViolationEventOccurrenceRange]
(Int -> ReadS ViolationEventOccurrenceRange)
-> ReadS [ViolationEventOccurrenceRange]
-> ReadPrec ViolationEventOccurrenceRange
-> ReadPrec [ViolationEventOccurrenceRange]
-> Read ViolationEventOccurrenceRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ViolationEventOccurrenceRange]
$creadListPrec :: ReadPrec [ViolationEventOccurrenceRange]
readPrec :: ReadPrec ViolationEventOccurrenceRange
$creadPrec :: ReadPrec ViolationEventOccurrenceRange
readList :: ReadS [ViolationEventOccurrenceRange]
$creadList :: ReadS [ViolationEventOccurrenceRange]
readsPrec :: Int -> ReadS ViolationEventOccurrenceRange
$creadsPrec :: Int -> ReadS ViolationEventOccurrenceRange
Prelude.Read, Int -> ViolationEventOccurrenceRange -> ShowS
[ViolationEventOccurrenceRange] -> ShowS
ViolationEventOccurrenceRange -> String
(Int -> ViolationEventOccurrenceRange -> ShowS)
-> (ViolationEventOccurrenceRange -> String)
-> ([ViolationEventOccurrenceRange] -> ShowS)
-> Show ViolationEventOccurrenceRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ViolationEventOccurrenceRange] -> ShowS
$cshowList :: [ViolationEventOccurrenceRange] -> ShowS
show :: ViolationEventOccurrenceRange -> String
$cshow :: ViolationEventOccurrenceRange -> String
showsPrec :: Int -> ViolationEventOccurrenceRange -> ShowS
$cshowsPrec :: Int -> ViolationEventOccurrenceRange -> ShowS
Prelude.Show, (forall x.
 ViolationEventOccurrenceRange
 -> Rep ViolationEventOccurrenceRange x)
-> (forall x.
    Rep ViolationEventOccurrenceRange x
    -> ViolationEventOccurrenceRange)
-> Generic ViolationEventOccurrenceRange
forall x.
Rep ViolationEventOccurrenceRange x
-> ViolationEventOccurrenceRange
forall x.
ViolationEventOccurrenceRange
-> Rep ViolationEventOccurrenceRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ViolationEventOccurrenceRange x
-> ViolationEventOccurrenceRange
$cfrom :: forall x.
ViolationEventOccurrenceRange
-> Rep ViolationEventOccurrenceRange x
Prelude.Generic)

-- |
-- Create a value of 'ViolationEventOccurrenceRange' 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:
--
-- 'startTime', 'violationEventOccurrenceRange_startTime' - The start date and time of a time period in which violation events
-- occurred.
--
-- 'endTime', 'violationEventOccurrenceRange_endTime' - The end date and time of a time period in which violation events
-- occurred.
newViolationEventOccurrenceRange ::
  -- | 'startTime'
  Prelude.UTCTime ->
  -- | 'endTime'
  Prelude.UTCTime ->
  ViolationEventOccurrenceRange
newViolationEventOccurrenceRange :: UTCTime -> UTCTime -> ViolationEventOccurrenceRange
newViolationEventOccurrenceRange
  UTCTime
pStartTime_
  UTCTime
pEndTime_ =
    ViolationEventOccurrenceRange' :: POSIX -> POSIX -> ViolationEventOccurrenceRange
ViolationEventOccurrenceRange'
      { $sel:startTime:ViolationEventOccurrenceRange' :: POSIX
startTime =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pStartTime_,
        $sel:endTime:ViolationEventOccurrenceRange' :: POSIX
endTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pEndTime_
      }

-- | The start date and time of a time period in which violation events
-- occurred.
violationEventOccurrenceRange_startTime :: Lens.Lens' ViolationEventOccurrenceRange Prelude.UTCTime
violationEventOccurrenceRange_startTime :: (UTCTime -> f UTCTime)
-> ViolationEventOccurrenceRange -> f ViolationEventOccurrenceRange
violationEventOccurrenceRange_startTime = (ViolationEventOccurrenceRange -> POSIX)
-> (ViolationEventOccurrenceRange
    -> POSIX -> ViolationEventOccurrenceRange)
-> Lens
     ViolationEventOccurrenceRange
     ViolationEventOccurrenceRange
     POSIX
     POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationEventOccurrenceRange' {POSIX
startTime :: POSIX
$sel:startTime:ViolationEventOccurrenceRange' :: ViolationEventOccurrenceRange -> POSIX
startTime} -> POSIX
startTime) (\s :: ViolationEventOccurrenceRange
s@ViolationEventOccurrenceRange' {} POSIX
a -> ViolationEventOccurrenceRange
s {$sel:startTime:ViolationEventOccurrenceRange' :: POSIX
startTime = POSIX
a} :: ViolationEventOccurrenceRange) ((POSIX -> f POSIX)
 -> ViolationEventOccurrenceRange
 -> f ViolationEventOccurrenceRange)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ViolationEventOccurrenceRange
-> f ViolationEventOccurrenceRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The end date and time of a time period in which violation events
-- occurred.
violationEventOccurrenceRange_endTime :: Lens.Lens' ViolationEventOccurrenceRange Prelude.UTCTime
violationEventOccurrenceRange_endTime :: (UTCTime -> f UTCTime)
-> ViolationEventOccurrenceRange -> f ViolationEventOccurrenceRange
violationEventOccurrenceRange_endTime = (ViolationEventOccurrenceRange -> POSIX)
-> (ViolationEventOccurrenceRange
    -> POSIX -> ViolationEventOccurrenceRange)
-> Lens
     ViolationEventOccurrenceRange
     ViolationEventOccurrenceRange
     POSIX
     POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ViolationEventOccurrenceRange' {POSIX
endTime :: POSIX
$sel:endTime:ViolationEventOccurrenceRange' :: ViolationEventOccurrenceRange -> POSIX
endTime} -> POSIX
endTime) (\s :: ViolationEventOccurrenceRange
s@ViolationEventOccurrenceRange' {} POSIX
a -> ViolationEventOccurrenceRange
s {$sel:endTime:ViolationEventOccurrenceRange' :: POSIX
endTime = POSIX
a} :: ViolationEventOccurrenceRange) ((POSIX -> f POSIX)
 -> ViolationEventOccurrenceRange
 -> f ViolationEventOccurrenceRange)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ViolationEventOccurrenceRange
-> f ViolationEventOccurrenceRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON ViolationEventOccurrenceRange where
  parseJSON :: Value -> Parser ViolationEventOccurrenceRange
parseJSON =
    String
-> (Object -> Parser ViolationEventOccurrenceRange)
-> Value
-> Parser ViolationEventOccurrenceRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ViolationEventOccurrenceRange"
      ( \Object
x ->
          POSIX -> POSIX -> ViolationEventOccurrenceRange
ViolationEventOccurrenceRange'
            (POSIX -> POSIX -> ViolationEventOccurrenceRange)
-> Parser POSIX -> Parser (POSIX -> ViolationEventOccurrenceRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"startTime")
            Parser (POSIX -> ViolationEventOccurrenceRange)
-> Parser POSIX -> Parser ViolationEventOccurrenceRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"endTime")
      )

instance
  Prelude.Hashable
    ViolationEventOccurrenceRange

instance Prelude.NFData ViolationEventOccurrenceRange

instance Core.ToJSON ViolationEventOccurrenceRange where
  toJSON :: ViolationEventOccurrenceRange -> Value
toJSON ViolationEventOccurrenceRange' {POSIX
endTime :: POSIX
startTime :: POSIX
$sel:endTime:ViolationEventOccurrenceRange' :: ViolationEventOccurrenceRange -> POSIX
$sel:startTime:ViolationEventOccurrenceRange' :: ViolationEventOccurrenceRange -> POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"startTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
startTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"endTime" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= POSIX
endTime)
          ]
      )