21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/legion/mcp/tools/rbac_assignments.rb', line 21
def call(team: nil, role: nil, principal: nil)
log.info('Starting legion.mcp.tools.rbac_assignments.call')
return error_response('legion-rbac not installed') unless defined?(Legion::Rbac)
return error_response('legion-data not connected') unless Legion::Rbac::Store.db_available?
ds = Legion::Data::Model::RbacRoleAssignment.dataset
ds = ds.where(team: team) if team
ds = ds.where(role: role) if role
ds = ds.where(principal_id: principal) if principal
text_response(ds.all.map(&:values))
rescue StandardError => e
handle_exception(e, level: :warn, operation: 'legion.mcp.tools.rbac_assignments.call')
log.warn("RbacAssignments#call failed: #{e.message}")
error_response("Failed to list assignments: #{e.message}")
end
|