{-# 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.CloudFront.Types.RealtimeLogConfig
-- 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.CloudFront.Types.RealtimeLogConfig where

import Amazonka.CloudFront.Types.EndPoint
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A real-time log configuration.
--
-- /See:/ 'newRealtimeLogConfig' smart constructor.
data RealtimeLogConfig = RealtimeLogConfig'
  { -- | The Amazon Resource Name (ARN) of this real-time log configuration.
    RealtimeLogConfig -> Text
arn :: Prelude.Text,
    -- | The unique name of this real-time log configuration.
    RealtimeLogConfig -> Text
name :: Prelude.Text,
    -- | The sampling rate for this real-time log configuration. The sampling
    -- rate determines the percentage of viewer requests that are represented
    -- in the real-time log data. The sampling rate is an integer between 1 and
    -- 100, inclusive.
    RealtimeLogConfig -> Integer
samplingRate :: Prelude.Integer,
    -- | Contains information about the Amazon Kinesis data stream where you are
    -- sending real-time log data for this real-time log configuration.
    RealtimeLogConfig -> [EndPoint]
endPoints :: [EndPoint],
    -- | A list of fields that are included in each real-time log record. In an
    -- API response, the fields are provided in the same order in which they
    -- are sent to the Amazon Kinesis data stream.
    --
    -- For more information about fields, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields Real-time log configuration fields>
    -- in the /Amazon CloudFront Developer Guide/.
    RealtimeLogConfig -> [Text]
fields :: [Prelude.Text]
  }
  deriving (RealtimeLogConfig -> RealtimeLogConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RealtimeLogConfig -> RealtimeLogConfig -> Bool
$c/= :: RealtimeLogConfig -> RealtimeLogConfig -> Bool
== :: RealtimeLogConfig -> RealtimeLogConfig -> Bool
$c== :: RealtimeLogConfig -> RealtimeLogConfig -> Bool
Prelude.Eq, ReadPrec [RealtimeLogConfig]
ReadPrec RealtimeLogConfig
Int -> ReadS RealtimeLogConfig
ReadS [RealtimeLogConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RealtimeLogConfig]
$creadListPrec :: ReadPrec [RealtimeLogConfig]
readPrec :: ReadPrec RealtimeLogConfig
$creadPrec :: ReadPrec RealtimeLogConfig
readList :: ReadS [RealtimeLogConfig]
$creadList :: ReadS [RealtimeLogConfig]
readsPrec :: Int -> ReadS RealtimeLogConfig
$creadsPrec :: Int -> ReadS RealtimeLogConfig
Prelude.Read, Int -> RealtimeLogConfig -> ShowS
[RealtimeLogConfig] -> ShowS
RealtimeLogConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RealtimeLogConfig] -> ShowS
$cshowList :: [RealtimeLogConfig] -> ShowS
show :: RealtimeLogConfig -> String
$cshow :: RealtimeLogConfig -> String
showsPrec :: Int -> RealtimeLogConfig -> ShowS
$cshowsPrec :: Int -> RealtimeLogConfig -> ShowS
Prelude.Show, forall x. Rep RealtimeLogConfig x -> RealtimeLogConfig
forall x. RealtimeLogConfig -> Rep RealtimeLogConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RealtimeLogConfig x -> RealtimeLogConfig
$cfrom :: forall x. RealtimeLogConfig -> Rep RealtimeLogConfig x
Prelude.Generic)

-- |
-- Create a value of 'RealtimeLogConfig' 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:
--
-- 'arn', 'realtimeLogConfig_arn' - The Amazon Resource Name (ARN) of this real-time log configuration.
--
-- 'name', 'realtimeLogConfig_name' - The unique name of this real-time log configuration.
--
-- 'samplingRate', 'realtimeLogConfig_samplingRate' - The sampling rate for this real-time log configuration. The sampling
-- rate determines the percentage of viewer requests that are represented
-- in the real-time log data. The sampling rate is an integer between 1 and
-- 100, inclusive.
--
-- 'endPoints', 'realtimeLogConfig_endPoints' - Contains information about the Amazon Kinesis data stream where you are
-- sending real-time log data for this real-time log configuration.
--
-- 'fields', 'realtimeLogConfig_fields' - A list of fields that are included in each real-time log record. In an
-- API response, the fields are provided in the same order in which they
-- are sent to the Amazon Kinesis data stream.
--
-- For more information about fields, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields Real-time log configuration fields>
-- in the /Amazon CloudFront Developer Guide/.
newRealtimeLogConfig ::
  -- | 'arn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'samplingRate'
  Prelude.Integer ->
  RealtimeLogConfig
newRealtimeLogConfig :: Text -> Text -> Integer -> RealtimeLogConfig
newRealtimeLogConfig Text
pARN_ Text
pName_ Integer
pSamplingRate_ =
  RealtimeLogConfig'
    { $sel:arn:RealtimeLogConfig' :: Text
arn = Text
pARN_,
      $sel:name:RealtimeLogConfig' :: Text
name = Text
pName_,
      $sel:samplingRate:RealtimeLogConfig' :: Integer
samplingRate = Integer
pSamplingRate_,
      $sel:endPoints:RealtimeLogConfig' :: [EndPoint]
endPoints = forall a. Monoid a => a
Prelude.mempty,
      $sel:fields:RealtimeLogConfig' :: [Text]
fields = forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Resource Name (ARN) of this real-time log configuration.
realtimeLogConfig_arn :: Lens.Lens' RealtimeLogConfig Prelude.Text
realtimeLogConfig_arn :: Lens' RealtimeLogConfig Text
realtimeLogConfig_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RealtimeLogConfig' {Text
arn :: Text
$sel:arn:RealtimeLogConfig' :: RealtimeLogConfig -> Text
arn} -> Text
arn) (\s :: RealtimeLogConfig
s@RealtimeLogConfig' {} Text
a -> RealtimeLogConfig
s {$sel:arn:RealtimeLogConfig' :: Text
arn = Text
a} :: RealtimeLogConfig)

-- | The unique name of this real-time log configuration.
realtimeLogConfig_name :: Lens.Lens' RealtimeLogConfig Prelude.Text
realtimeLogConfig_name :: Lens' RealtimeLogConfig Text
realtimeLogConfig_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RealtimeLogConfig' {Text
name :: Text
$sel:name:RealtimeLogConfig' :: RealtimeLogConfig -> Text
name} -> Text
name) (\s :: RealtimeLogConfig
s@RealtimeLogConfig' {} Text
a -> RealtimeLogConfig
s {$sel:name:RealtimeLogConfig' :: Text
name = Text
a} :: RealtimeLogConfig)

-- | The sampling rate for this real-time log configuration. The sampling
-- rate determines the percentage of viewer requests that are represented
-- in the real-time log data. The sampling rate is an integer between 1 and
-- 100, inclusive.
realtimeLogConfig_samplingRate :: Lens.Lens' RealtimeLogConfig Prelude.Integer
realtimeLogConfig_samplingRate :: Lens' RealtimeLogConfig Integer
realtimeLogConfig_samplingRate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RealtimeLogConfig' {Integer
samplingRate :: Integer
$sel:samplingRate:RealtimeLogConfig' :: RealtimeLogConfig -> Integer
samplingRate} -> Integer
samplingRate) (\s :: RealtimeLogConfig
s@RealtimeLogConfig' {} Integer
a -> RealtimeLogConfig
s {$sel:samplingRate:RealtimeLogConfig' :: Integer
samplingRate = Integer
a} :: RealtimeLogConfig)

-- | Contains information about the Amazon Kinesis data stream where you are
-- sending real-time log data for this real-time log configuration.
realtimeLogConfig_endPoints :: Lens.Lens' RealtimeLogConfig [EndPoint]
realtimeLogConfig_endPoints :: Lens' RealtimeLogConfig [EndPoint]
realtimeLogConfig_endPoints = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RealtimeLogConfig' {[EndPoint]
endPoints :: [EndPoint]
$sel:endPoints:RealtimeLogConfig' :: RealtimeLogConfig -> [EndPoint]
endPoints} -> [EndPoint]
endPoints) (\s :: RealtimeLogConfig
s@RealtimeLogConfig' {} [EndPoint]
a -> RealtimeLogConfig
s {$sel:endPoints:RealtimeLogConfig' :: [EndPoint]
endPoints = [EndPoint]
a} :: RealtimeLogConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of fields that are included in each real-time log record. In an
-- API response, the fields are provided in the same order in which they
-- are sent to the Amazon Kinesis data stream.
--
-- For more information about fields, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html#understand-real-time-log-config-fields Real-time log configuration fields>
-- in the /Amazon CloudFront Developer Guide/.
realtimeLogConfig_fields :: Lens.Lens' RealtimeLogConfig [Prelude.Text]
realtimeLogConfig_fields :: Lens' RealtimeLogConfig [Text]
realtimeLogConfig_fields = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RealtimeLogConfig' {[Text]
fields :: [Text]
$sel:fields:RealtimeLogConfig' :: RealtimeLogConfig -> [Text]
fields} -> [Text]
fields) (\s :: RealtimeLogConfig
s@RealtimeLogConfig' {} [Text]
a -> RealtimeLogConfig
s {$sel:fields:RealtimeLogConfig' :: [Text]
fields = [Text]
a} :: RealtimeLogConfig) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML RealtimeLogConfig where
  parseXML :: [Node] -> Either String RealtimeLogConfig
parseXML [Node]
x =
    Text
-> Text -> Integer -> [EndPoint] -> [Text] -> RealtimeLogConfig
RealtimeLogConfig'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ARN")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Name")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"SamplingRate")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"EndPoints"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member"
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Fields"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"Field"
                  )

instance Prelude.Hashable RealtimeLogConfig where
  hashWithSalt :: Int -> RealtimeLogConfig -> Int
hashWithSalt Int
_salt RealtimeLogConfig' {Integer
[Text]
[EndPoint]
Text
fields :: [Text]
endPoints :: [EndPoint]
samplingRate :: Integer
name :: Text
arn :: Text
$sel:fields:RealtimeLogConfig' :: RealtimeLogConfig -> [Text]
$sel:endPoints:RealtimeLogConfig' :: RealtimeLogConfig -> [EndPoint]
$sel:samplingRate:RealtimeLogConfig' :: RealtimeLogConfig -> Integer
$sel:name:RealtimeLogConfig' :: RealtimeLogConfig -> Text
$sel:arn:RealtimeLogConfig' :: RealtimeLogConfig -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Integer
samplingRate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [EndPoint]
endPoints
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
fields

instance Prelude.NFData RealtimeLogConfig where
  rnf :: RealtimeLogConfig -> ()
rnf RealtimeLogConfig' {Integer
[Text]
[EndPoint]
Text
fields :: [Text]
endPoints :: [EndPoint]
samplingRate :: Integer
name :: Text
arn :: Text
$sel:fields:RealtimeLogConfig' :: RealtimeLogConfig -> [Text]
$sel:endPoints:RealtimeLogConfig' :: RealtimeLogConfig -> [EndPoint]
$sel:samplingRate:RealtimeLogConfig' :: RealtimeLogConfig -> Integer
$sel:name:RealtimeLogConfig' :: RealtimeLogConfig -> Text
$sel:arn:RealtimeLogConfig' :: RealtimeLogConfig -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Integer
samplingRate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [EndPoint]
endPoints
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
fields