{-# 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.CustomErrorResponse -- 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.CustomErrorResponse where 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 complex type that controls: -- -- - Whether CloudFront replaces HTTP status codes in the 4xx and 5xx -- range with custom error messages before returning the response to -- the viewer. -- -- - How long CloudFront caches HTTP status codes in the 4xx and 5xx -- range. -- -- For more information about custom error pages, see -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html Customizing Error Responses> -- in the /Amazon CloudFront Developer Guide/. -- -- /See:/ 'newCustomErrorResponse' smart constructor. data CustomErrorResponse = CustomErrorResponse' { -- | The minimum amount of time, in seconds, that you want CloudFront to -- cache the HTTP status code specified in @ErrorCode@. When this time -- period has elapsed, CloudFront queries your origin to see whether the -- problem that caused the error has been resolved and the requested object -- is now available. -- -- For more information, see -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html Customizing Error Responses> -- in the /Amazon CloudFront Developer Guide/. CustomErrorResponse -> Maybe Integer errorCachingMinTTL :: Prelude.Maybe Prelude.Integer, -- | The HTTP status code that you want CloudFront to return to the viewer -- along with the custom error page. There are a variety of reasons that -- you might want CloudFront to return a status code different from the -- status code that your origin returned to CloudFront, for example: -- -- - Some Internet devices (some firewalls and corporate proxies, for -- example) intercept HTTP 4xx and 5xx and prevent the response from -- being returned to the viewer. If you substitute @200@, the response -- typically won\'t be intercepted. -- -- - If you don\'t care about distinguishing among different client -- errors or server errors, you can specify @400@ or @500@ as the -- @ResponseCode@ for all 4xx or 5xx errors. -- -- - You might want to return a @200@ status code (OK) and static website -- so your customers don\'t know that your website is down. -- -- If you specify a value for @ResponseCode@, you must also specify a value -- for @ResponsePagePath@. CustomErrorResponse -> Maybe Text responseCode :: Prelude.Maybe Prelude.Text, -- | The path to the custom error page that you want CloudFront to return to -- a viewer when your origin returns the HTTP status code specified by -- @ErrorCode@, for example, @\/4xx-errors\/403-forbidden.html@. If you -- want to store your objects and your custom error pages in different -- locations, your distribution must include a cache behavior for which the -- following is true: -- -- - The value of @PathPattern@ matches the path to your custom error -- messages. For example, suppose you saved custom error pages for 4xx -- errors in an Amazon S3 bucket in a directory named @\/4xx-errors@. -- Your distribution must include a cache behavior for which the path -- pattern routes requests for your custom error pages to that -- location, for example, @\/4xx-errors\/*@. -- -- - The value of @TargetOriginId@ specifies the value of the @ID@ -- element for the origin that contains your custom error pages. -- -- If you specify a value for @ResponsePagePath@, you must also specify a -- value for @ResponseCode@. -- -- We recommend that you store custom error pages in an Amazon S3 bucket. -- If you store custom error pages on an HTTP server and the server starts -- to return 5xx errors, CloudFront can\'t get the files that you want to -- return to viewers because the origin server is unavailable. CustomErrorResponse -> Maybe Text responsePagePath :: Prelude.Maybe Prelude.Text, -- | The HTTP status code for which you want to specify a custom error page -- and\/or a caching duration. CustomErrorResponse -> Int errorCode :: Prelude.Int } deriving (CustomErrorResponse -> CustomErrorResponse -> Bool forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: CustomErrorResponse -> CustomErrorResponse -> Bool $c/= :: CustomErrorResponse -> CustomErrorResponse -> Bool == :: CustomErrorResponse -> CustomErrorResponse -> Bool $c== :: CustomErrorResponse -> CustomErrorResponse -> Bool Prelude.Eq, ReadPrec [CustomErrorResponse] ReadPrec CustomErrorResponse Int -> ReadS CustomErrorResponse ReadS [CustomErrorResponse] forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a readListPrec :: ReadPrec [CustomErrorResponse] $creadListPrec :: ReadPrec [CustomErrorResponse] readPrec :: ReadPrec CustomErrorResponse $creadPrec :: ReadPrec CustomErrorResponse readList :: ReadS [CustomErrorResponse] $creadList :: ReadS [CustomErrorResponse] readsPrec :: Int -> ReadS CustomErrorResponse $creadsPrec :: Int -> ReadS CustomErrorResponse Prelude.Read, Int -> CustomErrorResponse -> ShowS [CustomErrorResponse] -> ShowS CustomErrorResponse -> String forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [CustomErrorResponse] -> ShowS $cshowList :: [CustomErrorResponse] -> ShowS show :: CustomErrorResponse -> String $cshow :: CustomErrorResponse -> String showsPrec :: Int -> CustomErrorResponse -> ShowS $cshowsPrec :: Int -> CustomErrorResponse -> ShowS Prelude.Show, forall x. Rep CustomErrorResponse x -> CustomErrorResponse forall x. CustomErrorResponse -> Rep CustomErrorResponse x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a $cto :: forall x. Rep CustomErrorResponse x -> CustomErrorResponse $cfrom :: forall x. CustomErrorResponse -> Rep CustomErrorResponse x Prelude.Generic) -- | -- Create a value of 'CustomErrorResponse' 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: -- -- 'errorCachingMinTTL', 'customErrorResponse_errorCachingMinTTL' - The minimum amount of time, in seconds, that you want CloudFront to -- cache the HTTP status code specified in @ErrorCode@. When this time -- period has elapsed, CloudFront queries your origin to see whether the -- problem that caused the error has been resolved and the requested object -- is now available. -- -- For more information, see -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html Customizing Error Responses> -- in the /Amazon CloudFront Developer Guide/. -- -- 'responseCode', 'customErrorResponse_responseCode' - The HTTP status code that you want CloudFront to return to the viewer -- along with the custom error page. There are a variety of reasons that -- you might want CloudFront to return a status code different from the -- status code that your origin returned to CloudFront, for example: -- -- - Some Internet devices (some firewalls and corporate proxies, for -- example) intercept HTTP 4xx and 5xx and prevent the response from -- being returned to the viewer. If you substitute @200@, the response -- typically won\'t be intercepted. -- -- - If you don\'t care about distinguishing among different client -- errors or server errors, you can specify @400@ or @500@ as the -- @ResponseCode@ for all 4xx or 5xx errors. -- -- - You might want to return a @200@ status code (OK) and static website -- so your customers don\'t know that your website is down. -- -- If you specify a value for @ResponseCode@, you must also specify a value -- for @ResponsePagePath@. -- -- 'responsePagePath', 'customErrorResponse_responsePagePath' - The path to the custom error page that you want CloudFront to return to -- a viewer when your origin returns the HTTP status code specified by -- @ErrorCode@, for example, @\/4xx-errors\/403-forbidden.html@. If you -- want to store your objects and your custom error pages in different -- locations, your distribution must include a cache behavior for which the -- following is true: -- -- - The value of @PathPattern@ matches the path to your custom error -- messages. For example, suppose you saved custom error pages for 4xx -- errors in an Amazon S3 bucket in a directory named @\/4xx-errors@. -- Your distribution must include a cache behavior for which the path -- pattern routes requests for your custom error pages to that -- location, for example, @\/4xx-errors\/*@. -- -- - The value of @TargetOriginId@ specifies the value of the @ID@ -- element for the origin that contains your custom error pages. -- -- If you specify a value for @ResponsePagePath@, you must also specify a -- value for @ResponseCode@. -- -- We recommend that you store custom error pages in an Amazon S3 bucket. -- If you store custom error pages on an HTTP server and the server starts -- to return 5xx errors, CloudFront can\'t get the files that you want to -- return to viewers because the origin server is unavailable. -- -- 'errorCode', 'customErrorResponse_errorCode' - The HTTP status code for which you want to specify a custom error page -- and\/or a caching duration. newCustomErrorResponse :: -- | 'errorCode' Prelude.Int -> CustomErrorResponse newCustomErrorResponse :: Int -> CustomErrorResponse newCustomErrorResponse Int pErrorCode_ = CustomErrorResponse' { $sel:errorCachingMinTTL:CustomErrorResponse' :: Maybe Integer errorCachingMinTTL = forall a. Maybe a Prelude.Nothing, $sel:responseCode:CustomErrorResponse' :: Maybe Text responseCode = forall a. Maybe a Prelude.Nothing, $sel:responsePagePath:CustomErrorResponse' :: Maybe Text responsePagePath = forall a. Maybe a Prelude.Nothing, $sel:errorCode:CustomErrorResponse' :: Int errorCode = Int pErrorCode_ } -- | The minimum amount of time, in seconds, that you want CloudFront to -- cache the HTTP status code specified in @ErrorCode@. When this time -- period has elapsed, CloudFront queries your origin to see whether the -- problem that caused the error has been resolved and the requested object -- is now available. -- -- For more information, see -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html Customizing Error Responses> -- in the /Amazon CloudFront Developer Guide/. customErrorResponse_errorCachingMinTTL :: Lens.Lens' CustomErrorResponse (Prelude.Maybe Prelude.Integer) customErrorResponse_errorCachingMinTTL :: Lens' CustomErrorResponse (Maybe Integer) customErrorResponse_errorCachingMinTTL = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\CustomErrorResponse' {Maybe Integer errorCachingMinTTL :: Maybe Integer $sel:errorCachingMinTTL:CustomErrorResponse' :: CustomErrorResponse -> Maybe Integer errorCachingMinTTL} -> Maybe Integer errorCachingMinTTL) (\s :: CustomErrorResponse s@CustomErrorResponse' {} Maybe Integer a -> CustomErrorResponse s {$sel:errorCachingMinTTL:CustomErrorResponse' :: Maybe Integer errorCachingMinTTL = Maybe Integer a} :: CustomErrorResponse) -- | The HTTP status code that you want CloudFront to return to the viewer -- along with the custom error page. There are a variety of reasons that -- you might want CloudFront to return a status code different from the -- status code that your origin returned to CloudFront, for example: -- -- - Some Internet devices (some firewalls and corporate proxies, for -- example) intercept HTTP 4xx and 5xx and prevent the response from -- being returned to the viewer. If you substitute @200@, the response -- typically won\'t be intercepted. -- -- - If you don\'t care about distinguishing among different client -- errors or server errors, you can specify @400@ or @500@ as the -- @ResponseCode@ for all 4xx or 5xx errors. -- -- - You might want to return a @200@ status code (OK) and static website -- so your customers don\'t know that your website is down. -- -- If you specify a value for @ResponseCode@, you must also specify a value -- for @ResponsePagePath@. customErrorResponse_responseCode :: Lens.Lens' CustomErrorResponse (Prelude.Maybe Prelude.Text) customErrorResponse_responseCode :: Lens' CustomErrorResponse (Maybe Text) customErrorResponse_responseCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\CustomErrorResponse' {Maybe Text responseCode :: Maybe Text $sel:responseCode:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text responseCode} -> Maybe Text responseCode) (\s :: CustomErrorResponse s@CustomErrorResponse' {} Maybe Text a -> CustomErrorResponse s {$sel:responseCode:CustomErrorResponse' :: Maybe Text responseCode = Maybe Text a} :: CustomErrorResponse) -- | The path to the custom error page that you want CloudFront to return to -- a viewer when your origin returns the HTTP status code specified by -- @ErrorCode@, for example, @\/4xx-errors\/403-forbidden.html@. If you -- want to store your objects and your custom error pages in different -- locations, your distribution must include a cache behavior for which the -- following is true: -- -- - The value of @PathPattern@ matches the path to your custom error -- messages. For example, suppose you saved custom error pages for 4xx -- errors in an Amazon S3 bucket in a directory named @\/4xx-errors@. -- Your distribution must include a cache behavior for which the path -- pattern routes requests for your custom error pages to that -- location, for example, @\/4xx-errors\/*@. -- -- - The value of @TargetOriginId@ specifies the value of the @ID@ -- element for the origin that contains your custom error pages. -- -- If you specify a value for @ResponsePagePath@, you must also specify a -- value for @ResponseCode@. -- -- We recommend that you store custom error pages in an Amazon S3 bucket. -- If you store custom error pages on an HTTP server and the server starts -- to return 5xx errors, CloudFront can\'t get the files that you want to -- return to viewers because the origin server is unavailable. customErrorResponse_responsePagePath :: Lens.Lens' CustomErrorResponse (Prelude.Maybe Prelude.Text) customErrorResponse_responsePagePath :: Lens' CustomErrorResponse (Maybe Text) customErrorResponse_responsePagePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\CustomErrorResponse' {Maybe Text responsePagePath :: Maybe Text $sel:responsePagePath:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text responsePagePath} -> Maybe Text responsePagePath) (\s :: CustomErrorResponse s@CustomErrorResponse' {} Maybe Text a -> CustomErrorResponse s {$sel:responsePagePath:CustomErrorResponse' :: Maybe Text responsePagePath = Maybe Text a} :: CustomErrorResponse) -- | The HTTP status code for which you want to specify a custom error page -- and\/or a caching duration. customErrorResponse_errorCode :: Lens.Lens' CustomErrorResponse Prelude.Int customErrorResponse_errorCode :: Lens' CustomErrorResponse Int customErrorResponse_errorCode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b Lens.lens (\CustomErrorResponse' {Int errorCode :: Int $sel:errorCode:CustomErrorResponse' :: CustomErrorResponse -> Int errorCode} -> Int errorCode) (\s :: CustomErrorResponse s@CustomErrorResponse' {} Int a -> CustomErrorResponse s {$sel:errorCode:CustomErrorResponse' :: Int errorCode = Int a} :: CustomErrorResponse) instance Data.FromXML CustomErrorResponse where parseXML :: [Node] -> Either String CustomErrorResponse parseXML [Node] x = Maybe Integer -> Maybe Text -> Maybe Text -> Int -> CustomErrorResponse CustomErrorResponse' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b Prelude.<$> ([Node] x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a) Data..@? Text "ErrorCachingMinTTL") 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 "ResponseCode") 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 "ResponsePagePath") 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 "ErrorCode") instance Prelude.Hashable CustomErrorResponse where hashWithSalt :: Int -> CustomErrorResponse -> Int hashWithSalt Int _salt CustomErrorResponse' {Int Maybe Integer Maybe Text errorCode :: Int responsePagePath :: Maybe Text responseCode :: Maybe Text errorCachingMinTTL :: Maybe Integer $sel:errorCode:CustomErrorResponse' :: CustomErrorResponse -> Int $sel:responsePagePath:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text $sel:responseCode:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text $sel:errorCachingMinTTL:CustomErrorResponse' :: CustomErrorResponse -> Maybe Integer ..} = Int _salt forall a. Hashable a => Int -> a -> Int `Prelude.hashWithSalt` Maybe Integer errorCachingMinTTL forall a. Hashable a => Int -> a -> Int `Prelude.hashWithSalt` Maybe Text responseCode forall a. Hashable a => Int -> a -> Int `Prelude.hashWithSalt` Maybe Text responsePagePath forall a. Hashable a => Int -> a -> Int `Prelude.hashWithSalt` Int errorCode instance Prelude.NFData CustomErrorResponse where rnf :: CustomErrorResponse -> () rnf CustomErrorResponse' {Int Maybe Integer Maybe Text errorCode :: Int responsePagePath :: Maybe Text responseCode :: Maybe Text errorCachingMinTTL :: Maybe Integer $sel:errorCode:CustomErrorResponse' :: CustomErrorResponse -> Int $sel:responsePagePath:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text $sel:responseCode:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text $sel:errorCachingMinTTL:CustomErrorResponse' :: CustomErrorResponse -> Maybe Integer ..} = forall a. NFData a => a -> () Prelude.rnf Maybe Integer errorCachingMinTTL seq :: forall a b. a -> b -> b `Prelude.seq` forall a. NFData a => a -> () Prelude.rnf Maybe Text responseCode seq :: forall a b. a -> b -> b `Prelude.seq` forall a. NFData a => a -> () Prelude.rnf Maybe Text responsePagePath seq :: forall a b. a -> b -> b `Prelude.seq` forall a. NFData a => a -> () Prelude.rnf Int errorCode instance Data.ToXML CustomErrorResponse where toXML :: CustomErrorResponse -> XML toXML CustomErrorResponse' {Int Maybe Integer Maybe Text errorCode :: Int responsePagePath :: Maybe Text responseCode :: Maybe Text errorCachingMinTTL :: Maybe Integer $sel:errorCode:CustomErrorResponse' :: CustomErrorResponse -> Int $sel:responsePagePath:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text $sel:responseCode:CustomErrorResponse' :: CustomErrorResponse -> Maybe Text $sel:errorCachingMinTTL:CustomErrorResponse' :: CustomErrorResponse -> Maybe Integer ..} = forall a. Monoid a => [a] -> a Prelude.mconcat [ Name "ErrorCachingMinTTL" forall a. ToXML a => Name -> a -> XML Data.@= Maybe Integer errorCachingMinTTL, Name "ResponseCode" forall a. ToXML a => Name -> a -> XML Data.@= Maybe Text responseCode, Name "ResponsePagePath" forall a. ToXML a => Name -> a -> XML Data.@= Maybe Text responsePagePath, Name "ErrorCode" forall a. ToXML a => Name -> a -> XML Data.@= Int errorCode ]