Unverified Commit 4cfac14d authored by kastolars's avatar kastolars Committed by GitHub
Browse files

Getters added to ConfigImpl (#1761)

parent a11ea2a0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -93,3 +93,9 @@ message = "Paginators now stop on encountering a duplicate token by default rath
references = ["aws-sdk-rust#620", "smithy-rs#1748"]
meta = { "breaking" = false, "tada" = false, "bug" = true, "target" = "client"}
author = "jdisanti"

[[aws-sdk-rust]]
message = "The client Config now has getters for every value that it holds."
references = ["smithy-rs#1747"]
meta = { "breaking" = false, "tada" = false, "bug" = true }
author = "kastolars"
+33 −29
Original line number Diff line number Diff line
@@ -109,21 +109,25 @@ class EndpointConfigCustomization(
        "aws_types" to awsTypes(runtimeConfig).asType(),
    )

    override fun section(section: ServiceConfig): Writable =
        writable {
    override fun section(section: ServiceConfig): Writable = writable {
        when (section) {
            is ServiceConfig.ConfigStruct -> rustTemplate(
                "pub (crate) endpoint_resolver: std::sync::Arc<dyn #{SmithyResolver}<#{PlaceholderParams}>>,",
                *codegenScope,
            )

            is ServiceConfig.ConfigImpl -> emptySection
// TODO(https://github.com/awslabs/smithy-rs/issues/1780): Uncomment once endpoints 2.0 project is completed
//                rustTemplate(
//                """
//                /// Returns the endpoint resolver.
//                pub fn endpoint_resolver(&self) -> std::sync::Arc<dyn #{SmithyResolver}<#{PlaceholderParams}>> {
//                    self.endpoint_resolver.clone()
//                }
//                """,
//                *codegenScope,
//            )
            is ServiceConfig.BuilderStruct ->
                    rustTemplate(
                        "endpoint_resolver: Option<std::sync::Arc<dyn #{SmithyResolver}<#{PlaceholderParams}>>>,",
                        *codegenScope,
                    )

                rustTemplate("endpoint_resolver: Option<std::sync::Arc<dyn #{SmithyResolver}<#{PlaceholderParams}>>>,", *codegenScope)
            ServiceConfig.BuilderImpl ->
                rustTemplate(
                    """
+26 −24
Original line number Diff line number Diff line
@@ -64,21 +64,23 @@ class CredentialProviderConfig(runtimeConfig: RuntimeConfig) : ConfigCustomizati
        "DefaultProvider" to defaultProvider,
    )

    override fun section(section: ServiceConfig) =
        writable {
    override fun section(section: ServiceConfig) = writable {
        when (section) {
            is ServiceConfig.ConfigStruct -> rustTemplate(
                """pub(crate) credentials_provider: #{credentials}::SharedCredentialsProvider,""",
                *codegenScope,
            )

                is ServiceConfig.ConfigImpl -> emptySection
                is ServiceConfig.BuilderStruct ->
                    rustTemplate(
                        "credentials_provider: Option<#{credentials}::SharedCredentialsProvider>,",
            is ServiceConfig.ConfigImpl -> rustTemplate(
                """
                /// Returns the credentials provider.
                pub fn credentials_provider(&self) -> #{credentials}::SharedCredentialsProvider {
                    self.credentials_provider.clone()
                }
                """,
                *codegenScope,
            )

            is ServiceConfig.BuilderStruct ->
                rustTemplate("credentials_provider: Option<#{credentials}::SharedCredentialsProvider>,", *codegenScope)
            ServiceConfig.BuilderImpl -> {
                rustTemplate(
                    """
+23 −17
Original line number Diff line number Diff line
@@ -105,14 +105,20 @@ class RegionProviderConfig(codegenContext: CodegenContext) : ConfigCustomization
    private val region = region(codegenContext.runtimeConfig)
    private val moduleUseName = codegenContext.moduleUseName()
    private val codegenScope = arrayOf("Region" to region.member("Region"))
    override fun section(section: ServiceConfig) =
        writable {
    override fun section(section: ServiceConfig) = writable {
        when (section) {
            is ServiceConfig.ConfigStruct -> rustTemplate("pub(crate) region: Option<#{Region}>,", *codegenScope)
                is ServiceConfig.ConfigImpl -> emptySection
            is ServiceConfig.ConfigImpl -> rustTemplate(
                """
                /// Returns the AWS region, if it was provided.
                pub fn region(&self) -> Option<&#{Region}> {
                    self.region.as_ref()
                }
                """,
                *codegenScope,
            )
            is ServiceConfig.BuilderStruct ->
                rustTemplate("region: Option<#{Region}>,", *codegenScope)

            ServiceConfig.BuilderImpl ->
                rustTemplate(
                    """
+13 −1
Original line number Diff line number Diff line
@@ -20,7 +20,19 @@ class IdempotencyTokenProviderCustomization : NamedSectionGenerator<ServiceConfi
            is ServiceConfig.ConfigStruct -> writable {
                rust("pub (crate) make_token: #T::IdempotencyTokenProvider,", RuntimeType.IdempotencyToken)
            }
            ServiceConfig.ConfigImpl -> emptySection
            ServiceConfig.ConfigImpl -> writable {
                rust(
                    """
                    /// Returns a copy of the idempotency token provider.
                    /// If a random token provider was configured,
                    /// a newly-randomized token provider will be returned.
                    pub fn make_token(&self) -> #T::IdempotencyTokenProvider {
                        self.make_token.clone()
                    }
                    """,
                    RuntimeType.IdempotencyToken,
                )
            }
            ServiceConfig.BuilderStruct -> writable {
                rust("make_token: Option<#T::IdempotencyTokenProvider>,", RuntimeType.IdempotencyToken)
            }
Loading