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

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

-- | Information about a cache behavior for the distribution.
--
-- /See:/ 'newAwsCloudFrontDistributionCacheBehavior' smart constructor.
data AwsCloudFrontDistributionCacheBehavior = AwsCloudFrontDistributionCacheBehavior'
  { -- | 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).
    AwsCloudFrontDistributionCacheBehavior -> Maybe Text
viewerProtocolPolicy :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsCloudFrontDistributionCacheBehavior
-> AwsCloudFrontDistributionCacheBehavior -> Bool
(AwsCloudFrontDistributionCacheBehavior
 -> AwsCloudFrontDistributionCacheBehavior -> Bool)
-> (AwsCloudFrontDistributionCacheBehavior
    -> AwsCloudFrontDistributionCacheBehavior -> Bool)
-> Eq AwsCloudFrontDistributionCacheBehavior
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsCloudFrontDistributionCacheBehavior
-> AwsCloudFrontDistributionCacheBehavior -> Bool
$c/= :: AwsCloudFrontDistributionCacheBehavior
-> AwsCloudFrontDistributionCacheBehavior -> Bool
== :: AwsCloudFrontDistributionCacheBehavior
-> AwsCloudFrontDistributionCacheBehavior -> Bool
$c== :: AwsCloudFrontDistributionCacheBehavior
-> AwsCloudFrontDistributionCacheBehavior -> Bool
Prelude.Eq, ReadPrec [AwsCloudFrontDistributionCacheBehavior]
ReadPrec AwsCloudFrontDistributionCacheBehavior
Int -> ReadS AwsCloudFrontDistributionCacheBehavior
ReadS [AwsCloudFrontDistributionCacheBehavior]
(Int -> ReadS AwsCloudFrontDistributionCacheBehavior)
-> ReadS [AwsCloudFrontDistributionCacheBehavior]
-> ReadPrec AwsCloudFrontDistributionCacheBehavior
-> ReadPrec [AwsCloudFrontDistributionCacheBehavior]
-> Read AwsCloudFrontDistributionCacheBehavior
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsCloudFrontDistributionCacheBehavior]
$creadListPrec :: ReadPrec [AwsCloudFrontDistributionCacheBehavior]
readPrec :: ReadPrec AwsCloudFrontDistributionCacheBehavior
$creadPrec :: ReadPrec AwsCloudFrontDistributionCacheBehavior
readList :: ReadS [AwsCloudFrontDistributionCacheBehavior]
$creadList :: ReadS [AwsCloudFrontDistributionCacheBehavior]
readsPrec :: Int -> ReadS AwsCloudFrontDistributionCacheBehavior
$creadsPrec :: Int -> ReadS AwsCloudFrontDistributionCacheBehavior
Prelude.Read, Int -> AwsCloudFrontDistributionCacheBehavior -> ShowS
[AwsCloudFrontDistributionCacheBehavior] -> ShowS
AwsCloudFrontDistributionCacheBehavior -> String
(Int -> AwsCloudFrontDistributionCacheBehavior -> ShowS)
-> (AwsCloudFrontDistributionCacheBehavior -> String)
-> ([AwsCloudFrontDistributionCacheBehavior] -> ShowS)
-> Show AwsCloudFrontDistributionCacheBehavior
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsCloudFrontDistributionCacheBehavior] -> ShowS
$cshowList :: [AwsCloudFrontDistributionCacheBehavior] -> ShowS
show :: AwsCloudFrontDistributionCacheBehavior -> String
$cshow :: AwsCloudFrontDistributionCacheBehavior -> String
showsPrec :: Int -> AwsCloudFrontDistributionCacheBehavior -> ShowS
$cshowsPrec :: Int -> AwsCloudFrontDistributionCacheBehavior -> ShowS
Prelude.Show, (forall x.
 AwsCloudFrontDistributionCacheBehavior
 -> Rep AwsCloudFrontDistributionCacheBehavior x)
-> (forall x.
    Rep AwsCloudFrontDistributionCacheBehavior x
    -> AwsCloudFrontDistributionCacheBehavior)
-> Generic AwsCloudFrontDistributionCacheBehavior
forall x.
Rep AwsCloudFrontDistributionCacheBehavior x
-> AwsCloudFrontDistributionCacheBehavior
forall x.
AwsCloudFrontDistributionCacheBehavior
-> Rep AwsCloudFrontDistributionCacheBehavior x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsCloudFrontDistributionCacheBehavior x
-> AwsCloudFrontDistributionCacheBehavior
$cfrom :: forall x.
AwsCloudFrontDistributionCacheBehavior
-> Rep AwsCloudFrontDistributionCacheBehavior x
Prelude.Generic)

-- |
-- Create a value of 'AwsCloudFrontDistributionCacheBehavior' 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', 'awsCloudFrontDistributionCacheBehavior_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).
newAwsCloudFrontDistributionCacheBehavior ::
  AwsCloudFrontDistributionCacheBehavior
newAwsCloudFrontDistributionCacheBehavior :: AwsCloudFrontDistributionCacheBehavior
newAwsCloudFrontDistributionCacheBehavior =
  AwsCloudFrontDistributionCacheBehavior' :: Maybe Text -> AwsCloudFrontDistributionCacheBehavior
AwsCloudFrontDistributionCacheBehavior'
    { $sel:viewerProtocolPolicy:AwsCloudFrontDistributionCacheBehavior' :: 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).
awsCloudFrontDistributionCacheBehavior_viewerProtocolPolicy :: Lens.Lens' AwsCloudFrontDistributionCacheBehavior (Prelude.Maybe Prelude.Text)
awsCloudFrontDistributionCacheBehavior_viewerProtocolPolicy :: (Maybe Text -> f (Maybe Text))
-> AwsCloudFrontDistributionCacheBehavior
-> f AwsCloudFrontDistributionCacheBehavior
awsCloudFrontDistributionCacheBehavior_viewerProtocolPolicy = (AwsCloudFrontDistributionCacheBehavior -> Maybe Text)
-> (AwsCloudFrontDistributionCacheBehavior
    -> Maybe Text -> AwsCloudFrontDistributionCacheBehavior)
-> Lens
     AwsCloudFrontDistributionCacheBehavior
     AwsCloudFrontDistributionCacheBehavior
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsCloudFrontDistributionCacheBehavior' {Maybe Text
viewerProtocolPolicy :: Maybe Text
$sel:viewerProtocolPolicy:AwsCloudFrontDistributionCacheBehavior' :: AwsCloudFrontDistributionCacheBehavior -> Maybe Text
viewerProtocolPolicy} -> Maybe Text
viewerProtocolPolicy) (\s :: AwsCloudFrontDistributionCacheBehavior
s@AwsCloudFrontDistributionCacheBehavior' {} Maybe Text
a -> AwsCloudFrontDistributionCacheBehavior
s {$sel:viewerProtocolPolicy:AwsCloudFrontDistributionCacheBehavior' :: Maybe Text
viewerProtocolPolicy = Maybe Text
a} :: AwsCloudFrontDistributionCacheBehavior)

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

instance
  Prelude.NFData
    AwsCloudFrontDistributionCacheBehavior

instance
  Core.ToJSON
    AwsCloudFrontDistributionCacheBehavior
  where
  toJSON :: AwsCloudFrontDistributionCacheBehavior -> Value
toJSON AwsCloudFrontDistributionCacheBehavior' {Maybe Text
viewerProtocolPolicy :: Maybe Text
$sel:viewerProtocolPolicy:AwsCloudFrontDistributionCacheBehavior' :: AwsCloudFrontDistributionCacheBehavior -> 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
          ]
      )