An entity representing system user. Attribute: name: Username. Also used as a primary key and foreign key when referencing users in other models. is_service: True if this is a service account. nicknames: Nickname + origin pairs for ChatOps auth.
| 29 | |
| 30 | |
| 31 | class UserDB(stormbase.StormFoundationDB): |
| 32 | """ |
| 33 | An entity representing system user. |
| 34 | |
| 35 | Attribute: |
| 36 | name: Username. Also used as a primary key and foreign key when referencing users in other |
| 37 | models. |
| 38 | is_service: True if this is a service account. |
| 39 | nicknames: Nickname + origin pairs for ChatOps auth. |
| 40 | """ |
| 41 | |
| 42 | name = me.StringField(required=True, unique=True) |
| 43 | is_service = me.BooleanField(required=True, default=False) |
| 44 | nicknames = me.DictField( |
| 45 | required=False, help_text='"Nickname + origin" pairs for ChatOps auth' |
| 46 | ) |
| 47 | |
| 48 | def get_roles(self, include_remote=True): |
| 49 | """ |
| 50 | Retrieve roles assigned to that user. |
| 51 | |
| 52 | :param include_remote: True to also include remote role assignments. |
| 53 | :type include_remote: ``bool`` |
| 54 | |
| 55 | :rtype: ``list`` of :class:`RoleDB` |
| 56 | """ |
| 57 | rbac_service = get_rbac_backend().get_service_class() |
| 58 | result = rbac_service.get_roles_for_user( |
| 59 | user_db=self, include_remote=include_remote |
| 60 | ) |
| 61 | return result |
| 62 | |
| 63 | def get_permission_assignments(self): |
| 64 | # TODO |
| 65 | pass |
| 66 | |
| 67 | |
| 68 | class TokenDB(stormbase.StormFoundationDB): |
no outgoing calls