@@ -36,7 +36,7 @@ class Functions extends Service {
36
36
/// [permissions] (https://appwrite.io/docs/permissions) to allow different
37
37
/// project users or team with access to execute the function using the client
38
38
/// API.
39
- Future <models.Func > create ({required String functionId, required String name, required enums.Runtime runtime, List <String >? execute, List <String >? events, String ? schedule, int ? timeout, bool ? enabled, bool ? logging, String ? entrypoint, String ? commands, List <String >? scopes, String ? installationId, String ? providerRepositoryId, String ? providerBranch, bool ? providerSilentMode, String ? providerRootDirectory, String ? templateRepository, String ? templateOwner, String ? templateRootDirectory, String ? templateBranch }) async {
39
+ Future <models.Func > create ({required String functionId, required String name, required enums.Runtime runtime, List <String >? execute, List <String >? events, String ? schedule, int ? timeout, bool ? enabled, bool ? logging, String ? entrypoint, String ? commands, List <String >? scopes, String ? installationId, String ? providerRepositoryId, String ? providerBranch, bool ? providerSilentMode, String ? providerRootDirectory, String ? templateRepository, String ? templateOwner, String ? templateRootDirectory, String ? templateVersion }) async {
40
40
final String apiPath = '/functions' ;
41
41
42
42
final Map <String , dynamic > apiParams = {
@@ -61,7 +61,7 @@ class Functions extends Service {
61
61
'templateRepository' : templateRepository,
62
62
'templateOwner' : templateOwner,
63
63
'templateRootDirectory' : templateRootDirectory,
64
- 'templateBranch ' : templateBranch ,
64
+ 'templateVersion ' : templateVersion ,
65
65
66
66
};
67
67
@@ -98,6 +98,58 @@ class Functions extends Service {
98
98
99
99
}
100
100
101
+ /// List function templates
102
+ ///
103
+ /// List available function templates. You can use template details in
104
+ /// [createFunction] (/docs/references/cloud/server-nodejs/functions#create)
105
+ /// method.
106
+ Future <models.TemplateFunctionList > listTemplates ({List <String >? runtimes, List <String >? useCases, int ? limit, int ? offset}) async {
107
+ final String apiPath = '/functions/templates' ;
108
+
109
+ final Map <String , dynamic > apiParams = {
110
+ 'runtimes' : runtimes,
111
+ 'useCases' : useCases,
112
+ 'limit' : limit,
113
+ 'offset' : offset,
114
+
115
+
116
+ };
117
+
118
+ final Map <String , String > apiHeaders = {
119
+ 'content-type' : 'application/json' ,
120
+
121
+ };
122
+
123
+ final res = await client.call (HttpMethod .get , path: apiPath, params: apiParams, headers: apiHeaders);
124
+
125
+ return models.TemplateFunctionList .fromMap (res.data);
126
+
127
+ }
128
+
129
+ /// Get function template
130
+ ///
131
+ /// Get a function template using ID. You can use template details in
132
+ /// [createFunction] (/docs/references/cloud/server-nodejs/functions#create)
133
+ /// method.
134
+ Future <models.TemplateFunction > getTemplate ({required String templateId}) async {
135
+ final String apiPath = '/functions/templates/{templateId}' .replaceAll ('{templateId}' , templateId);
136
+
137
+ final Map <String , dynamic > apiParams = {
138
+
139
+
140
+ };
141
+
142
+ final Map <String , String > apiHeaders = {
143
+ 'content-type' : 'application/json' ,
144
+
145
+ };
146
+
147
+ final res = await client.call (HttpMethod .get , path: apiPath, params: apiParams, headers: apiHeaders);
148
+
149
+ return models.TemplateFunction .fromMap (res.data);
150
+
151
+ }
152
+
101
153
/// Get function
102
154
///
103
155
/// Get a function by its unique ID.
@@ -271,7 +323,7 @@ class Functions extends Service {
271
323
272
324
}
273
325
274
- /// Update function deployment
326
+ /// Update deployment
275
327
///
276
328
/// Update the function code deployment ID using the unique function ID. Use
277
329
/// this endpoint to switch the code deployment that should be executed by the
@@ -360,18 +412,18 @@ class Functions extends Service {
360
412
361
413
}
362
414
363
- /// Download Deployment
415
+ /// Download deployment
364
416
///
365
417
/// Get a Deployment's contents by its unique ID. This endpoint supports range
366
418
/// requests for partial or streaming file download.
367
- Future <Uint8List > downloadDeployment ({required String functionId, required String deploymentId}) async {
419
+ Future <Uint8List > getDeploymentDownload ({required String functionId, required String deploymentId}) async {
368
420
final String apiPath = '/functions/{functionId}/deployments/{deploymentId}/download' .replaceAll ('{functionId}' , functionId).replaceAll ('{deploymentId}' , deploymentId);
369
421
370
422
final Map <String , dynamic > params = {
371
423
372
424
373
425
'project' : client.config['project' ],
374
- 'key ' : client.config['key ' ],
426
+ 'session ' : client.config['session ' ],
375
427
};
376
428
377
429
final res = await client.call (HttpMethod .get , path: apiPath, params: params, responseType: ResponseType .bytes);
@@ -409,7 +461,7 @@ class Functions extends Service {
409
461
/// current execution status. You can ping the `Get Execution` endpoint to get
410
462
/// updates on the current execution status. Once this endpoint is called, your
411
463
/// function execution process will start asynchronously.
412
- Future <models.Execution > createExecution ({required String functionId, String ? body, bool ? xasync, String ? path, enums.ExecutionMethod ? method, Map ? headers, String ? scheduledAt}) async {
464
+ Future <models.Execution > createExecution ({required String functionId, String ? body, bool ? xasync, String ? path, enums.ExecutionMethod ? method, Map ? headers, String ? scheduledAt, Function ( UploadProgress ) ? onProgress }) async {
413
465
final String apiPath = '/functions/{functionId}/executions' .replaceAll ('{functionId}' , functionId);
414
466
415
467
final Map <String , dynamic > apiParams = {
@@ -424,11 +476,19 @@ class Functions extends Service {
424
476
};
425
477
426
478
final Map <String , String > apiHeaders = {
427
- 'content-type' : 'application/json ' ,
479
+ 'content-type' : 'multipart/form-data ' ,
428
480
429
481
};
430
482
431
- final res = await client.call (HttpMethod .post, path: apiPath, params: apiParams, headers: apiHeaders);
483
+ String idParamName = '' ;
484
+ final res = await client.chunkedUpload (
485
+ path: apiPath,
486
+ params: apiParams,
487
+ paramName: paramName,
488
+ idParamName: idParamName,
489
+ headers: apiHeaders,
490
+ onProgress: onProgress,
491
+ );
432
492
433
493
return models.Execution .fromMap (res.data);
434
494
0 commit comments