Skip to content
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

chore: Update codegen after event streams & event streams auth modularization #1536

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ addDependencies(
)

// Uncomment this line to exclude runtime unit tests
excludeRuntimeUnitTests()
// excludeRuntimeUnitTests()

let serviceTargets: [String] = [
"AWSACM",
Expand Down Expand Up @@ -719,7 +719,7 @@ let servicesWithIntegrationTests: [String] = [
// addIntegrationTests()

// Uncomment this line to enable protocol tests
addProtocolTests()
// addProtocolTests()

addResolvedTargets()

57 changes: 34 additions & 23 deletions Sources/Services/AWSACM/ACMClient.swift

Large diffs are not rendered by default.

14 changes: 8 additions & 6 deletions Sources/Services/AWSACM/AuthSchemeResolver.swift
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
// Code generated by smithy-swift-codegen. DO NOT EDIT!

import ClientRuntime
import Smithy
import SmithyHTTPAuthAPI

public struct ACMAuthSchemeResolverParameters: ClientRuntime.AuthSchemeResolverParameters {
public struct ACMAuthSchemeResolverParameters: SmithyHTTPAuthAPI.AuthSchemeResolverParameters {
public let operation: String
// Region is used for SigV4 auth scheme
public let region: String?
}

public protocol ACMAuthSchemeResolver: ClientRuntime.AuthSchemeResolver {
public protocol ACMAuthSchemeResolver: SmithyHTTPAuthAPI.AuthSchemeResolver {
// Intentionally empty.
// This is the parent protocol that all auth scheme resolver implementations of
// the service ACM must conform to.
}

public struct DefaultACMAuthSchemeResolver: ACMAuthSchemeResolver {
public func resolveAuthScheme(params: ClientRuntime.AuthSchemeResolverParameters) throws -> [AuthOption] {
public func resolveAuthScheme(params: SmithyHTTPAuthAPI.AuthSchemeResolverParameters) throws -> [AuthOption] {
var validAuthOptions = [AuthOption]()
guard let serviceParams = params as? ACMAuthSchemeResolverParameters else {
throw ClientError.authError("Service specific auth scheme parameters type must be passed to auth scheme resolver.")
}
switch serviceParams.operation {
default:
var sigV4Option = AuthOption(schemeID: "aws.auth#sigv4")
sigV4Option.signingProperties.set(key: AttributeKeys.signingName, value: "acm")
sigV4Option.signingProperties.set(key: SigningPropertyKeys.signingName, value: "acm")
guard let region = serviceParams.region else {
throw ClientError.authError("Missing region in auth scheme parameters for SigV4 auth scheme.")
}
sigV4Option.signingProperties.set(key: AttributeKeys.signingRegion, value: region)
sigV4Option.signingProperties.set(key: SigningPropertyKeys.signingRegion, value: region)
validAuthOptions.append(sigV4Option)
}
return validAuthOptions
}

public func constructParameters(context: HttpContext) throws -> ClientRuntime.AuthSchemeResolverParameters {
public func constructParameters(context: Smithy.Context) throws -> SmithyHTTPAuthAPI.AuthSchemeResolverParameters {
guard let opName = context.getOperation() else {
throw ClientError.dataNotFound("Operation name not configured in middleware context for auth scheme resolver params construction.")
}
Expand Down
42 changes: 23 additions & 19 deletions Sources/Services/AWSACM/EndpointResolver.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// Code generated by smithy-swift-codegen. DO NOT EDIT!

import AWSClientRuntime
import AWSSDKHTTPAuth
import ClientRuntime
import Smithy
import SmithyHTTPAPI
import SmithyHTTPAuthAPI
import protocol ClientRuntime.EndpointsAuthSchemeResolver
import struct ClientRuntime.DefaultEndpointsAuthSchemeResolver

public struct EndpointParams {
/// Override the endpoint used to send this request
Expand All @@ -28,7 +34,7 @@ public struct EndpointParams {
}

public protocol EndpointResolver {
func resolve(params: EndpointParams) throws -> ClientRuntime.Endpoint
func resolve(params: EndpointParams) throws -> SmithyHTTPAPI.Endpoint
}

public struct DefaultEndpointResolver: EndpointResolver {
Expand All @@ -40,7 +46,7 @@ public struct DefaultEndpointResolver: EndpointResolver {
engine = try ClientRuntime.EndpointsRuleEngine(partitions: AWSClientRuntime.awsPartitionJSON, ruleSet: ruleSet)
}

public func resolve(params: EndpointParams) throws -> ClientRuntime.Endpoint {
public func resolve(params: EndpointParams) throws -> SmithyHTTPAPI.Endpoint {
let context = try ClientRuntime.EndpointsRequestContext()
try context.add(name: "Endpoint", value: params.endpoint)
try context.add(name: "Region", value: params.region)
Expand Down Expand Up @@ -82,29 +88,27 @@ public struct EndpointResolverMiddleware<OperationStackOutput>: ClientRuntime.Mi
self.authSchemeResolver = authSchemeResolver
}

public func handle<H>(context: Context,
input: ClientRuntime.SdkHttpRequestBuilder,
public func handle<H>(context: Smithy.Context,
input: SmithyHTTPAPI.SdkHttpRequestBuilder,
next: H) async throws -> ClientRuntime.OperationOutput<OperationStackOutput>
where H: Handler,
Self.MInput == H.Input,
Self.MOutput == H.Output,
Self.Context == H.Context
Self.MOutput == H.Output
{
let selectedAuthScheme = context.getSelectedAuthScheme()
let selectedAuthScheme = context.selectedAuthScheme
let request = input.build()
let updatedRequest = try await apply(request: request, selectedAuthScheme: selectedAuthScheme, attributes: context)
return try await next.handle(context: context, input: updatedRequest.toBuilder())
}

public typealias MInput = ClientRuntime.SdkHttpRequestBuilder
public typealias MInput = SmithyHTTPAPI.SdkHttpRequestBuilder
public typealias MOutput = ClientRuntime.OperationOutput<OperationStackOutput>
public typealias Context = ClientRuntime.HttpContext
}
extension EndpointResolverMiddleware: ApplyEndpoint {
public func apply(
request: SdkHttpRequest,
selectedAuthScheme: SelectedAuthScheme?,
attributes: HttpContext) async throws -> SdkHttpRequest
attributes: Smithy.Context) async throws -> SdkHttpRequest
{
let builder = request.toBuilder()

Expand Down Expand Up @@ -132,34 +136,34 @@ extension EndpointResolverMiddleware: ApplyEndpoint {
let awsEndpoint = AWSEndpoint(endpoint: endpoint, signingName: signingName, signingRegion: signingRegion)

var host = ""
if let hostOverride = attributes.getHost() {
if let hostOverride = attributes.host {
host = hostOverride
} else {
host = "\(attributes.getHostPrefix() ?? "")\(awsEndpoint.endpoint.host)"
host = "\(attributes.hostPrefix ?? "")\(awsEndpoint.endpoint.host)"
}

if let protocolType = awsEndpoint.endpoint.protocolType {
builder.withProtocol(protocolType)
}

if let signingRegion = signingRegion {
attributes.set(key: AttributeKeys.signingRegion, value: signingRegion)
attributes.set(key: AttributeKeys.selectedAuthScheme, value: selectedAuthScheme?.getCopyWithUpdatedSigningProperty(key: AttributeKeys.signingRegion, value: signingRegion))
attributes.signingRegion = signingRegion
attributes.selectedAuthScheme = selectedAuthScheme?.getCopyWithUpdatedSigningProperty(key: SigningPropertyKeys.signingRegion, value: signingRegion)
}

if let signingName = signingName {
attributes.set(key: AttributeKeys.signingName, value: signingName)
attributes.set(key: AttributeKeys.selectedAuthScheme, value: selectedAuthScheme?.getCopyWithUpdatedSigningProperty(key: AttributeKeys.signingName, value: signingName))
attributes.signingName = signingName
attributes.selectedAuthScheme = selectedAuthScheme?.getCopyWithUpdatedSigningProperty(key: SigningPropertyKeys.signingName, value: signingName)
}

if let signingAlgorithm = signingAlgorithm {
attributes.set(key: AttributeKeys.signingAlgorithm, value: AWSSigningAlgorithm(rawValue: signingAlgorithm))
attributes.signingAlgorithm = SigningAlgorithm(rawValue: signingAlgorithm)
}

return builder.withMethod(attributes.getMethod())
return builder.withMethod(attributes.method)
.withHost(host)
.withPort(awsEndpoint.endpoint.port)
.withPath(awsEndpoint.endpoint.path.appendingPathComponent(attributes.getPath()))
.withPath(awsEndpoint.endpoint.path.appendingPathComponent(attributes.path))
.withHeaders(endpoint.headers)
.withHeader(name: "Host", value: host)
.build()
Expand Down
2 changes: 2 additions & 0 deletions Sources/Services/AWSACM/Paginators.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Code generated by smithy-swift-codegen. DO NOT EDIT!

import ClientRuntime
import protocol ClientRuntime.PaginateToken
import struct ClientRuntime.PaginatorSequence

extension ACMClient {
/// Paginate over `[ListCertificatesOutput]` results.
Expand Down
12 changes: 8 additions & 4 deletions Sources/Services/AWSACM/Plugins.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// Code generated by smithy-swift-codegen. DO NOT EDIT!

@_spi(FileBasedConfig) import AWSClientRuntime
import AWSSDKHTTPAuth
import AWSSDKIdentity
import ClientRuntime
import SmithyHTTPAuthAPI
import SmithyIdentityAPI

public class ACMClientEndpointPlugin: Plugin {
private var endpointResolver: EndpointResolver
Expand Down Expand Up @@ -31,10 +35,10 @@ public class DefaultAWSAuthSchemePlugin: Plugin {
}

public class ACMClientAuthSchemePlugin: Plugin {
private var authSchemes: [ClientRuntime.AuthScheme]?
private var authSchemeResolver: ClientRuntime.AuthSchemeResolver?
private var awsCredentialIdentityResolver: (any AWSClientRuntime.AWSCredentialIdentityResolver)?
public init(authSchemes: [ClientRuntime.AuthScheme]? = nil, authSchemeResolver: ACMAuthSchemeResolver? = nil, awsCredentialIdentityResolver: (any AWSClientRuntime.AWSCredentialIdentityResolver)? = nil) {
private var authSchemes: [SmithyHTTPAuthAPI.AuthScheme]?
private var authSchemeResolver: SmithyHTTPAuthAPI.AuthSchemeResolver?
private var awsCredentialIdentityResolver: (any SmithyIdentityAPI.AWSCredentialIdentityResolver)?
public init(authSchemes: [SmithyHTTPAuthAPI.AuthScheme]? = nil, authSchemeResolver: ACMAuthSchemeResolver? = nil, awsCredentialIdentityResolver: (any SmithyIdentityAPI.AWSCredentialIdentityResolver)? = nil) {
self.authSchemeResolver = authSchemeResolver
self.authSchemes = authSchemes
self.awsCredentialIdentityResolver = awsCredentialIdentityResolver
Expand Down
Loading
Loading