createFeed method
Implementation
Future<Feed> createFeed({
required String projectId,
required String name,
String description = '',
String visibility = 'private',
bool paused = false,
Map<String, String> annotations = const {},
Object? messageSchema,
}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/feeds');
final body = {
'name': name,
'description': description,
'visibility': visibility,
'paused': paused,
'annotations': annotations,
'message_schema': messageSchema,
};
final response = await httpClient.post(uri, body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to create feed. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
final data = jsonDecode(response.body) as Map<String, dynamic>;
return Feed.fromJson(data['feed'] as Map<String, dynamic>);
}