-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathfunctions.dart
More file actions
95 lines (79 loc) · 2.54 KB
/
functions.dart
File metadata and controls
95 lines (79 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
part of appwrite;
/// The Functions Service allows you view, create and manage your Cloud
/// Functions.
class Functions extends Service {
Functions(super.client);
/// List Executions
///
/// Get a list of all the current user function execution logs. You can use the
/// query params to filter your results.
///
Future<models.ExecutionList> listExecutions(
{required String functionId,
List<String>? queries,
String? search}) async {
final String path = '/functions/{functionId}/executions'
.replaceAll('{functionId}', functionId);
final Map<String, dynamic> params = {
'queries': queries,
'search': search,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
final res = await client.call(CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
));
return models.ExecutionList.fromMap(res.data);
}
/// Create Execution
///
/// Trigger a function execution. The returned object will return you the
/// current execution status. You can ping the `Get Execution` endpoint to get
/// updates on the current execution status. Once this endpoint is called, your
/// function execution process will start asynchronously.
///
Future<models.Execution> createExecution(
{required String functionId, String? data, bool? xasync}) async {
final String path = '/functions/{functionId}/executions'
.replaceAll('{functionId}', functionId);
final Map<String, dynamic> params = {
'data': data,
'async': xasync,
};
final Map<String, String> headers = {
'content-type': 'application/json',
};
final res = await client.call(CallParams(
HttpMethod.post,
path,
params: params,
headers: headers,
));
return models.Execution.fromMap(res.data);
}
/// Get Execution
///
/// Get a function execution log by its unique ID.
///
Future<models.Execution> getExecution(
{required String functionId, required String executionId}) async {
final String path = '/functions/{functionId}/executions/{executionId}'
.replaceAll('{functionId}', functionId)
.replaceAll('{executionId}', executionId);
final Map<String, dynamic> params = {};
final Map<String, String> headers = {
'content-type': 'application/json',
};
final res = await client.call(CallParams(
HttpMethod.get,
path,
params: params,
headers: headers,
));
return models.Execution.fromMap(res.data);
}
}