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

commonMain.aws.sdk.kotlin.crt.auth.credentials.EcsCredentialsProvider.kt Maven / Gradle / Ivy

There is a newer version: 0.8.9
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

package aws.sdk.kotlin.crt.auth.credentials

import aws.sdk.kotlin.crt.io.ClientBootstrap
import aws.sdk.kotlin.crt.io.TlsContext

/**
 * A credentials provider that sources credentials from an ECS environment.
 */
public expect class EcsCredentialsProvider
internal constructor(
    builder: EcsCredentialsProviderBuilder,
) : CredentialsProvider {
    public companion object { }

    override fun close()
    override suspend fun getCredentials(): Credentials
    override suspend fun waitForShutdown()
}

public class EcsCredentialsProviderBuilder {
    /**
     * Connection bootstrap to use for any network connections made while sourcing credentials.
     */
    public var clientBootstrap: ClientBootstrap? = null

    /**
     * The tls context to use for any secure network connections made while sourcing credentials.
     */
    public var tlsContext: TlsContext? = null

    /**
     * The host component of the URL to query credentials from.
     * Example: www.test.com
     */
    public var host: String? = null

    /**
     * The path and query components of the URI, concatenated, to query credentials from.
     * Example: "/path/to/resource?test1=value1&test%20space=value%20space&test2=value2&test2=value3"
     */
    public var pathAndQuery: String? = null

    /**
     * Provide token to pass to ECS credential service.
     */
    public var authToken: String? = null

    public fun build(): EcsCredentialsProvider = EcsCredentialsProvider(this)
}

/**
 * Construct a new ECS credentials provider using a builder.
 */
public fun EcsCredentialsProvider.Companion.build(block: EcsCredentialsProviderBuilder.() -> Unit): EcsCredentialsProvider = EcsCredentialsProviderBuilder().apply(block).build()




© 2015 - 2024 Weber Informatics LLC | Privacy Policy