{-# 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.LicenseManager.Types.ReportFrequency
-- 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.LicenseManager.Types.ReportFrequency where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LicenseManager.Types.ReportFrequencyType
import qualified Amazonka.Prelude as Prelude

-- | Details about how frequently reports are generated.
--
-- /See:/ 'newReportFrequency' smart constructor.
data ReportFrequency = ReportFrequency'
  { -- | Time period between each report. The period can be daily, weekly, or
    -- monthly.
    ReportFrequency -> Maybe ReportFrequencyType
period :: Prelude.Maybe ReportFrequencyType,
    -- | Number of times within the frequency period that a report is generated.
    -- The only supported value is @1@.
    ReportFrequency -> Maybe Int
value :: Prelude.Maybe Prelude.Int
  }
  deriving (ReportFrequency -> ReportFrequency -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReportFrequency -> ReportFrequency -> Bool
$c/= :: ReportFrequency -> ReportFrequency -> Bool
== :: ReportFrequency -> ReportFrequency -> Bool
$c== :: ReportFrequency -> ReportFrequency -> Bool
Prelude.Eq, ReadPrec [ReportFrequency]
ReadPrec ReportFrequency
Int -> ReadS ReportFrequency
ReadS [ReportFrequency]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReportFrequency]
$creadListPrec :: ReadPrec [ReportFrequency]
readPrec :: ReadPrec ReportFrequency
$creadPrec :: ReadPrec ReportFrequency
readList :: ReadS [ReportFrequency]
$creadList :: ReadS [ReportFrequency]
readsPrec :: Int -> ReadS ReportFrequency
$creadsPrec :: Int -> ReadS ReportFrequency
Prelude.Read, Int -> ReportFrequency -> ShowS
[ReportFrequency] -> ShowS
ReportFrequency -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReportFrequency] -> ShowS
$cshowList :: [ReportFrequency] -> ShowS
show :: ReportFrequency -> String
$cshow :: ReportFrequency -> String
showsPrec :: Int -> ReportFrequency -> ShowS
$cshowsPrec :: Int -> ReportFrequency -> ShowS
Prelude.Show, forall x. Rep ReportFrequency x -> ReportFrequency
forall x. ReportFrequency -> Rep ReportFrequency x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReportFrequency x -> ReportFrequency
$cfrom :: forall x. ReportFrequency -> Rep ReportFrequency x
Prelude.Generic)

-- |
-- Create a value of 'ReportFrequency' 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:
--
-- 'period', 'reportFrequency_period' - Time period between each report. The period can be daily, weekly, or
-- monthly.
--
-- 'value', 'reportFrequency_value' - Number of times within the frequency period that a report is generated.
-- The only supported value is @1@.
newReportFrequency ::
  ReportFrequency
newReportFrequency :: ReportFrequency
newReportFrequency =
  ReportFrequency'
    { $sel:period:ReportFrequency' :: Maybe ReportFrequencyType
period = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ReportFrequency' :: Maybe Int
value = forall a. Maybe a
Prelude.Nothing
    }

-- | Time period between each report. The period can be daily, weekly, or
-- monthly.
reportFrequency_period :: Lens.Lens' ReportFrequency (Prelude.Maybe ReportFrequencyType)
reportFrequency_period :: Lens' ReportFrequency (Maybe ReportFrequencyType)
reportFrequency_period = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportFrequency' {Maybe ReportFrequencyType
period :: Maybe ReportFrequencyType
$sel:period:ReportFrequency' :: ReportFrequency -> Maybe ReportFrequencyType
period} -> Maybe ReportFrequencyType
period) (\s :: ReportFrequency
s@ReportFrequency' {} Maybe ReportFrequencyType
a -> ReportFrequency
s {$sel:period:ReportFrequency' :: Maybe ReportFrequencyType
period = Maybe ReportFrequencyType
a} :: ReportFrequency)

-- | Number of times within the frequency period that a report is generated.
-- The only supported value is @1@.
reportFrequency_value :: Lens.Lens' ReportFrequency (Prelude.Maybe Prelude.Int)
reportFrequency_value :: Lens' ReportFrequency (Maybe Int)
reportFrequency_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReportFrequency' {Maybe Int
value :: Maybe Int
$sel:value:ReportFrequency' :: ReportFrequency -> Maybe Int
value} -> Maybe Int
value) (\s :: ReportFrequency
s@ReportFrequency' {} Maybe Int
a -> ReportFrequency
s {$sel:value:ReportFrequency' :: Maybe Int
value = Maybe Int
a} :: ReportFrequency)

instance Data.FromJSON ReportFrequency where
  parseJSON :: Value -> Parser ReportFrequency
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ReportFrequency"
      ( \Object
x ->
          Maybe ReportFrequencyType -> Maybe Int -> ReportFrequency
ReportFrequency'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"period")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"value")
      )

instance Prelude.Hashable ReportFrequency where
  hashWithSalt :: Int -> ReportFrequency -> Int
hashWithSalt Int
_salt ReportFrequency' {Maybe Int
Maybe ReportFrequencyType
value :: Maybe Int
period :: Maybe ReportFrequencyType
$sel:value:ReportFrequency' :: ReportFrequency -> Maybe Int
$sel:period:ReportFrequency' :: ReportFrequency -> Maybe ReportFrequencyType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ReportFrequencyType
period
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
value

instance Prelude.NFData ReportFrequency where
  rnf :: ReportFrequency -> ()
rnf ReportFrequency' {Maybe Int
Maybe ReportFrequencyType
value :: Maybe Int
period :: Maybe ReportFrequencyType
$sel:value:ReportFrequency' :: ReportFrequency -> Maybe Int
$sel:period:ReportFrequency' :: ReportFrequency -> Maybe ReportFrequencyType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ReportFrequencyType
period seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
value

instance Data.ToJSON ReportFrequency where
  toJSON :: ReportFrequency -> Value
toJSON ReportFrequency' {Maybe Int
Maybe ReportFrequencyType
value :: Maybe Int
period :: Maybe ReportFrequencyType
$sel:value:ReportFrequency' :: ReportFrequency -> Maybe Int
$sel:period:ReportFrequency' :: ReportFrequency -> Maybe ReportFrequencyType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"period" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ReportFrequencyType
period,
            (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
value
          ]
      )