@@ -75,7 +75,7 @@ open class Functions: Service {
7575 /// @param String templateRepository
7676 /// @param String templateOwner
7777 /// @param String templateRootDirectory
78- /// @param String templateBranch
78+ /// @param String templateVersion
7979 /// @throws Exception
8080 /// @return array
8181 ///
@@ -100,7 +100,7 @@ open class Functions: Service {
100100 templateRepository: String ? = nil ,
101101 templateOwner: String ? = nil ,
102102 templateRootDirectory: String ? = nil ,
103- templateBranch : String ? = nil
103+ templateVersion : String ? = nil
104104 ) async throws -> AppwriteModels . Function {
105105 let apiPath : String = " /functions "
106106
@@ -125,7 +125,7 @@ open class Functions: Service {
125125 " templateRepository " : templateRepository,
126126 " templateOwner " : templateOwner,
127127 " templateRootDirectory " : templateRootDirectory,
128- " templateBranch " : templateBranch
128+ " templateVersion " : templateVersion
129129 ]
130130
131131 let apiHeaders : [ String : String ] = [
@@ -176,6 +176,88 @@ open class Functions: Service {
176176 )
177177 }
178178
179+ ///
180+ /// List function templates
181+ ///
182+ /// List available function templates. You can use template details in
183+ /// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
184+ /// method.
185+ ///
186+ /// @param [String] runtimes
187+ /// @param [String] useCases
188+ /// @param Int limit
189+ /// @param Int offset
190+ /// @throws Exception
191+ /// @return array
192+ ///
193+ open func listTemplates(
194+ runtimes: [ String ] ? = nil ,
195+ useCases: [ String ] ? = nil ,
196+ limit: Int ? = nil ,
197+ offset: Int ? = nil
198+ ) async throws -> AppwriteModels . TemplateFunctionList {
199+ let apiPath : String = " /functions/templates "
200+
201+ let apiParams : [ String : Any ? ] = [
202+ " runtimes " : runtimes,
203+ " useCases " : useCases,
204+ " limit " : limit,
205+ " offset " : offset
206+ ]
207+
208+ let apiHeaders : [ String : String ] = [
209+ " content-type " : " application/json "
210+ ]
211+
212+ let converter : ( Any ) -> AppwriteModels . TemplateFunctionList = { response in
213+ return AppwriteModels . TemplateFunctionList. from ( map: response as! [ String : Any ] )
214+ }
215+
216+ return try await client. call (
217+ method: " GET " ,
218+ path: apiPath,
219+ headers: apiHeaders,
220+ params: apiParams,
221+ converter: converter
222+ )
223+ }
224+
225+ ///
226+ /// Get function template
227+ ///
228+ /// Get a function template using ID. You can use template details in
229+ /// [createFunction](/docs/references/cloud/server-nodejs/functions#create)
230+ /// method.
231+ ///
232+ /// @param String templateId
233+ /// @throws Exception
234+ /// @return array
235+ ///
236+ open func getTemplate(
237+ templateId: String
238+ ) async throws -> AppwriteModels . TemplateFunction {
239+ let apiPath : String = " /functions/templates/{templateId} "
240+ . replacingOccurrences ( of: " {templateId} " , with: templateId)
241+
242+ let apiParams : [ String : Any ] = [ : ]
243+
244+ let apiHeaders : [ String : String ] = [
245+ " content-type " : " application/json "
246+ ]
247+
248+ let converter : ( Any ) -> AppwriteModels . TemplateFunction = { response in
249+ return AppwriteModels . TemplateFunction. from ( map: response as! [ String : Any ] )
250+ }
251+
252+ return try await client. call (
253+ method: " GET " ,
254+ path: apiPath,
255+ headers: apiHeaders,
256+ params: apiParams,
257+ converter: converter
258+ )
259+ }
260+
179261 ///
180262 /// Get function
181263 ///
@@ -462,7 +544,7 @@ open class Functions: Service {
462544 }
463545
464546 ///
465- /// Update function deployment
547+ /// Update deployment
466548 ///
467549 /// Update the function code deployment ID using the unique function ID. Use
468550 /// this endpoint to switch the code deployment that should be executed by the
@@ -600,7 +682,7 @@ open class Functions: Service {
600682 }
601683
602684 ///
603- /// Download Deployment
685+ /// Download deployment
604686 ///
605687 /// Get a Deployment's contents by its unique ID. This endpoint supports range
606688 /// requests for partial or streaming file download.
@@ -610,7 +692,7 @@ open class Functions: Service {
610692 /// @throws Exception
611693 /// @return array
612694 ///
613- open func downloadDeployment (
695+ open func getDeploymentDownload (
614696 functionId: String ,
615697 deploymentId: String
616698 ) async throws -> ByteBuffer {
@@ -698,12 +780,13 @@ open class Functions: Service {
698780 path: String ? = nil ,
699781 method: AppwriteEnums . ExecutionMethod ? = nil ,
700782 headers: Any ? = nil ,
701- scheduledAt: String ? = nil
783+ scheduledAt: String ? = nil ,
784+ onProgress: ( ( UploadProgress ) -> Void ) ? = nil
702785 ) async throws -> AppwriteModels . Execution {
703786 let apiPath : String = " /functions/{functionId}/executions "
704787 . replacingOccurrences ( of: " {functionId} " , with: functionId)
705788
706- let apiParams : [ String : Any ? ] = [
789+ var apiParams : [ String : Any ? ] = [
707790 " body " : body,
708791 " async " : async ,
709792 " path " : path,
@@ -712,20 +795,23 @@ open class Functions: Service {
712795 " scheduledAt " : scheduledAt
713796 ]
714797
715- let apiHeaders : [ String : String ] = [
716- " content-type " : " application/json "
798+ var apiHeaders : [ String : String ] = [
799+ " content-type " : " multipart/form-data "
717800 ]
718801
719802 let converter : ( Any ) -> AppwriteModels . Execution = { response in
720803 return AppwriteModels . Execution. from ( map: response as! [ String : Any ] )
721804 }
722805
723- return try await client . call (
724- method : " POST " ,
806+ let idParamName : String ? = nil
807+ return try await client . chunkedUpload (
725808 path: apiPath,
726- headers: apiHeaders,
727- params: apiParams,
728- converter: converter
809+ headers: & apiHeaders,
810+ params: & apiParams,
811+ paramName: paramName,
812+ idParamName: idParamName,
813+ converter: converter,
814+ onProgress: onProgress
729815 )
730816 }
731817
0 commit comments