@@ -19,12 +19,21 @@ private func buildActionAttributeList(for action: APIModel.Action, discardableRe
1919 }
2020}
2121
22+ private func buildExecuteExpr( for action: String ) -> ExprSyntax {
23+ ExprSyntax ( " self.client.execute(action: \( literal: action) , region: region, serviceConfig: self.config \( raw: skipAuthorizationParameter ( for: action) ) , input: input, logger: logger, on: eventLoop) " )
24+ }
25+
26+ private func buildInputExpr( for type: String , members: [ APIObject . Member ] ) -> FunctionCallExprSyntax {
27+ let parameters = members. map ( { " \( $0. identifier) : \( $0. escapedIdentifier) " } ) . joined ( separator: " , " )
28+ return FunctionCallExprSyntax ( " \( raw: type) ( \( raw: parameters) ) " )
29+ }
30+
2231func buildActionDecl( for action: String , metadata: APIModel . Action , discardableResult: Bool ) -> FunctionDeclSyntax {
2332 FunctionDeclSyntax ( """
2433 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
2534 \( buildActionAttributeList ( for: metadata, discardableResult: discardableResult) )
2635 public func \( raw: action. lowerFirst ( ) ) (_ input: \( raw: metadata. input) , region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> \( raw: " EventLoopFuture< \( metadata. output) > " ) {
27- self.client.execute(action: \( literal : action ) , region: region, serviceConfig: self.config \( raw : skipAuthorizationParameter ( for: action) ) , input: input, logger: logger, on: eventLoop )
36+ \( buildExecuteExpr ( for: action) )
2837 }
2938 """ )
3039}
@@ -34,7 +43,7 @@ func buildAsyncActionDecl(for action: String, metadata: APIModel.Action, discard
3443 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
3544 \( buildActionAttributeList ( for: metadata, discardableResult: discardableResult) )
3645 public func \( raw: action. lowerFirst ( ) ) (_ input: \( raw: metadata. input) , region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> \( raw: metadata. output) {
37- try await self.client.execute(action: \( literal : action ) , region: region, serviceConfig: self.config \( raw : skipAuthorizationParameter ( for: action) ) , input: input, logger: logger, on: eventLoop ).get()
46+ try await \( buildExecuteExpr ( for: action) ) .get()
3847 }
3948 """ )
4049}
@@ -44,7 +53,8 @@ func buildUnpackedActionDecl(for action: String, metadata: APIModel.Action, inpu
4453 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
4554 \( buildActionAttributeList ( for: metadata, discardableResult: discardableResult) )
4655 public func \( raw: action. lowerFirst ( ) ) ( \( raw: initializerParameterList ( for: inputMembers, packed: true ) ) region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) -> \( raw: " EventLoopFuture< \( metadata. output) > " ) {
47- self. \( raw: action. lowerFirst ( ) ) ( \( raw: metadata. input) ( \( raw: inputMembers. map ( { " \( $0. identifier) : \( $0. escapedIdentifier) " } ) . joined ( separator: " , " ) ) ), region: region, logger: logger, on: eventLoop)
56+ let input = \( buildInputExpr ( for: metadata. input, members: inputMembers) )
57+ return \( buildExecuteExpr ( for: action) )
4858 }
4959 """ )
5060}
@@ -54,7 +64,8 @@ func buildUnpackedAsyncActionDecl(for action: String, metadata: APIModel.Action,
5464 \( raw: buildDocumentation ( summary: metadata. name, discussion: metadata. document) )
5565 \( buildActionAttributeList ( for: metadata, discardableResult: discardableResult) )
5666 public func \( raw: action. lowerFirst ( ) ) ( \( raw: initializerParameterList ( for: inputMembers, packed: true ) ) region: TCRegion? = nil, logger: Logger = TCClient.loggingDisabled, on eventLoop: EventLoop? = nil) async throws -> \( raw: metadata. output) {
57- try await self. \( raw: action. lowerFirst ( ) ) ( \( raw: metadata. input) ( \( raw: inputMembers. map ( { " \( $0. identifier) : \( $0. escapedIdentifier) " } ) . joined ( separator: " , " ) ) ), region: region, logger: logger, on: eventLoop)
67+ let input = \( buildInputExpr ( for: metadata. input, members: inputMembers) )
68+ return try await \( buildExecuteExpr ( for: action) ) .get()
5869 }
5970 """ )
6071}
0 commit comments