
commonMain.aws.sdk.kotlin.services.cloudfront.model.CustomErrorResponse.kt Maven / Gradle / Ivy
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.cloudfront.model
import aws.smithy.kotlin.runtime.SdkDsl
/**
* 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 [Customizing Error Responses](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html) in the *Amazon CloudFront Developer Guide*.
*/
public class CustomErrorResponse private constructor(builder: Builder) {
/**
* 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 [Customizing Error Responses](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html) in the *Amazon CloudFront Developer Guide*.
*/
public val errorCachingMinTtl: kotlin.Long? = builder.errorCachingMinTtl
/**
* The HTTP status code for which you want to specify a custom error page and/or a caching duration.
*/
public val errorCode: kotlin.Int = requireNotNull(builder.errorCode) { "A non-null value must be provided for errorCode" }
/**
* 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`.
*/
public val responseCode: kotlin.String? = builder.responseCode
/**
* 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.
*/
public val responsePagePath: kotlin.String? = builder.responsePagePath
public companion object {
public operator fun invoke(block: Builder.() -> kotlin.Unit): aws.sdk.kotlin.services.cloudfront.model.CustomErrorResponse = Builder().apply(block).build()
}
override fun toString(): kotlin.String = buildString {
append("CustomErrorResponse(")
append("errorCachingMinTtl=$errorCachingMinTtl,")
append("errorCode=$errorCode,")
append("responseCode=$responseCode,")
append("responsePagePath=$responsePagePath")
append(")")
}
override fun hashCode(): kotlin.Int {
var result = errorCachingMinTtl?.hashCode() ?: 0
result = 31 * result + (errorCode)
result = 31 * result + (responseCode?.hashCode() ?: 0)
result = 31 * result + (responsePagePath?.hashCode() ?: 0)
return result
}
override fun equals(other: kotlin.Any?): kotlin.Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false
other as CustomErrorResponse
if (errorCachingMinTtl != other.errorCachingMinTtl) return false
if (errorCode != other.errorCode) return false
if (responseCode != other.responseCode) return false
if (responsePagePath != other.responsePagePath) return false
return true
}
public inline fun copy(block: Builder.() -> kotlin.Unit = {}): aws.sdk.kotlin.services.cloudfront.model.CustomErrorResponse = Builder(this).apply(block).build()
@SdkDsl
public class Builder {
/**
* 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 [Customizing Error Responses](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html) in the *Amazon CloudFront Developer Guide*.
*/
public var errorCachingMinTtl: kotlin.Long? = null
/**
* The HTTP status code for which you want to specify a custom error page and/or a caching duration.
*/
public var errorCode: kotlin.Int? = null
/**
* 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`.
*/
public var responseCode: kotlin.String? = null
/**
* 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.
*/
public var responsePagePath: kotlin.String? = null
@PublishedApi
internal constructor()
@PublishedApi
internal constructor(x: aws.sdk.kotlin.services.cloudfront.model.CustomErrorResponse) : this() {
this.errorCachingMinTtl = x.errorCachingMinTtl
this.errorCode = x.errorCode
this.responseCode = x.responseCode
this.responsePagePath = x.responsePagePath
}
@PublishedApi
internal fun build(): aws.sdk.kotlin.services.cloudfront.model.CustomErrorResponse = CustomErrorResponse(this)
internal fun correctErrors(): Builder {
if (errorCode == null) errorCode = 0
return this
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy