OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is govered by a BSD-style |
| 3 # license that can be found in the LICENSE file or at |
| 4 # https://developers.google.com/open-source/licenses/bsd |
| 5 |
| 6 """Protocol buffers for Monorail usergroups.""" |
| 7 |
| 8 from protorpc import messages |
| 9 |
| 10 |
| 11 class MemberVisibility(messages.Enum): |
| 12 """Enum controlling who can see the members of a user group.""" |
| 13 OWNERS = 0 |
| 14 MEMBERS = 1 |
| 15 ANYONE = 2 |
| 16 |
| 17 |
| 18 class GroupType(messages.Enum): |
| 19 """Type of external group to import.""" |
| 20 CHROME_INFRA_AUTH = 0 |
| 21 MDB = 1 |
| 22 BAGGINS = 3 |
| 23 |
| 24 |
| 25 class UserGroupSettings(messages.Message): |
| 26 """In-memory busines object for representing user group settings.""" |
| 27 who_can_view_members = messages.EnumField( |
| 28 MemberVisibility, 1, default=MemberVisibility.MEMBERS) |
| 29 ext_group_type = messages.EnumField(GroupType, 2) |
| 30 last_sync_time = messages.IntegerField( |
| 31 3, default=0, variant=messages.Variant.INT32) |
| 32 friend_projects = messages.IntegerField( |
| 33 4, repeated=True, variant=messages.Variant.INT32) |
| 34 # TODO(jrobbins): add settings to control who can join, etc. |
| 35 |
| 36 |
| 37 def MakeSettings(who_can_view_members_str, ext_group_type_str=None, |
| 38 last_sync_time=0, friend_projects=[]): |
| 39 """Create and return a new user record in RAM.""" |
| 40 settings = UserGroupSettings( |
| 41 who_can_view_members=MemberVisibility(who_can_view_members_str.upper())) |
| 42 if ext_group_type_str: |
| 43 settings.ext_group_type = GroupType(ext_group_type_str.upper()) |
| 44 settings.last_sync_time = last_sync_time |
| 45 settings.friend_projects = friend_projects |
| 46 return settings |
OLD | NEW |