@@ -75,7 +75,7 @@ open class Functions: Service {
75
75
/// @param String templateRepository
76
76
/// @param String templateOwner
77
77
/// @param String templateRootDirectory
78
- /// @param String templateBranch
78
+ /// @param String templateVersion
79
79
/// @throws Exception
80
80
/// @return array
81
81
///
@@ -100,7 +100,7 @@ open class Functions: Service {
100
100
templateRepository: String ? = nil ,
101
101
templateOwner: String ? = nil ,
102
102
templateRootDirectory: String ? = nil ,
103
- templateBranch : String ? = nil
103
+ templateVersion : String ? = nil
104
104
) async throws -> AppwriteModels . Function {
105
105
let apiPath : String = " /functions "
106
106
@@ -125,7 +125,7 @@ open class Functions: Service {
125
125
" templateRepository " : templateRepository,
126
126
" templateOwner " : templateOwner,
127
127
" templateRootDirectory " : templateRootDirectory,
128
- " templateBranch " : templateBranch
128
+ " templateVersion " : templateVersion
129
129
]
130
130
131
131
let apiHeaders : [ String : String ] = [
@@ -176,6 +176,88 @@ open class Functions: Service {
176
176
)
177
177
}
178
178
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
+
179
261
///
180
262
/// Get function
181
263
///
@@ -462,7 +544,7 @@ open class Functions: Service {
462
544
}
463
545
464
546
///
465
- /// Update function deployment
547
+ /// Update deployment
466
548
///
467
549
/// Update the function code deployment ID using the unique function ID. Use
468
550
/// this endpoint to switch the code deployment that should be executed by the
@@ -600,7 +682,7 @@ open class Functions: Service {
600
682
}
601
683
602
684
///
603
- /// Download Deployment
685
+ /// Download deployment
604
686
///
605
687
/// Get a Deployment's contents by its unique ID. This endpoint supports range
606
688
/// requests for partial or streaming file download.
@@ -610,7 +692,7 @@ open class Functions: Service {
610
692
/// @throws Exception
611
693
/// @return array
612
694
///
613
- open func downloadDeployment (
695
+ open func getDeploymentDownload (
614
696
functionId: String ,
615
697
deploymentId: String
616
698
) async throws -> ByteBuffer {
@@ -698,12 +780,13 @@ open class Functions: Service {
698
780
path: String ? = nil ,
699
781
method: AppwriteEnums . ExecutionMethod ? = nil ,
700
782
headers: Any ? = nil ,
701
- scheduledAt: String ? = nil
783
+ scheduledAt: String ? = nil ,
784
+ onProgress: ( ( UploadProgress ) -> Void ) ? = nil
702
785
) async throws -> AppwriteModels . Execution {
703
786
let apiPath : String = " /functions/{functionId}/executions "
704
787
. replacingOccurrences ( of: " {functionId} " , with: functionId)
705
788
706
- let apiParams : [ String : Any ? ] = [
789
+ var apiParams : [ String : Any ? ] = [
707
790
" body " : body,
708
791
" async " : async ,
709
792
" path " : path,
@@ -712,20 +795,23 @@ open class Functions: Service {
712
795
" scheduledAt " : scheduledAt
713
796
]
714
797
715
- let apiHeaders : [ String : String ] = [
716
- " content-type " : " application/json "
798
+ var apiHeaders : [ String : String ] = [
799
+ " content-type " : " multipart/form-data "
717
800
]
718
801
719
802
let converter : ( Any ) -> AppwriteModels . Execution = { response in
720
803
return AppwriteModels . Execution. from ( map: response as! [ String : Any ] )
721
804
}
722
805
723
- return try await client . call (
724
- method : " POST " ,
806
+ let idParamName : String ? = nil
807
+ return try await client . chunkedUpload (
725
808
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
729
815
)
730
816
}
731
817
0 commit comments