Skip to content

Commit

Permalink
adjust code for model when ruleset is missing
Browse files Browse the repository at this point in the history
this will never happen in final models
  • Loading branch information
Ganesh Jangir committed Oct 7, 2022
1 parent a371261 commit d9c4cce
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,25 @@ class EndpointResolverGenerator() {
}

private fun renderResolver(writer: SwiftWriter, endpointRules: EndpointRuleset?) {
endpointRules?.let { endpointRules ->
writer.openBlock("public struct \$L: \$L {", "}", AWSServiceTypes.DefaultEndpointResolver, AWSServiceTypes.EndpointResolver) {
writer.write("")
writer.openBlock("public struct \$L: \$L {", "}", AWSServiceTypes.DefaultEndpointResolver, AWSServiceTypes.EndpointResolver) {
writer.write("")
endpointRules?.let {
writer.write("private let engine: \$L", AWSClientRuntimeTypes.Core.AWSEndpointsRuleEngine)
writer.write("private let ruleSetString = \$S", Node.printJson(endpointRules.toNode()))
writer.write("")
writer.openBlock("public init() throws {", "}") {
}
writer.write("")
writer.openBlock("public init() throws {", "}") {
endpointRules?.let {
writer.write("engine = try \$L(ruleSetString: ruleSetString)", AWSClientRuntimeTypes.Core.AWSEndpointsRuleEngine)
}
writer.write("")
writer.openBlock(
"public func resolve(params: EndpointParams) throws -> \$L {", "}", ClientRuntimeTypes.Core.Endpoint
) {
}
writer.write("")
writer.openBlock(
"public func resolve(params: EndpointParams) throws -> \$L {", "}", ClientRuntimeTypes.Core.Endpoint
) {
endpointRules?.let {
writer.write("let context = try \$L()", AWSClientRuntimeTypes.Core.AWSEndpointsRequestContext)
endpointRules.parameters?.toList()?.sortedBy { it.name.toString() }?.let { sortedParameters ->
endpointRules?.parameters?.toList()?.sortedBy { it.name.toString() }?.let { sortedParameters ->
sortedParameters.forEach { param ->
val memberName = param.name.toString().toCamelCase()
val paramName = param.name.toString()
Expand All @@ -105,6 +109,8 @@ class EndpointResolverGenerator() {
writer.write("let headers = try crtResolvedEndpoint.getHeaders() ?? [:]")
writer.write("let properties = try crtResolvedEndpoint.getProperties() ?? [:]")
writer.write("return try Endpoint(urlString: url, headers: Headers(headers), properties: properties)")
} ?: run {
writer.write("fatalError(\"EndpointResolver not implemented\")")
}
}
}
Expand Down

0 comments on commit d9c4cce

Please sign in to comment.