createAgentRoomGrant method
Future<void>
createAgentRoomGrant({
- required String projectId,
- required String agentId,
- required String roomId,
- AgentRoomGrant? permissions,
Implementation
Future<void> createAgentRoomGrant({
required String projectId,
required String agentId,
required String roomId,
AgentRoomGrant? permissions,
}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/agent-room-grants');
final effectivePermissions = permissions ?? AgentRoomGrant.fromApiScope(ApiScope.agentDefault());
final body = {'agent_id': agentId, 'room_id': roomId, 'permissions': effectivePermissions.toJson()};
final response = await httpClient.post(uri, body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to create agent room grant. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
}