{-# 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.SecurityHub.Types.AwsCloudFrontDistributionLogging
-- 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.SecurityHub.Types.AwsCloudFrontDistributionLogging where

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

-- | A complex type that controls whether access logs are written for the
-- distribution.
--
-- /See:/ 'newAwsCloudFrontDistributionLogging' smart constructor.
data AwsCloudFrontDistributionLogging = AwsCloudFrontDistributionLogging'
  { -- | With this field, you can enable or disable the selected distribution.
    AwsCloudFrontDistributionLogging -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | An optional string that you want CloudFront to use as a prefix to the
    -- access log filenames for this distribution.
    AwsCloudFrontDistributionLogging -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | The S3 bucket to store the access logs in.
    AwsCloudFrontDistributionLogging -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether you want CloudFront to include cookies in access logs.
    AwsCloudFrontDistributionLogging -> Maybe Bool
includeCookies :: Prelude.Maybe Prelude.Bool
  }
  deriving (AwsCloudFrontDistributionLogging
-> AwsCloudFrontDistributionLogging -> Bool
(AwsCloudFrontDistributionLogging
 -> AwsCloudFrontDistributionLogging -> Bool)
-> (AwsCloudFrontDistributionLogging
    -> AwsCloudFrontDistributionLogging -> Bool)
-> Eq AwsCloudFrontDistributionLogging
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCloudFrontDistributionLogging
-> AwsCloudFrontDistributionLogging -> Bool
$c/= :: AwsCloudFrontDistributionLogging
-> AwsCloudFrontDistributionLogging -> Bool
== :: AwsCloudFrontDistributionLogging
-> AwsCloudFrontDistributionLogging -> Bool
$c== :: AwsCloudFrontDistributionLogging
-> AwsCloudFrontDistributionLogging -> Bool
Prelude.Eq, ReadPrec [AwsCloudFrontDistributionLogging]
ReadPrec AwsCloudFrontDistributionLogging
Int -> ReadS AwsCloudFrontDistributionLogging
ReadS [AwsCloudFrontDistributionLogging]
(Int -> ReadS AwsCloudFrontDistributionLogging)
-> ReadS [AwsCloudFrontDistributionLogging]
-> ReadPrec AwsCloudFrontDistributionLogging
-> ReadPrec [AwsCloudFrontDistributionLogging]
-> Read AwsCloudFrontDistributionLogging
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCloudFrontDistributionLogging]
$creadListPrec :: ReadPrec [AwsCloudFrontDistributionLogging]
readPrec :: ReadPrec AwsCloudFrontDistributionLogging
$creadPrec :: ReadPrec AwsCloudFrontDistributionLogging
readList :: ReadS [AwsCloudFrontDistributionLogging]
$creadList :: ReadS [AwsCloudFrontDistributionLogging]
readsPrec :: Int -> ReadS AwsCloudFrontDistributionLogging
$creadsPrec :: Int -> ReadS AwsCloudFrontDistributionLogging
Prelude.Read, Int -> AwsCloudFrontDistributionLogging -> ShowS
[AwsCloudFrontDistributionLogging] -> ShowS
AwsCloudFrontDistributionLogging -> String
(Int -> AwsCloudFrontDistributionLogging -> ShowS)
-> (AwsCloudFrontDistributionLogging -> String)
-> ([AwsCloudFrontDistributionLogging] -> ShowS)
-> Show AwsCloudFrontDistributionLogging
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCloudFrontDistributionLogging] -> ShowS
$cshowList :: [AwsCloudFrontDistributionLogging] -> ShowS
show :: AwsCloudFrontDistributionLogging -> String
$cshow :: AwsCloudFrontDistributionLogging -> String
showsPrec :: Int -> AwsCloudFrontDistributionLogging -> ShowS
$cshowsPrec :: Int -> AwsCloudFrontDistributionLogging -> ShowS
Prelude.Show, (forall x.
 AwsCloudFrontDistributionLogging
 -> Rep AwsCloudFrontDistributionLogging x)
-> (forall x.
    Rep AwsCloudFrontDistributionLogging x
    -> AwsCloudFrontDistributionLogging)
-> Generic AwsCloudFrontDistributionLogging
forall x.
Rep AwsCloudFrontDistributionLogging x
-> AwsCloudFrontDistributionLogging
forall x.
AwsCloudFrontDistributionLogging
-> Rep AwsCloudFrontDistributionLogging x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsCloudFrontDistributionLogging x
-> AwsCloudFrontDistributionLogging
$cfrom :: forall x.
AwsCloudFrontDistributionLogging
-> Rep AwsCloudFrontDistributionLogging x
Prelude.Generic)

-- |
-- Create a value of 'AwsCloudFrontDistributionLogging' 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:
--
-- 'enabled', 'awsCloudFrontDistributionLogging_enabled' - With this field, you can enable or disable the selected distribution.
--
-- 'prefix', 'awsCloudFrontDistributionLogging_prefix' - An optional string that you want CloudFront to use as a prefix to the
-- access log filenames for this distribution.
--
-- 'bucket', 'awsCloudFrontDistributionLogging_bucket' - The S3 bucket to store the access logs in.
--
-- 'includeCookies', 'awsCloudFrontDistributionLogging_includeCookies' - Specifies whether you want CloudFront to include cookies in access logs.
newAwsCloudFrontDistributionLogging ::
  AwsCloudFrontDistributionLogging
newAwsCloudFrontDistributionLogging :: AwsCloudFrontDistributionLogging
newAwsCloudFrontDistributionLogging =
  AwsCloudFrontDistributionLogging' :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> AwsCloudFrontDistributionLogging
AwsCloudFrontDistributionLogging'
    { $sel:enabled:AwsCloudFrontDistributionLogging' :: Maybe Bool
enabled =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:prefix:AwsCloudFrontDistributionLogging' :: Maybe Text
prefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:AwsCloudFrontDistributionLogging' :: Maybe Text
bucket = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:includeCookies:AwsCloudFrontDistributionLogging' :: Maybe Bool
includeCookies = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | With this field, you can enable or disable the selected distribution.
awsCloudFrontDistributionLogging_enabled :: Lens.Lens' AwsCloudFrontDistributionLogging (Prelude.Maybe Prelude.Bool)
awsCloudFrontDistributionLogging_enabled :: (Maybe Bool -> f (Maybe Bool))
-> AwsCloudFrontDistributionLogging
-> f AwsCloudFrontDistributionLogging
awsCloudFrontDistributionLogging_enabled = (AwsCloudFrontDistributionLogging -> Maybe Bool)
-> (AwsCloudFrontDistributionLogging
    -> Maybe Bool -> AwsCloudFrontDistributionLogging)
-> Lens
     AwsCloudFrontDistributionLogging
     AwsCloudFrontDistributionLogging
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionLogging' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: AwsCloudFrontDistributionLogging
s@AwsCloudFrontDistributionLogging' {} Maybe Bool
a -> AwsCloudFrontDistributionLogging
s {$sel:enabled:AwsCloudFrontDistributionLogging' :: Maybe Bool
enabled = Maybe Bool
a} :: AwsCloudFrontDistributionLogging)

-- | An optional string that you want CloudFront to use as a prefix to the
-- access log filenames for this distribution.
awsCloudFrontDistributionLogging_prefix :: Lens.Lens' AwsCloudFrontDistributionLogging (Prelude.Maybe Prelude.Text)
awsCloudFrontDistributionLogging_prefix :: (Maybe Text -> f (Maybe Text))
-> AwsCloudFrontDistributionLogging
-> f AwsCloudFrontDistributionLogging
awsCloudFrontDistributionLogging_prefix = (AwsCloudFrontDistributionLogging -> Maybe Text)
-> (AwsCloudFrontDistributionLogging
    -> Maybe Text -> AwsCloudFrontDistributionLogging)
-> Lens
     AwsCloudFrontDistributionLogging
     AwsCloudFrontDistributionLogging
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionLogging' {Maybe Text
prefix :: Maybe Text
$sel:prefix:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: AwsCloudFrontDistributionLogging
s@AwsCloudFrontDistributionLogging' {} Maybe Text
a -> AwsCloudFrontDistributionLogging
s {$sel:prefix:AwsCloudFrontDistributionLogging' :: Maybe Text
prefix = Maybe Text
a} :: AwsCloudFrontDistributionLogging)

-- | The S3 bucket to store the access logs in.
awsCloudFrontDistributionLogging_bucket :: Lens.Lens' AwsCloudFrontDistributionLogging (Prelude.Maybe Prelude.Text)
awsCloudFrontDistributionLogging_bucket :: (Maybe Text -> f (Maybe Text))
-> AwsCloudFrontDistributionLogging
-> f AwsCloudFrontDistributionLogging
awsCloudFrontDistributionLogging_bucket = (AwsCloudFrontDistributionLogging -> Maybe Text)
-> (AwsCloudFrontDistributionLogging
    -> Maybe Text -> AwsCloudFrontDistributionLogging)
-> Lens
     AwsCloudFrontDistributionLogging
     AwsCloudFrontDistributionLogging
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionLogging' {Maybe Text
bucket :: Maybe Text
$sel:bucket:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: AwsCloudFrontDistributionLogging
s@AwsCloudFrontDistributionLogging' {} Maybe Text
a -> AwsCloudFrontDistributionLogging
s {$sel:bucket:AwsCloudFrontDistributionLogging' :: Maybe Text
bucket = Maybe Text
a} :: AwsCloudFrontDistributionLogging)

-- | Specifies whether you want CloudFront to include cookies in access logs.
awsCloudFrontDistributionLogging_includeCookies :: Lens.Lens' AwsCloudFrontDistributionLogging (Prelude.Maybe Prelude.Bool)
awsCloudFrontDistributionLogging_includeCookies :: (Maybe Bool -> f (Maybe Bool))
-> AwsCloudFrontDistributionLogging
-> f AwsCloudFrontDistributionLogging
awsCloudFrontDistributionLogging_includeCookies = (AwsCloudFrontDistributionLogging -> Maybe Bool)
-> (AwsCloudFrontDistributionLogging
    -> Maybe Bool -> AwsCloudFrontDistributionLogging)
-> Lens
     AwsCloudFrontDistributionLogging
     AwsCloudFrontDistributionLogging
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionLogging' {Maybe Bool
includeCookies :: Maybe Bool
$sel:includeCookies:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Bool
includeCookies} -> Maybe Bool
includeCookies) (\s :: AwsCloudFrontDistributionLogging
s@AwsCloudFrontDistributionLogging' {} Maybe Bool
a -> AwsCloudFrontDistributionLogging
s {$sel:includeCookies:AwsCloudFrontDistributionLogging' :: Maybe Bool
includeCookies = Maybe Bool
a} :: AwsCloudFrontDistributionLogging)

instance
  Core.FromJSON
    AwsCloudFrontDistributionLogging
  where
  parseJSON :: Value -> Parser AwsCloudFrontDistributionLogging
parseJSON =
    String
-> (Object -> Parser AwsCloudFrontDistributionLogging)
-> Value
-> Parser AwsCloudFrontDistributionLogging
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsCloudFrontDistributionLogging"
      ( \Object
x ->
          Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> AwsCloudFrontDistributionLogging
AwsCloudFrontDistributionLogging'
            (Maybe Bool
 -> Maybe Text
 -> Maybe Text
 -> Maybe Bool
 -> AwsCloudFrontDistributionLogging)
-> Parser (Maybe Bool)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Bool -> AwsCloudFrontDistributionLogging)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Enabled")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Bool -> AwsCloudFrontDistributionLogging)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Bool -> AwsCloudFrontDistributionLogging)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Prefix")
            Parser
  (Maybe Text -> Maybe Bool -> AwsCloudFrontDistributionLogging)
-> Parser (Maybe Text)
-> Parser (Maybe Bool -> AwsCloudFrontDistributionLogging)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Bucket")
            Parser (Maybe Bool -> AwsCloudFrontDistributionLogging)
-> Parser (Maybe Bool) -> Parser AwsCloudFrontDistributionLogging
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IncludeCookies")
      )

instance
  Prelude.Hashable
    AwsCloudFrontDistributionLogging

instance
  Prelude.NFData
    AwsCloudFrontDistributionLogging

instance Core.ToJSON AwsCloudFrontDistributionLogging where
  toJSON :: AwsCloudFrontDistributionLogging -> Value
toJSON AwsCloudFrontDistributionLogging' {Maybe Bool
Maybe Text
includeCookies :: Maybe Bool
bucket :: Maybe Text
prefix :: Maybe Text
enabled :: Maybe Bool
$sel:includeCookies:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Bool
$sel:bucket:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Text
$sel:prefix:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Text
$sel:enabled:AwsCloudFrontDistributionLogging' :: AwsCloudFrontDistributionLogging -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            (Text
"Prefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
prefix,
            (Text
"Bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
bucket,
            (Text
"IncludeCookies" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeCookies
          ]
      )