All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.sdk.kotlin.services.route53.endpoints.DefaultRoute53EndpointProvider.kt Maven / Gradle / Ivy

The newest version!
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!

package aws.sdk.kotlin.services.route53.endpoints

import aws.sdk.kotlin.services.route53.endpoints.internal.partition
import aws.smithy.kotlin.runtime.businessmetrics.ServiceEndpointOverride
import aws.smithy.kotlin.runtime.client.endpoints.Endpoint
import aws.smithy.kotlin.runtime.client.endpoints.EndpointProviderException
import aws.smithy.kotlin.runtime.client.endpoints.SigningContextAttributeKey
import aws.smithy.kotlin.runtime.collections.attributesOf
import aws.smithy.kotlin.runtime.http.auth.sigV4
import aws.smithy.kotlin.runtime.net.url.Url

/**
 * The default endpoint provider as specified by the service model.
 */
public class DefaultRoute53EndpointProvider: Route53EndpointProvider {
    public override suspend fun resolveEndpoint(params: Route53EndpointParameters): Endpoint {
        if (
            params.endpoint != null
        ) {
            if (
                params.useFips == true
            ) {
                throw EndpointProviderException("Invalid Configuration: FIPS and custom endpoint are not supported")
            }
            if (
                params.useDualStack == true
            ) {
                throw EndpointProviderException("Invalid Configuration: Dualstack and custom endpoint are not supported")
            }
            return Endpoint(
                Url.parse(params.endpoint),
                attributes = attributesOf {
                    ServiceEndpointOverride to true
                },
            )
        }
        if (
            params.region != null
        ) {
            run {
                val partitionResult = partition(params.region)
                if (
                    partitionResult != null
                ) {
                    if (
                        partitionResult?.name == "aws" &&
                        params.useFips == false &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.amazonaws.com"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "us-east-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws" &&
                        params.useFips == true &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53-fips.amazonaws.com"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "us-east-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws-cn" &&
                        params.useFips == false &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.amazonaws.com.cn"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "cn-northwest-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws-us-gov" &&
                        params.useFips == false &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.us-gov.amazonaws.com"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "us-gov-west-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws-us-gov" &&
                        params.useFips == true &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.us-gov.amazonaws.com"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "us-gov-west-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws-iso" &&
                        params.useFips == false &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.c2s.ic.gov"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "us-iso-east-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws-iso-b" &&
                        params.useFips == false &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.sc2s.sgov.gov"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "us-isob-east-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws-iso-e" &&
                        params.useFips == false &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.cloud.adc-e.uk"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "eu-isoe-west-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        partitionResult?.name == "aws-iso-f" &&
                        params.useFips == false &&
                        params.useDualStack == false
                    ) {
                        return Endpoint(
                            Url.parse("https://route53.csp.hci.ic.gov"),
                            attributes = attributesOf {
                                SigningContextAttributeKey to listOf(
                                    sigV4(
                                        serviceName = "route53",
                                        disableDoubleUriEncode = false,
                                        signingRegion = "us-isof-south-1",
                                    ),
                                )
                            },
                        )
                    }
                    if (
                        params.useFips == true &&
                        params.useDualStack == true
                    ) {
                        if (
                            true == partitionResult?.supportsFIPS &&
                            true == partitionResult?.supportsDualStack
                        ) {
                            return Endpoint(
                                Url.parse("https://route53-fips.${params.region}.${partitionResult?.dualStackDnsSuffix}"),
                            )
                        }
                        throw EndpointProviderException("FIPS and DualStack are enabled, but this partition does not support one or both")
                    }
                    if (
                        params.useFips == true
                    ) {
                        if (
                            partitionResult?.supportsFIPS == true
                        ) {
                            return Endpoint(
                                Url.parse("https://route53-fips.${params.region}.${partitionResult?.dnsSuffix}"),
                            )
                        }
                        throw EndpointProviderException("FIPS is enabled but this partition does not support FIPS")
                    }
                    if (
                        params.useDualStack == true
                    ) {
                        if (
                            true == partitionResult?.supportsDualStack
                        ) {
                            return Endpoint(
                                Url.parse("https://route53.${params.region}.${partitionResult?.dualStackDnsSuffix}"),
                            )
                        }
                        throw EndpointProviderException("DualStack is enabled but this partition does not support DualStack")
                    }
                    return Endpoint(
                        Url.parse("https://route53.${params.region}.${partitionResult?.dnsSuffix}"),
                    )
                }
            }
        }
        throw EndpointProviderException("Invalid Configuration: Missing Region")

        throw EndpointProviderException("endpoint rules were exhausted without a match")
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy