{-# 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.MediaTailor.Types.LogConfiguration
-- 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.MediaTailor.Types.LogConfiguration where

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

-- | Returns Amazon CloudWatch log settings for a playback configuration.
--
-- /See:/ 'newLogConfiguration' smart constructor.
data LogConfiguration = LogConfiguration'
  { -- | The percentage of session logs that MediaTailor sends to your Cloudwatch
    -- Logs account. For example, if your playback configuration has 1000
    -- sessions and percentEnabled is set to 60, MediaTailor sends logs for 600
    -- of the sessions to CloudWatch Logs. MediaTailor decides at random which
    -- of the playback configuration sessions to send logs for. If you want to
    -- view logs for a specific session, you can use the
    -- <https://docs.aws.amazon.com/mediatailor/latest/ug/debug-log-mode.html debug log mode>.
    --
    -- Valid values: 0 - 100
    LogConfiguration -> Int
percentEnabled :: Prelude.Int
  }
  deriving (LogConfiguration -> LogConfiguration -> Bool
(LogConfiguration -> LogConfiguration -> Bool)
-> (LogConfiguration -> LogConfiguration -> Bool)
-> Eq LogConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LogConfiguration -> LogConfiguration -> Bool
$c/= :: LogConfiguration -> LogConfiguration -> Bool
== :: LogConfiguration -> LogConfiguration -> Bool
$c== :: LogConfiguration -> LogConfiguration -> Bool
Prelude.Eq, ReadPrec [LogConfiguration]
ReadPrec LogConfiguration
Int -> ReadS LogConfiguration
ReadS [LogConfiguration]
(Int -> ReadS LogConfiguration)
-> ReadS [LogConfiguration]
-> ReadPrec LogConfiguration
-> ReadPrec [LogConfiguration]
-> Read LogConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LogConfiguration]
$creadListPrec :: ReadPrec [LogConfiguration]
readPrec :: ReadPrec LogConfiguration
$creadPrec :: ReadPrec LogConfiguration
readList :: ReadS [LogConfiguration]
$creadList :: ReadS [LogConfiguration]
readsPrec :: Int -> ReadS LogConfiguration
$creadsPrec :: Int -> ReadS LogConfiguration
Prelude.Read, Int -> LogConfiguration -> ShowS
[LogConfiguration] -> ShowS
LogConfiguration -> String
(Int -> LogConfiguration -> ShowS)
-> (LogConfiguration -> String)
-> ([LogConfiguration] -> ShowS)
-> Show LogConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LogConfiguration] -> ShowS
$cshowList :: [LogConfiguration] -> ShowS
show :: LogConfiguration -> String
$cshow :: LogConfiguration -> String
showsPrec :: Int -> LogConfiguration -> ShowS
$cshowsPrec :: Int -> LogConfiguration -> ShowS
Prelude.Show, (forall x. LogConfiguration -> Rep LogConfiguration x)
-> (forall x. Rep LogConfiguration x -> LogConfiguration)
-> Generic LogConfiguration
forall x. Rep LogConfiguration x -> LogConfiguration
forall x. LogConfiguration -> Rep LogConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LogConfiguration x -> LogConfiguration
$cfrom :: forall x. LogConfiguration -> Rep LogConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LogConfiguration' 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:
--
-- 'percentEnabled', 'logConfiguration_percentEnabled' - The percentage of session logs that MediaTailor sends to your Cloudwatch
-- Logs account. For example, if your playback configuration has 1000
-- sessions and percentEnabled is set to 60, MediaTailor sends logs for 600
-- of the sessions to CloudWatch Logs. MediaTailor decides at random which
-- of the playback configuration sessions to send logs for. If you want to
-- view logs for a specific session, you can use the
-- <https://docs.aws.amazon.com/mediatailor/latest/ug/debug-log-mode.html debug log mode>.
--
-- Valid values: 0 - 100
newLogConfiguration ::
  -- | 'percentEnabled'
  Prelude.Int ->
  LogConfiguration
newLogConfiguration :: Int -> LogConfiguration
newLogConfiguration Int
pPercentEnabled_ =
  LogConfiguration' :: Int -> LogConfiguration
LogConfiguration'
    { $sel:percentEnabled:LogConfiguration' :: Int
percentEnabled =
        Int
pPercentEnabled_
    }

-- | The percentage of session logs that MediaTailor sends to your Cloudwatch
-- Logs account. For example, if your playback configuration has 1000
-- sessions and percentEnabled is set to 60, MediaTailor sends logs for 600
-- of the sessions to CloudWatch Logs. MediaTailor decides at random which
-- of the playback configuration sessions to send logs for. If you want to
-- view logs for a specific session, you can use the
-- <https://docs.aws.amazon.com/mediatailor/latest/ug/debug-log-mode.html debug log mode>.
--
-- Valid values: 0 - 100
logConfiguration_percentEnabled :: Lens.Lens' LogConfiguration Prelude.Int
logConfiguration_percentEnabled :: (Int -> f Int) -> LogConfiguration -> f LogConfiguration
logConfiguration_percentEnabled = (LogConfiguration -> Int)
-> (LogConfiguration -> Int -> LogConfiguration)
-> Lens LogConfiguration LogConfiguration Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LogConfiguration' {Int
percentEnabled :: Int
$sel:percentEnabled:LogConfiguration' :: LogConfiguration -> Int
percentEnabled} -> Int
percentEnabled) (\s :: LogConfiguration
s@LogConfiguration' {} Int
a -> LogConfiguration
s {$sel:percentEnabled:LogConfiguration' :: Int
percentEnabled = Int
a} :: LogConfiguration)

instance Core.FromJSON LogConfiguration where
  parseJSON :: Value -> Parser LogConfiguration
parseJSON =
    String
-> (Object -> Parser LogConfiguration)
-> Value
-> Parser LogConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LogConfiguration"
      ( \Object
x ->
          Int -> LogConfiguration
LogConfiguration'
            (Int -> LogConfiguration) -> Parser Int -> Parser LogConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"PercentEnabled")
      )

instance Prelude.Hashable LogConfiguration

instance Prelude.NFData LogConfiguration