@@ -6,6 +6,69 @@ class Functions extends Service {
66 /// Initializes a [Functions] service
77 Functions (super .client);
88
9+ /// List function templates
10+ ///
11+ /// List available function templates. You can use template details in
12+ /// [createFunction] (/docs/references/cloud/server-nodejs/functions#create)
13+ /// method.
14+ Future <models.TemplateFunctionList > listTemplates ({List <String >? runtimes, List <String >? useCases, int ? limit, int ? offset}) async {
15+ const String apiPath = '/functions/templates' ;
16+
17+ final Map <String , dynamic > apiParams = {
18+ 'runtimes' : runtimes,
19+ 'useCases' : useCases,
20+ 'limit' : limit,
21+ 'offset' : offset,
22+ };
23+
24+ final Map <String , String > apiHeaders = {
25+ 'content-type' : 'application/json' ,
26+ };
27+
28+ final res = await client.call (HttpMethod .get , path: apiPath, params: apiParams, headers: apiHeaders);
29+
30+ return models.TemplateFunctionList .fromMap (res.data);
31+
32+ }
33+
34+ /// Get function template
35+ ///
36+ /// Get a function template using ID. You can use template details in
37+ /// [createFunction] (/docs/references/cloud/server-nodejs/functions#create)
38+ /// method.
39+ Future <models.TemplateFunction > getTemplate ({required String templateId}) async {
40+ final String apiPath = '/functions/templates/{templateId}' .replaceAll ('{templateId}' , templateId);
41+
42+ final Map <String , dynamic > apiParams = {
43+ };
44+
45+ final Map <String , String > apiHeaders = {
46+ 'content-type' : 'application/json' ,
47+ };
48+
49+ final res = await client.call (HttpMethod .get , path: apiPath, params: apiParams, headers: apiHeaders);
50+
51+ return models.TemplateFunction .fromMap (res.data);
52+
53+ }
54+
55+ /// Download deployment
56+ ///
57+ /// Get a Deployment's contents by its unique ID. This endpoint supports range
58+ /// requests for partial or streaming file download.
59+ Future <Uint8List > getDeploymentDownload ({required String functionId, required String deploymentId}) async {
60+ final String apiPath = '/functions/{functionId}/deployments/{deploymentId}/download' .replaceAll ('{functionId}' , functionId).replaceAll ('{deploymentId}' , deploymentId);
61+
62+ final Map <String , dynamic > params = {
63+
64+
65+ 'project' : client.config['project' ],
66+ };
67+
68+ final res = await client.call (HttpMethod .get , path: apiPath, params: params, responseType: ResponseType .bytes);
69+ return res.data;
70+ }
71+
972 /// List executions
1073 ///
1174 /// Get a list of all the current user function execution logs. You can use the
@@ -34,10 +97,12 @@ class Functions extends Service {
3497 /// current execution status. You can ping the `Get Execution` endpoint to get
3598 /// updates on the current execution status. Once this endpoint is called, your
3699 /// function execution process will start asynchronously.
37- Future <models.Execution > createExecution ({required String functionId, String ? body, bool ? xasync, String ? path, enums.ExecutionMethod ? method, Map ? headers, String ? scheduledAt}) async {
100+ Future <models.Execution > createExecution ({required String functionId, String ? body, bool ? xasync, String ? path, enums.ExecutionMethod ? method, Map ? headers, String ? scheduledAt, Function ( UploadProgress ) ? onProgress }) async {
38101 final String apiPath = '/functions/{functionId}/executions' .replaceAll ('{functionId}' , functionId);
39102
40103 final Map <String , dynamic > apiParams = {
104+
105+
41106 'body' : body,
42107 'async' : xasync,
43108 'path' : path,
@@ -47,10 +112,18 @@ class Functions extends Service {
47112 };
48113
49114 final Map <String , String > apiHeaders = {
50- 'content-type' : 'application/json ' ,
115+ 'content-type' : 'multipart/form-data ' ,
51116 };
52117
53- final res = await client.call (HttpMethod .post, path: apiPath, params: apiParams, headers: apiHeaders);
118+ String idParamName = '' ;
119+ final res = await client.chunkedUpload (
120+ path: apiPath,
121+ params: apiParams,
122+ paramName: paramName,
123+ idParamName: idParamName,
124+ headers: apiHeaders,
125+ onProgress: onProgress,
126+ );
54127
55128 return models.Execution .fromMap (res.data);
56129
0 commit comments