{-# 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.AwsCloudFrontDistributionDefaultCacheBehavior
-- 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.AwsCloudFrontDistributionDefaultCacheBehavior where

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

-- | Contains information about the default cache configuration for the
-- distribution.
--
-- /See:/ 'newAwsCloudFrontDistributionDefaultCacheBehavior' smart constructor.
data AwsCloudFrontDistributionDefaultCacheBehavior = AwsCloudFrontDistributionDefaultCacheBehavior'
  { -- | The protocol that viewers can use to access the files in an origin. You
    -- can specify the following options:
    --
    -- -   @allow-all@ - Viewers can use HTTP or HTTPS.
    --
    -- -   @redirect-to-https@ - CloudFront responds to HTTP requests with an
    --     HTTP status code of 301 (Moved Permanently) and the HTTPS URL. The
    --     viewer then uses the new URL to resubmit.
    --
    -- -   @https-only@ - CloudFront responds to HTTP request with an HTTP
    --     status code of 403 (Forbidden).
    AwsCloudFrontDistributionDefaultCacheBehavior -> Maybe Text
viewerProtocolPolicy :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsCloudFrontDistributionDefaultCacheBehavior
-> AwsCloudFrontDistributionDefaultCacheBehavior -> Bool
(AwsCloudFrontDistributionDefaultCacheBehavior
 -> AwsCloudFrontDistributionDefaultCacheBehavior -> Bool)
-> (AwsCloudFrontDistributionDefaultCacheBehavior
    -> AwsCloudFrontDistributionDefaultCacheBehavior -> Bool)
-> Eq AwsCloudFrontDistributionDefaultCacheBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCloudFrontDistributionDefaultCacheBehavior
-> AwsCloudFrontDistributionDefaultCacheBehavior -> Bool
$c/= :: AwsCloudFrontDistributionDefaultCacheBehavior
-> AwsCloudFrontDistributionDefaultCacheBehavior -> Bool
== :: AwsCloudFrontDistributionDefaultCacheBehavior
-> AwsCloudFrontDistributionDefaultCacheBehavior -> Bool
$c== :: AwsCloudFrontDistributionDefaultCacheBehavior
-> AwsCloudFrontDistributionDefaultCacheBehavior -> Bool
Prelude.Eq, ReadPrec [AwsCloudFrontDistributionDefaultCacheBehavior]
ReadPrec AwsCloudFrontDistributionDefaultCacheBehavior
Int -> ReadS AwsCloudFrontDistributionDefaultCacheBehavior
ReadS [AwsCloudFrontDistributionDefaultCacheBehavior]
(Int -> ReadS AwsCloudFrontDistributionDefaultCacheBehavior)
-> ReadS [AwsCloudFrontDistributionDefaultCacheBehavior]
-> ReadPrec AwsCloudFrontDistributionDefaultCacheBehavior
-> ReadPrec [AwsCloudFrontDistributionDefaultCacheBehavior]
-> Read AwsCloudFrontDistributionDefaultCacheBehavior
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCloudFrontDistributionDefaultCacheBehavior]
$creadListPrec :: ReadPrec [AwsCloudFrontDistributionDefaultCacheBehavior]
readPrec :: ReadPrec AwsCloudFrontDistributionDefaultCacheBehavior
$creadPrec :: ReadPrec AwsCloudFrontDistributionDefaultCacheBehavior
readList :: ReadS [AwsCloudFrontDistributionDefaultCacheBehavior]
$creadList :: ReadS [AwsCloudFrontDistributionDefaultCacheBehavior]
readsPrec :: Int -> ReadS AwsCloudFrontDistributionDefaultCacheBehavior
$creadsPrec :: Int -> ReadS AwsCloudFrontDistributionDefaultCacheBehavior
Prelude.Read, Int -> AwsCloudFrontDistributionDefaultCacheBehavior -> ShowS
[AwsCloudFrontDistributionDefaultCacheBehavior] -> ShowS
AwsCloudFrontDistributionDefaultCacheBehavior -> String
(Int -> AwsCloudFrontDistributionDefaultCacheBehavior -> ShowS)
-> (AwsCloudFrontDistributionDefaultCacheBehavior -> String)
-> ([AwsCloudFrontDistributionDefaultCacheBehavior] -> ShowS)
-> Show AwsCloudFrontDistributionDefaultCacheBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCloudFrontDistributionDefaultCacheBehavior] -> ShowS
$cshowList :: [AwsCloudFrontDistributionDefaultCacheBehavior] -> ShowS
show :: AwsCloudFrontDistributionDefaultCacheBehavior -> String
$cshow :: AwsCloudFrontDistributionDefaultCacheBehavior -> String
showsPrec :: Int -> AwsCloudFrontDistributionDefaultCacheBehavior -> ShowS
$cshowsPrec :: Int -> AwsCloudFrontDistributionDefaultCacheBehavior -> ShowS
Prelude.Show, (forall x.
 AwsCloudFrontDistributionDefaultCacheBehavior
 -> Rep AwsCloudFrontDistributionDefaultCacheBehavior x)
-> (forall x.
    Rep AwsCloudFrontDistributionDefaultCacheBehavior x
    -> AwsCloudFrontDistributionDefaultCacheBehavior)
-> Generic AwsCloudFrontDistributionDefaultCacheBehavior
forall x.
Rep AwsCloudFrontDistributionDefaultCacheBehavior x
-> AwsCloudFrontDistributionDefaultCacheBehavior
forall x.
AwsCloudFrontDistributionDefaultCacheBehavior
-> Rep AwsCloudFrontDistributionDefaultCacheBehavior x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsCloudFrontDistributionDefaultCacheBehavior x
-> AwsCloudFrontDistributionDefaultCacheBehavior
$cfrom :: forall x.
AwsCloudFrontDistributionDefaultCacheBehavior
-> Rep AwsCloudFrontDistributionDefaultCacheBehavior x
Prelude.Generic)

-- |
-- Create a value of 'AwsCloudFrontDistributionDefaultCacheBehavior' 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:
--
-- 'viewerProtocolPolicy', 'awsCloudFrontDistributionDefaultCacheBehavior_viewerProtocolPolicy' - The protocol that viewers can use to access the files in an origin. You
-- can specify the following options:
--
-- -   @allow-all@ - Viewers can use HTTP or HTTPS.
--
-- -   @redirect-to-https@ - CloudFront responds to HTTP requests with an
--     HTTP status code of 301 (Moved Permanently) and the HTTPS URL. The
--     viewer then uses the new URL to resubmit.
--
-- -   @https-only@ - CloudFront responds to HTTP request with an HTTP
--     status code of 403 (Forbidden).
newAwsCloudFrontDistributionDefaultCacheBehavior ::
  AwsCloudFrontDistributionDefaultCacheBehavior
newAwsCloudFrontDistributionDefaultCacheBehavior :: AwsCloudFrontDistributionDefaultCacheBehavior
newAwsCloudFrontDistributionDefaultCacheBehavior =
  AwsCloudFrontDistributionDefaultCacheBehavior' :: Maybe Text -> AwsCloudFrontDistributionDefaultCacheBehavior
AwsCloudFrontDistributionDefaultCacheBehavior'
    { $sel:viewerProtocolPolicy:AwsCloudFrontDistributionDefaultCacheBehavior' :: Maybe Text
viewerProtocolPolicy =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The protocol that viewers can use to access the files in an origin. You
-- can specify the following options:
--
-- -   @allow-all@ - Viewers can use HTTP or HTTPS.
--
-- -   @redirect-to-https@ - CloudFront responds to HTTP requests with an
--     HTTP status code of 301 (Moved Permanently) and the HTTPS URL. The
--     viewer then uses the new URL to resubmit.
--
-- -   @https-only@ - CloudFront responds to HTTP request with an HTTP
--     status code of 403 (Forbidden).
awsCloudFrontDistributionDefaultCacheBehavior_viewerProtocolPolicy :: Lens.Lens' AwsCloudFrontDistributionDefaultCacheBehavior (Prelude.Maybe Prelude.Text)
awsCloudFrontDistributionDefaultCacheBehavior_viewerProtocolPolicy :: (Maybe Text -> f (Maybe Text))
-> AwsCloudFrontDistributionDefaultCacheBehavior
-> f AwsCloudFrontDistributionDefaultCacheBehavior
awsCloudFrontDistributionDefaultCacheBehavior_viewerProtocolPolicy = (AwsCloudFrontDistributionDefaultCacheBehavior -> Maybe Text)
-> (AwsCloudFrontDistributionDefaultCacheBehavior
    -> Maybe Text -> AwsCloudFrontDistributionDefaultCacheBehavior)
-> Lens
     AwsCloudFrontDistributionDefaultCacheBehavior
     AwsCloudFrontDistributionDefaultCacheBehavior
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionDefaultCacheBehavior' {Maybe Text
viewerProtocolPolicy :: Maybe Text
$sel:viewerProtocolPolicy:AwsCloudFrontDistributionDefaultCacheBehavior' :: AwsCloudFrontDistributionDefaultCacheBehavior -> Maybe Text
viewerProtocolPolicy} -> Maybe Text
viewerProtocolPolicy) (\s :: AwsCloudFrontDistributionDefaultCacheBehavior
s@AwsCloudFrontDistributionDefaultCacheBehavior' {} Maybe Text
a -> AwsCloudFrontDistributionDefaultCacheBehavior
s {$sel:viewerProtocolPolicy:AwsCloudFrontDistributionDefaultCacheBehavior' :: Maybe Text
viewerProtocolPolicy = Maybe Text
a} :: AwsCloudFrontDistributionDefaultCacheBehavior)

instance
  Core.FromJSON
    AwsCloudFrontDistributionDefaultCacheBehavior
  where
  parseJSON :: Value -> Parser AwsCloudFrontDistributionDefaultCacheBehavior
parseJSON =
    String
-> (Object -> Parser AwsCloudFrontDistributionDefaultCacheBehavior)
-> Value
-> Parser AwsCloudFrontDistributionDefaultCacheBehavior
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsCloudFrontDistributionDefaultCacheBehavior"
      ( \Object
x ->
          Maybe Text -> AwsCloudFrontDistributionDefaultCacheBehavior
AwsCloudFrontDistributionDefaultCacheBehavior'
            (Maybe Text -> AwsCloudFrontDistributionDefaultCacheBehavior)
-> Parser (Maybe Text)
-> Parser AwsCloudFrontDistributionDefaultCacheBehavior
forall (f :: * -> *) a b. Functor 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
"ViewerProtocolPolicy")
      )

instance
  Prelude.Hashable
    AwsCloudFrontDistributionDefaultCacheBehavior

instance
  Prelude.NFData
    AwsCloudFrontDistributionDefaultCacheBehavior

instance
  Core.ToJSON
    AwsCloudFrontDistributionDefaultCacheBehavior
  where
  toJSON :: AwsCloudFrontDistributionDefaultCacheBehavior -> Value
toJSON
    AwsCloudFrontDistributionDefaultCacheBehavior' {Maybe Text
viewerProtocolPolicy :: Maybe Text
$sel:viewerProtocolPolicy:AwsCloudFrontDistributionDefaultCacheBehavior' :: AwsCloudFrontDistributionDefaultCacheBehavior -> Maybe Text
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"ViewerProtocolPolicy" 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
viewerProtocolPolicy
            ]
        )