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

commonMain.aws.sdk.kotlin.services.sso.SsoClient.kt Maven / Gradle / Ivy

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

package aws.sdk.kotlin.services.sso

import aws.sdk.kotlin.runtime.auth.credentials.DefaultChainCredentialsProvider
import aws.sdk.kotlin.runtime.auth.credentials.internal.borrow
import aws.sdk.kotlin.runtime.endpoint.AwsEndpointResolver
import aws.sdk.kotlin.runtime.region.resolveRegion
import aws.sdk.kotlin.services.sso.internal.DefaultEndpointResolver
import aws.sdk.kotlin.services.sso.model.*
import aws.sdk.kotlin.services.sso.model.GetRoleCredentialsRequest
import aws.sdk.kotlin.services.sso.model.GetRoleCredentialsResponse
import aws.sdk.kotlin.services.sso.model.ListAccountRolesRequest
import aws.sdk.kotlin.services.sso.model.ListAccountRolesResponse
import aws.sdk.kotlin.services.sso.model.ListAccountsRequest
import aws.sdk.kotlin.services.sso.model.ListAccountsResponse
import aws.sdk.kotlin.services.sso.model.LogoutRequest
import aws.sdk.kotlin.services.sso.model.LogoutResponse
import aws.smithy.kotlin.runtime.SdkClient
import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
import aws.smithy.kotlin.runtime.auth.awssigning.AwsSigner
import aws.smithy.kotlin.runtime.auth.awssigning.DefaultAwsSigner
import aws.smithy.kotlin.runtime.client.SdkLogMode
import aws.smithy.kotlin.runtime.config.SdkClientConfig
import aws.smithy.kotlin.runtime.http.config.HttpClientConfig
import aws.smithy.kotlin.runtime.http.endpoints.EndpointResolver
import aws.smithy.kotlin.runtime.http.engine.HttpClientEngine
import aws.smithy.kotlin.runtime.retries.RetryStrategy
import aws.smithy.kotlin.runtime.retries.StandardRetryStrategy

/**
 * AWS Single Sign-On Portal is a web service that makes it easy for you to assign user access to AWS SSO resources such as the user portal. Users can get AWS account applications and roles assigned to them and get federated into the application.
 *
 * For general information about AWS SSO, see [What is AWS Single Sign-On?](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html) in the *AWS SSO User Guide*.
 *
 * This API reference guide describes the AWS SSO Portal operations that you can call programatically and includes detailed information on data types and errors.
 *
 * AWS provides SDKs that consist of libraries and sample code for various programming languages and platforms, such as Java, Ruby, .Net, iOS, or Android. The SDKs provide a convenient way to create programmatic access to AWS SSO and other AWS services. For more information about the AWS SDKs, including how to download and install them, see [Tools for Amazon Web Services](http://aws.amazon.com/tools/).
 */
public interface SsoClient : SdkClient {

    override val serviceName: String
        get() = "SSO"
    /**
     * SsoClient's configuration
     */
    public val config: Config

    public companion object {
        public operator fun invoke(block: Config.Builder.() -> Unit): SsoClient {
            val config = Config.Builder().apply(block).build()
            return DefaultSsoClient(config)
        }

        public operator fun invoke(config: Config): SsoClient = DefaultSsoClient(config)

        /**
         * Construct a [SsoClient] by resolving the configuration from the current environment.
         */
        public suspend fun fromEnvironment(block: (Config.Builder.() -> Unit)? = null): SsoClient {
            val builder = Config.Builder()
            if (block != null) builder.apply(block)
            builder.region = builder.region ?: resolveRegion()
            return DefaultSsoClient(builder.build())
        }
    }

    public class Config private constructor(builder: Builder): HttpClientConfig, SdkClientConfig {
        public val credentialsProvider: CredentialsProvider = builder.credentialsProvider?.borrow() ?: DefaultChainCredentialsProvider()
        public val endpointResolver: AwsEndpointResolver = builder.endpointResolver ?: DefaultEndpointResolver()
        override val httpClientEngine: HttpClientEngine? = builder.httpClientEngine
        public val region: String = requireNotNull(builder.region) { "region is a required configuration property" }
        public val retryStrategy: RetryStrategy = StandardRetryStrategy()
        override val sdkLogMode: SdkLogMode = builder.sdkLogMode
        public val signer: AwsSigner = builder.signer ?: DefaultAwsSigner
        public companion object {
            public inline operator fun invoke(block: Builder.() -> kotlin.Unit): Config = Builder().apply(block).build()
        }

        public class Builder {
            /**
             * The AWS credentials provider to use for authenticating requests. If not provided a
             * [aws.sdk.kotlin.runtime.auth.credentials.DefaultChainCredentialsProvider] instance will be used.
             * NOTE: The caller is responsible for managing the lifetime of the provider when set. The SDK
             * client will not close it when the client is closed.
             */
            public var credentialsProvider: CredentialsProvider? = null
            /**
             * Determines the endpoint (hostname) to make requests to. When not provided a default
             * resolver is configured automatically. This is an advanced client option.
             */
            public var endpointResolver: AwsEndpointResolver? = null
            /**
             * Override the default HTTP client engine used to make SDK requests (e.g. configure proxy behavior, timeouts, concurrency, etc).
             * NOTE: The caller is responsible for managing the lifetime of the engine when set. The SDK
             * client will not close it when the client is closed.
             */
            public var httpClientEngine: HttpClientEngine? = null
            /**
             * AWS region to make requests to
             */
            public var region: String? = null
            /**
             * Configure events that will be logged. By default clients will not output
             * raw requests or responses. Use this setting to opt-in to additional debug logging.
             *
             * This can be used to configure logging of requests, responses, retries, etc of SDK clients.
             *
             * **NOTE**: Logging of raw requests or responses may leak sensitive information! It may also have
             * performance considerations when dumping the request/response body. This is primarily a tool for
             * debug purposes.
             */
            public var sdkLogMode: SdkLogMode = SdkLogMode.Default
            /**
             * The implementation of AWS signer to use for signing requests
             */
            public var signer: AwsSigner? = null

            @PublishedApi
            internal fun build(): Config = Config(this)
        }
    }

    /**
     * Returns the STS short-term credentials for a given role name that is assigned to the user.
     */
    public suspend fun getRoleCredentials(input: GetRoleCredentialsRequest): GetRoleCredentialsResponse

    /**
     * Lists all roles that are assigned to the user for a given AWS account.
     */
    public suspend fun listAccountRoles(input: ListAccountRolesRequest): ListAccountRolesResponse

    /**
     * Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the administrator of the account. For more information, see [Assign User Access](https://docs.aws.amazon.com/singlesignon/latest/userguide/useraccess.html#assignusers) in the *AWS SSO User Guide*. This operation returns a paginated response.
     */
    public suspend fun listAccounts(input: ListAccountsRequest): ListAccountsResponse

    /**
     * Removes the client- and server-side session that is associated with the user.
     */
    public suspend fun logout(input: LogoutRequest): LogoutResponse
}

/**
 * Returns the STS short-term credentials for a given role name that is assigned to the user.
 */
public suspend inline fun SsoClient.getRoleCredentials(crossinline block: GetRoleCredentialsRequest.Builder.() -> Unit): GetRoleCredentialsResponse = getRoleCredentials(GetRoleCredentialsRequest.Builder().apply(block).build())

/**
 * Lists all roles that are assigned to the user for a given AWS account.
 */
public suspend inline fun SsoClient.listAccountRoles(crossinline block: ListAccountRolesRequest.Builder.() -> Unit): ListAccountRolesResponse = listAccountRoles(ListAccountRolesRequest.Builder().apply(block).build())

/**
 * Lists all AWS accounts assigned to the user. These AWS accounts are assigned by the administrator of the account. For more information, see [Assign User Access](https://docs.aws.amazon.com/singlesignon/latest/userguide/useraccess.html#assignusers) in the *AWS SSO User Guide*. This operation returns a paginated response.
 */
public suspend inline fun SsoClient.listAccounts(crossinline block: ListAccountsRequest.Builder.() -> Unit): ListAccountsResponse = listAccounts(ListAccountsRequest.Builder().apply(block).build())

/**
 * Removes the client- and server-side session that is associated with the user.
 */
public suspend inline fun SsoClient.logout(crossinline block: LogoutRequest.Builder.() -> Unit): LogoutResponse = logout(LogoutRequest.Builder().apply(block).build())




© 2015 - 2025 Weber Informatics LLC | Privacy Policy