commonMain.aws.sdk.kotlin.services.dynamodbstreams.endpoints.DefaultDynamoDbStreamsEndpointProvider.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dynamodbstreams-jvm Show documentation
Show all versions of dynamodbstreams-jvm Show documentation
The AWS SDK for Kotlin client for DynamoDB Streams
The newest version!
// Code generated by smithy-kotlin-codegen. DO NOT EDIT!
package aws.sdk.kotlin.services.dynamodbstreams.endpoints
import aws.sdk.kotlin.services.dynamodbstreams.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 DefaultDynamoDbStreamsEndpointProvider: DynamoDbStreamsEndpointProvider {
public override suspend fun resolveEndpoint(params: DynamoDbStreamsEndpointParameters): 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 (
params.useFips == true &&
params.useDualStack == true
) {
if (
true == partitionResult?.supportsFIPS &&
true == partitionResult?.supportsDualStack
) {
return Endpoint(
Url.parse("https://streams.dynamodb-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
) {
if (
partitionResult?.name == "aws-us-gov"
) {
return Endpoint(
Url.parse("https://streams.dynamodb.${params.region}.amazonaws.com"),
)
}
return Endpoint(
Url.parse("https://streams.dynamodb-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://streams.dynamodb.${params.region}.${partitionResult?.dualStackDnsSuffix}"),
)
}
throw EndpointProviderException("DualStack is enabled but this partition does not support DualStack")
}
if (
params.region == "local"
) {
return Endpoint(
Url.parse("http://localhost:8000"),
attributes = attributesOf {
SigningContextAttributeKey to listOf(
sigV4(
serviceName = "dynamodb",
disableDoubleUriEncode = false,
signingRegion = "us-east-1",
),
)
},
)
}
if (
"aws" == partitionResult?.name
) {
return Endpoint(
Url.parse("https://streams.dynamodb.${params.region}.amazonaws.com"),
)
}
if (
"aws-cn" == partitionResult?.name
) {
return Endpoint(
Url.parse("https://streams.dynamodb.${params.region}.amazonaws.com.cn"),
)
}
if (
"aws-us-gov" == partitionResult?.name
) {
return Endpoint(
Url.parse("https://streams.dynamodb.${params.region}.amazonaws.com"),
)
}
if (
"aws-iso" == partitionResult?.name
) {
return Endpoint(
Url.parse("https://streams.dynamodb.${params.region}.c2s.ic.gov"),
)
}
if (
"aws-iso-b" == partitionResult?.name
) {
return Endpoint(
Url.parse("https://streams.dynamodb.${params.region}.sc2s.sgov.gov"),
)
}
return Endpoint(
Url.parse("https://streams.dynamodb.${params.region}.${partitionResult?.dnsSuffix}"),
)
}
}
}
throw EndpointProviderException("Invalid Configuration: Missing Region")
throw EndpointProviderException("endpoint rules were exhausted without a match")
}
}