{-# 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.LexV2Models.Types.RelativeAggregationDuration
-- 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.LexV2Models.Types.RelativeAggregationDuration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.TimeDimension
import qualified Amazonka.Prelude as Prelude

-- | Specifies the time window that utterance statistics are returned for.
-- The time window is always relative to the last time that the that
-- utterances were aggregated. For example, if the
-- @ListAggregatedUtterances@ operation is called at 1600, the time window
-- is set to 1 hour, and the last refresh time was 1530, only utterances
-- made between 1430 and 1530 are returned.
--
-- You can choose the time window that statistics should be returned for.
--
-- -   __Hours__ - You can request utterance statistics for 1, 3, 6, 12, or
--     24 hour time windows. Statistics are refreshed every half hour for 1
--     hour time windows, and hourly for the other time windows.
--
-- -   __Days__ - You can request utterance statistics for 3 days.
--     Statistics are refreshed every 6 hours.
--
-- -   __Weeks__ - You can see statistics for one or two weeks. Statistics
--     are refreshed every 12 hours for one week time windows, and once per
--     day for two week time windows.
--
-- /See:/ 'newRelativeAggregationDuration' smart constructor.
data RelativeAggregationDuration = RelativeAggregationDuration'
  { -- | The type of time period that the @timeValue@ field represents.
    RelativeAggregationDuration -> TimeDimension
timeDimension :: TimeDimension,
    -- | The period of the time window to gather statistics for. The valid value
    -- depends on the setting of the @timeDimension@ field.
    --
    -- -   @Hours@ - 1\/3\/6\/12\/24
    --
    -- -   @Days@ - 3
    --
    -- -   @Weeks@ - 1\/2
    RelativeAggregationDuration -> Natural
timeValue :: Prelude.Natural
  }
  deriving (RelativeAggregationDuration -> RelativeAggregationDuration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelativeAggregationDuration -> RelativeAggregationDuration -> Bool
$c/= :: RelativeAggregationDuration -> RelativeAggregationDuration -> Bool
== :: RelativeAggregationDuration -> RelativeAggregationDuration -> Bool
$c== :: RelativeAggregationDuration -> RelativeAggregationDuration -> Bool
Prelude.Eq, ReadPrec [RelativeAggregationDuration]
ReadPrec RelativeAggregationDuration
Int -> ReadS RelativeAggregationDuration
ReadS [RelativeAggregationDuration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelativeAggregationDuration]
$creadListPrec :: ReadPrec [RelativeAggregationDuration]
readPrec :: ReadPrec RelativeAggregationDuration
$creadPrec :: ReadPrec RelativeAggregationDuration
readList :: ReadS [RelativeAggregationDuration]
$creadList :: ReadS [RelativeAggregationDuration]
readsPrec :: Int -> ReadS RelativeAggregationDuration
$creadsPrec :: Int -> ReadS RelativeAggregationDuration
Prelude.Read, Int -> RelativeAggregationDuration -> ShowS
[RelativeAggregationDuration] -> ShowS
RelativeAggregationDuration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelativeAggregationDuration] -> ShowS
$cshowList :: [RelativeAggregationDuration] -> ShowS
show :: RelativeAggregationDuration -> String
$cshow :: RelativeAggregationDuration -> String
showsPrec :: Int -> RelativeAggregationDuration -> ShowS
$cshowsPrec :: Int -> RelativeAggregationDuration -> ShowS
Prelude.Show, forall x.
Rep RelativeAggregationDuration x -> RelativeAggregationDuration
forall x.
RelativeAggregationDuration -> Rep RelativeAggregationDuration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RelativeAggregationDuration x -> RelativeAggregationDuration
$cfrom :: forall x.
RelativeAggregationDuration -> Rep RelativeAggregationDuration x
Prelude.Generic)

-- |
-- Create a value of 'RelativeAggregationDuration' 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:
--
-- 'timeDimension', 'relativeAggregationDuration_timeDimension' - The type of time period that the @timeValue@ field represents.
--
-- 'timeValue', 'relativeAggregationDuration_timeValue' - The period of the time window to gather statistics for. The valid value
-- depends on the setting of the @timeDimension@ field.
--
-- -   @Hours@ - 1\/3\/6\/12\/24
--
-- -   @Days@ - 3
--
-- -   @Weeks@ - 1\/2
newRelativeAggregationDuration ::
  -- | 'timeDimension'
  TimeDimension ->
  -- | 'timeValue'
  Prelude.Natural ->
  RelativeAggregationDuration
newRelativeAggregationDuration :: TimeDimension -> Natural -> RelativeAggregationDuration
newRelativeAggregationDuration
  TimeDimension
pTimeDimension_
  Natural
pTimeValue_ =
    RelativeAggregationDuration'
      { $sel:timeDimension:RelativeAggregationDuration' :: TimeDimension
timeDimension =
          TimeDimension
pTimeDimension_,
        $sel:timeValue:RelativeAggregationDuration' :: Natural
timeValue = Natural
pTimeValue_
      }

-- | The type of time period that the @timeValue@ field represents.
relativeAggregationDuration_timeDimension :: Lens.Lens' RelativeAggregationDuration TimeDimension
relativeAggregationDuration_timeDimension :: Lens' RelativeAggregationDuration TimeDimension
relativeAggregationDuration_timeDimension = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelativeAggregationDuration' {TimeDimension
timeDimension :: TimeDimension
$sel:timeDimension:RelativeAggregationDuration' :: RelativeAggregationDuration -> TimeDimension
timeDimension} -> TimeDimension
timeDimension) (\s :: RelativeAggregationDuration
s@RelativeAggregationDuration' {} TimeDimension
a -> RelativeAggregationDuration
s {$sel:timeDimension:RelativeAggregationDuration' :: TimeDimension
timeDimension = TimeDimension
a} :: RelativeAggregationDuration)

-- | The period of the time window to gather statistics for. The valid value
-- depends on the setting of the @timeDimension@ field.
--
-- -   @Hours@ - 1\/3\/6\/12\/24
--
-- -   @Days@ - 3
--
-- -   @Weeks@ - 1\/2
relativeAggregationDuration_timeValue :: Lens.Lens' RelativeAggregationDuration Prelude.Natural
relativeAggregationDuration_timeValue :: Lens' RelativeAggregationDuration Natural
relativeAggregationDuration_timeValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelativeAggregationDuration' {Natural
timeValue :: Natural
$sel:timeValue:RelativeAggregationDuration' :: RelativeAggregationDuration -> Natural
timeValue} -> Natural
timeValue) (\s :: RelativeAggregationDuration
s@RelativeAggregationDuration' {} Natural
a -> RelativeAggregationDuration
s {$sel:timeValue:RelativeAggregationDuration' :: Natural
timeValue = Natural
a} :: RelativeAggregationDuration)

instance Data.FromJSON RelativeAggregationDuration where
  parseJSON :: Value -> Parser RelativeAggregationDuration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RelativeAggregationDuration"
      ( \Object
x ->
          TimeDimension -> Natural -> RelativeAggregationDuration
RelativeAggregationDuration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"timeDimension")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"timeValue")
      )

instance Prelude.Hashable RelativeAggregationDuration where
  hashWithSalt :: Int -> RelativeAggregationDuration -> Int
hashWithSalt Int
_salt RelativeAggregationDuration' {Natural
TimeDimension
timeValue :: Natural
timeDimension :: TimeDimension
$sel:timeValue:RelativeAggregationDuration' :: RelativeAggregationDuration -> Natural
$sel:timeDimension:RelativeAggregationDuration' :: RelativeAggregationDuration -> TimeDimension
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TimeDimension
timeDimension
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
timeValue

instance Prelude.NFData RelativeAggregationDuration where
  rnf :: RelativeAggregationDuration -> ()
rnf RelativeAggregationDuration' {Natural
TimeDimension
timeValue :: Natural
timeDimension :: TimeDimension
$sel:timeValue:RelativeAggregationDuration' :: RelativeAggregationDuration -> Natural
$sel:timeDimension:RelativeAggregationDuration' :: RelativeAggregationDuration -> TimeDimension
..} =
    forall a. NFData a => a -> ()
Prelude.rnf TimeDimension
timeDimension
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
timeValue

instance Data.ToJSON RelativeAggregationDuration where
  toJSON :: RelativeAggregationDuration -> Value
toJSON RelativeAggregationDuration' {Natural
TimeDimension
timeValue :: Natural
timeDimension :: TimeDimension
$sel:timeValue:RelativeAggregationDuration' :: RelativeAggregationDuration -> Natural
$sel:timeDimension:RelativeAggregationDuration' :: RelativeAggregationDuration -> TimeDimension
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"timeDimension" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TimeDimension
timeDimension),
            forall a. a -> Maybe a
Prelude.Just (Key
"timeValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
timeValue)
          ]
      )