- 
                Notifications
    You must be signed in to change notification settings 
- Fork 35
chore: Refactor internal clients #952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
        
          
                ...hyIdentity/BearerTokenIdentityResolvers/ClientConfigDefaultBearerTokenIdentityResolver.swift
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | val mergeModels: Boolean, | ||
| val copyrightNotice: String, | ||
| val visibility: String, | ||
| val internalClient: Boolean, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this internalClient field to SwiftSettings to help make codegen more clear, i.e. can query this setting directly rather than rely on some string value of visibility.
| */ | ||
| enum class AccessModifier { | ||
| Public, | ||
| PublicPrivateSet, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of Swift 5.9 package is a Swift access modifier or "visibility" level.
Adding it to this enum along with the existing levels.
| "operator", | ||
| "optional", | ||
| "override", | ||
| "package", | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding package as a Swift reserved word so that it gets escaped with backticks in generated code.
There actually do seem to be services that already use package as an identifier without escaping it, but to date it seems not to cause any problems.
| val BearerTokenIdentity = runtimeSymbol("BearerTokenIdentity", SwiftDeclaration.STRUCT) | ||
| val StaticBearerTokenIdentityResolver = runtimeSymbol("StaticBearerTokenIdentityResolver", SwiftDeclaration.STRUCT) | ||
| val ClientConfigDefaultBearerTokenIdentityResolver = | ||
| runtimeSymbol("ClientConfigDefaultBearerTokenIdentityResolver", SwiftDeclaration.STRUCT) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symbol for the ClientConfigDefaultBearerTokenIdentityResolver defined at top.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A suggestion on ClientConfigDefaultBearerTokenIdentityResolver
        
          
                ...hyIdentity/BearerTokenIdentityResolvers/ClientConfigDefaultBearerTokenIdentityResolver.swift
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | public struct StaticAWSCredentialIdentityResolver: AWSCredentialIdentityResolver { | ||
| private let credentials: AWSCredentialIdentity | ||
| fileprivate let credentials: AWSCredentialIdentity | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @_spi initializer below creates a AWS credential identity resolver with empty credentials.  This is used in internal clients, where the default AWS credential identity resolver is never used.
| return credentials | ||
| } | ||
| } | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ClientConfigDefaultIdentityResolver extension below marks this resolver as a client config default if the credentials are empty, something that the new initializer above does, but a real customer should never do.
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|  | ||
| @_spi(ClientConfigDefaultIdentityResolver) import protocol SmithyIdentityAPI.ClientConfigDefaultIdentityResolver | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty much the same changes in this StaticBearerTokenIdentityResolver as in the StaticAWSCredentialIdentityResolver just above.
| /// A protocol on identity resolver used to signify that this resolver is a default resolver created because the client config was not passed a custom resolver at creation. | ||
| /// | ||
| /// Resolvers that do not implement this protocol should be presumed to not be a client config default. | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The protocol below is used to determine if a credential resolver came from client config defaults.  It's protected with @_spi so it isn't visible to customers.
| private fun runtimeSymbol( | ||
| name: String, | ||
| declaration: SwiftDeclaration?, | ||
| additionalImports: List<Symbol> = emptyList(), | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just fixed a typo in this file
Description of changes
Supports the changes to internal clients in awslabs/aws-sdk-swift#1995 .
internalClientBoolean field to SwiftSettings, to help make codegen code more clear.packagekeyword introduced to Swift in Swift 5.9.Scope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.