connectAgent method
Implementation
Future<AgentConnectionInfo> connectAgent({required String projectId, required String agentName}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final encodedAgentName = Uri.encodeComponent(agentName);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/agents/$encodedAgentName/connect');
final response = await httpClient.post(uri, body: jsonEncode({}));
if (response.statusCode >= 400) {
if (response.statusCode == 404) {
throw NotFoundException('Agent not found');
}
throw MeshagentException(
'Failed to connect agent. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
return AgentConnectionInfo.fromJson(jsonDecode(response.body));
}