|  |  | 1 |  | using LGDXRobotCloud.Utilities.Enums; | 
|  |  | 2 |  |  | 
|  |  | 3 |  | namespace LGDXRobotCloud.Utilities.Helpers; | 
|  |  | 4 |  |  | 
|  |  | 5 |  | public record LgdxRoleData | 
|  |  | 6 |  | { | 
|  |  | 7 |  |   public required LgdxRoleType RoleType { get; set; } | 
|  |  | 8 |  |   public required string Name { get; set; } | 
|  |  | 9 |  |   public List<string> Scopes { get; set; } = []; | 
|  |  | 10 |  | } | 
|  |  | 11 |  |  | 
|  |  | 12 |  | public class LgdxRolesHelper | 
|  |  | 13 |  | { | 
|  | 11 | 14 |  |   public static Dictionary<Guid, LgdxRoleData> DefaultRoles { get; set; } = new() | 
|  | 1 | 15 |  |   { | 
|  | 1 | 16 |  |     { | 
|  | 1 | 17 |  |       new Guid("01942232-62d5-7db2-a566-f720e44ade0d"), | 
|  | 1 | 18 |  |       new LgdxRoleData | 
|  | 1 | 19 |  |       { | 
|  | 1 | 20 |  |         RoleType = LgdxRoleType.GlobalAdministrator, | 
|  | 1 | 21 |  |         Name = LgdxRoleType.GlobalAdministrator.ToEnumMember()!, | 
|  | 1 | 22 |  |         Scopes = [ | 
|  | 1 | 23 |  |           "LGDXRobotCloud.API/FullAccess" | 
|  | 1 | 24 |  |         ] | 
|  | 1 | 25 |  |       } | 
|  | 1 | 26 |  |     }, | 
|  | 1 | 27 |  |     { | 
|  | 1 | 28 |  |       new Guid("01942232-62d5-7b98-9fbb-137f811c2ad9"), | 
|  | 1 | 29 |  |       new LgdxRoleData | 
|  | 1 | 30 |  |       { | 
|  | 1 | 31 |  |         RoleType = LgdxRoleType.GlobalAuditor, | 
|  | 1 | 32 |  |         Name = LgdxRoleType.GlobalAuditor.ToEnumMember()!, | 
|  | 1 | 33 |  |         Scopes = [ | 
|  | 1 | 34 |  |           "LGDXRobotCloud.API/Read" | 
|  | 1 | 35 |  |         ] | 
|  | 1 | 36 |  |       } | 
|  | 1 | 37 |  |     }, | 
|  | 1 | 38 |  |     { | 
|  | 1 | 39 |  |       new Guid("01942232-62d5-734a-b2fe-5caf8b22deda"), | 
|  | 1 | 40 |  |       new LgdxRoleData | 
|  | 1 | 41 |  |       { | 
|  | 1 | 42 |  |         RoleType = LgdxRoleType.RobotAdministrator, | 
|  | 1 | 43 |  |         Name = LgdxRoleType.RobotAdministrator.ToEnumMember()!, | 
|  | 1 | 44 |  |         Scopes = [ | 
|  | 1 | 45 |  |           "LGDXRobotCloud.API/Navigation/Robots/FullAccess" | 
|  | 1 | 46 |  |         ] | 
|  | 1 | 47 |  |       } | 
|  | 1 | 48 |  |     }, | 
|  | 1 | 49 |  |     { | 
|  | 1 | 50 |  |       new Guid("01942232-62d5-7dda-99de-e041a0ec179b"), | 
|  | 1 | 51 |  |       new LgdxRoleData | 
|  | 1 | 52 |  |       { | 
|  | 1 | 53 |  |         RoleType = LgdxRoleType.RobotAuditor, | 
|  | 1 | 54 |  |         Name = LgdxRoleType.RobotAuditor.ToEnumMember()!, | 
|  | 1 | 55 |  |         Scopes = [ | 
|  | 1 | 56 |  |           "LGDXRobotCloud.API/Navigation/Robots/Read" | 
|  | 1 | 57 |  |         ] | 
|  | 1 | 58 |  |       } | 
|  | 1 | 59 |  |     }, | 
|  | 1 | 60 |  |     { | 
|  | 1 | 61 |  |       new Guid("01942232-62d5-7a90-99c0-3716b4fd2bb1"), | 
|  | 1 | 62 |  |       new LgdxRoleData | 
|  | 1 | 63 |  |       { | 
|  | 1 | 64 |  |         RoleType = LgdxRoleType.NavigationAdministrator, | 
|  | 1 | 65 |  |         Name = LgdxRoleType.NavigationAdministrator.ToEnumMember()!, | 
|  | 1 | 66 |  |         Scopes = [ | 
|  | 1 | 67 |  |           "LGDXRobotCloud.API/Navigation/FullAccess" | 
|  | 1 | 68 |  |         ] | 
|  | 1 | 69 |  |       } | 
|  | 1 | 70 |  |     }, | 
|  | 1 | 71 |  |     { | 
|  | 1 | 72 |  |       new Guid("01942232-62d5-718a-b69a-044ac485ea0c"), | 
|  | 1 | 73 |  |       new LgdxRoleData | 
|  | 1 | 74 |  |       { | 
|  | 1 | 75 |  |         RoleType = LgdxRoleType.NavigationAuditor, | 
|  | 1 | 76 |  |         Name = LgdxRoleType.NavigationAuditor.ToEnumMember()!, | 
|  | 1 | 77 |  |         Scopes = [ | 
|  | 1 | 78 |  |           "LGDXRobotCloud.API/Navigation/Read" | 
|  | 1 | 79 |  |         ] | 
|  | 1 | 80 |  |       } | 
|  | 1 | 81 |  |     }, | 
|  | 1 | 82 |  |     { | 
|  | 1 | 83 |  |       new Guid("01942232-62d5-7218-a36f-b37da58d0066"), | 
|  | 1 | 84 |  |       new LgdxRoleData | 
|  | 1 | 85 |  |       { | 
|  | 1 | 86 |  |         RoleType = LgdxRoleType.AutomationAdministrator, | 
|  | 1 | 87 |  |         Name = LgdxRoleType.AutomationAdministrator.ToEnumMember()!, | 
|  | 1 | 88 |  |         Scopes = [ | 
|  | 1 | 89 |  |           "LGDXRobotCloud.API/Automation/FullAccess" | 
|  | 1 | 90 |  |         ] | 
|  | 1 | 91 |  |       } | 
|  | 1 | 92 |  |     }, | 
|  | 1 | 93 |  |     { | 
|  | 1 | 94 |  |       new Guid("01942232-62d5-7ad9-8fe5-4ca5135d3d5f"), | 
|  | 1 | 95 |  |       new LgdxRoleData | 
|  | 1 | 96 |  |       { | 
|  | 1 | 97 |  |         RoleType = LgdxRoleType.AutomationAuditor, | 
|  | 1 | 98 |  |         Name = LgdxRoleType.AutomationAuditor.ToEnumMember()!, | 
|  | 1 | 99 |  |         Scopes = [ | 
|  | 1 | 100 |  |           "LGDXRobotCloud.API/Automation/Read" | 
|  | 1 | 101 |  |         ] | 
|  | 1 | 102 |  |       } | 
|  | 1 | 103 |  |     }, | 
|  | 1 | 104 |  |     { | 
|  | 1 | 105 |  |       new Guid("01942232-62d5-755d-8cc6-dd069622cca5"), | 
|  | 1 | 106 |  |       new LgdxRoleData | 
|  | 1 | 107 |  |       { | 
|  | 1 | 108 |  |         RoleType = LgdxRoleType.AutoTaskAdministrator, | 
|  | 1 | 109 |  |         Name = LgdxRoleType.AutoTaskAdministrator.ToEnumMember()!, | 
|  | 1 | 110 |  |         Scopes = [ | 
|  | 1 | 111 |  |           "LGDXRobotCloud.API/Automation/AutoTasks/FullAccess" | 
|  | 1 | 112 |  |         ] | 
|  | 1 | 113 |  |       } | 
|  | 1 | 114 |  |     }, | 
|  | 1 | 115 |  |     { | 
|  | 1 | 116 |  |       new Guid("01942232-62d5-7d00-b742-e41e7421bf8f"), | 
|  | 1 | 117 |  |       new LgdxRoleData | 
|  | 1 | 118 |  |       { | 
|  | 1 | 119 |  |         RoleType = LgdxRoleType.AutoTaskAuditor, | 
|  | 1 | 120 |  |         Name = LgdxRoleType.AutoTaskAuditor.ToEnumMember()!, | 
|  | 1 | 121 |  |         Scopes = [ | 
|  | 1 | 122 |  |           "LGDXRobotCloud.API/Automation/AutoTasks/Read" | 
|  | 1 | 123 |  |         ] | 
|  | 1 | 124 |  |       } | 
|  | 1 | 125 |  |     }, | 
|  | 1 | 126 |  |     { | 
|  | 1 | 127 |  |       new Guid("01942323-e76a-79ef-9502-8f3894194070"), | 
|  | 1 | 128 |  |       new LgdxRoleData | 
|  | 1 | 129 |  |       { | 
|  | 1 | 130 |  |         RoleType = LgdxRoleType.AutoTaskOperator, | 
|  | 1 | 131 |  |         Name = LgdxRoleType.AutoTaskOperator.ToEnumMember()!, | 
|  | 1 | 132 |  |         Scopes = [ | 
|  | 1 | 133 |  |           "LGDXRobotCloud.API/Automation/AutoTasks/Write", | 
|  | 1 | 134 |  |           "LGDXRobotCloud.API/Automation/AutoTasks/Delete" | 
|  | 1 | 135 |  |         ] | 
|  | 1 | 136 |  |       } | 
|  | 1 | 137 |  |     }, | 
|  | 1 | 138 |  |     { | 
|  | 1 | 139 |  |       new Guid("01942323-e76a-7ce8-a4f9-d550527ffe4e"), | 
|  | 1 | 140 |  |       new LgdxRoleData | 
|  | 1 | 141 |  |       { | 
|  | 1 | 142 |  |         RoleType = LgdxRoleType.EmailRecipient, | 
|  | 1 | 143 |  |         Name = LgdxRoleType.EmailRecipient.ToEnumMember()!, | 
|  | 1 | 144 |  |         Scopes = [] | 
|  | 1 | 145 |  |       } | 
|  | 1 | 146 |  |     } | 
|  | 1 | 147 |  |   }; | 
|  |  | 148 |  |  | 
|  |  | 149 |  |   public static bool IsSystemRole(Guid roleId) | 
|  | 10 | 150 |  |   { | 
|  | 10 | 151 |  |     return DefaultRoles.ContainsKey(roleId); | 
|  | 10 | 152 |  |   } | 
|  |  | 153 |  |  | 
|  |  | 154 |  |   public static Guid GetSystemRoleId(LgdxRoleType roleType) | 
|  | 0 | 155 |  |   { | 
|  | 0 | 156 |  |     return DefaultRoles.First(r => r.Value.RoleType == roleType).Key; | 
|  | 0 | 157 |  |   } | 
|  |  | 158 |  | } |