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 API.""" |
| 7 |
| 8 from endpoints import ResourceContainer |
| 9 from protorpc import messages |
| 10 from protorpc import message_types |
| 11 |
| 12 from proto import usergroup_pb2 |
| 13 |
| 14 |
| 15 ########################## Helper Message ########################## |
| 16 |
| 17 |
| 18 class ErrorMessage(messages.Message): |
| 19 """Request error.""" |
| 20 code = messages.IntegerField( |
| 21 1, required=True, variant=messages.Variant.INT32) |
| 22 reason = messages.StringField(2, required=True) |
| 23 message = messages.StringField(3, required=True) |
| 24 |
| 25 |
| 26 class Status(messages.Message): |
| 27 """Issue status.""" |
| 28 status = messages.StringField(1, required=True) |
| 29 meansOpen = messages.BooleanField(2, required=True) |
| 30 description = messages.StringField(3) |
| 31 |
| 32 |
| 33 class Label(messages.Message): |
| 34 """Issue label.""" |
| 35 label = messages.StringField(1, required=True) |
| 36 description = messages.StringField(2) |
| 37 |
| 38 |
| 39 class Prompt(messages.Message): |
| 40 """Default issue template values.""" |
| 41 name = messages.StringField(1, required=True) |
| 42 title = messages.StringField(2) |
| 43 description = messages.StringField(3) |
| 44 titleMustBeEdited = messages.BooleanField(4) |
| 45 status = messages.StringField(5) |
| 46 labels = messages.StringField(6, repeated=True) |
| 47 membersOnly = messages.BooleanField(7) |
| 48 defaultToMember = messages.BooleanField(8) |
| 49 componentRequired = messages.BooleanField(9) |
| 50 |
| 51 |
| 52 class Role(messages.Enum): |
| 53 """User role.""" |
| 54 owner = 1 |
| 55 member = 2 |
| 56 contributor = 3 |
| 57 |
| 58 |
| 59 class IssueState(messages.Enum): |
| 60 """Issue state.""" |
| 61 closed = 0 |
| 62 open = 1 |
| 63 |
| 64 |
| 65 class CannedQuery(messages.Enum): |
| 66 """Canned query to search issues.""" |
| 67 all = 0 |
| 68 new = 1 |
| 69 open = 2 |
| 70 owned = 3 |
| 71 reported = 4 |
| 72 starred = 5 |
| 73 to_verify = 6 |
| 74 |
| 75 |
| 76 class AtomPerson(messages.Message): |
| 77 """Atomic person.""" |
| 78 name = messages.StringField(1, required=True) |
| 79 htmlLink = messages.StringField(2) |
| 80 kind = messages.StringField(3) |
| 81 |
| 82 |
| 83 class Attachment(messages.Message): |
| 84 """Issue attachment.""" |
| 85 attachmentId = messages.IntegerField( |
| 86 1, variant=messages.Variant.INT64, required=True) |
| 87 fileName = messages.StringField(2, required=True) |
| 88 fileSize = messages.IntegerField( |
| 89 3, required=True, variant=messages.Variant.INT32) |
| 90 mimetype = messages.StringField(4, required=True) |
| 91 isDeleted = messages.BooleanField(5) |
| 92 |
| 93 |
| 94 class IssueRef(messages.Message): |
| 95 "Issue reference." |
| 96 issueId = messages.IntegerField( |
| 97 1, required=True, variant=messages.Variant.INT32) |
| 98 projectId = messages.StringField(2) |
| 99 kind = messages.StringField(3) |
| 100 |
| 101 |
| 102 class FieldValueOperator(messages.Enum): |
| 103 """Operator of field values.""" |
| 104 add = 1 |
| 105 remove = 2 |
| 106 clear = 3 |
| 107 |
| 108 |
| 109 class FieldValue(messages.Message): |
| 110 """Custom field values.""" |
| 111 fieldName = messages.StringField(1, required=True) |
| 112 fieldValue = messages.StringField(2) |
| 113 derived = messages.BooleanField(3, default=False) |
| 114 operator = messages.EnumField(FieldValueOperator, 4, default='add') |
| 115 |
| 116 |
| 117 class Update(messages.Message): |
| 118 """Issue update.""" |
| 119 summary = messages.StringField(1) |
| 120 status = messages.StringField(2) |
| 121 owner = messages.StringField(3) |
| 122 labels = messages.StringField(4, repeated=True) |
| 123 cc = messages.StringField(5, repeated=True) |
| 124 blockedOn = messages.StringField(6, repeated=True) |
| 125 blocking = messages.StringField(7, repeated=True) |
| 126 mergedInto = messages.StringField(8) |
| 127 kind = messages.StringField(9) |
| 128 components = messages.StringField(10, repeated=True) |
| 129 moveToProject = messages.StringField(11) |
| 130 fieldValues = messages.MessageField(FieldValue, 12, repeated=True) |
| 131 |
| 132 |
| 133 class ProjectIssueConfig(messages.Message): |
| 134 """Issue configuration of project.""" |
| 135 kind = messages.StringField(1) |
| 136 restrictToKnown = messages.BooleanField(2) |
| 137 defaultColumns = messages.StringField(3, repeated=True) |
| 138 defaultSorting = messages.StringField(4, repeated=True) |
| 139 statuses = messages.MessageField(Status, 5, repeated=True) |
| 140 labels = messages.MessageField(Label, 6, repeated=True) |
| 141 prompts = messages.MessageField(Prompt, 7, repeated=True) |
| 142 defaultPromptForMembers = messages.IntegerField( |
| 143 8, variant=messages.Variant.INT32) |
| 144 defaultPromptForNonMembers = messages.IntegerField( |
| 145 9, variant=messages.Variant.INT32) |
| 146 usersCanSetLabels = messages.BooleanField(10) |
| 147 |
| 148 |
| 149 class IssueCommentWrapper(messages.Message): |
| 150 """Issue comment details.""" |
| 151 attachments = messages.MessageField(Attachment, 1, repeated=True) |
| 152 author = messages.MessageField(AtomPerson, 2) |
| 153 canDelete = messages.BooleanField(3) |
| 154 content = messages.StringField(4) |
| 155 deletedBy = messages.MessageField(AtomPerson, 5) |
| 156 id = messages.IntegerField(6, variant=messages.Variant.INT32) |
| 157 published = message_types.DateTimeField(7) |
| 158 updates = messages.MessageField(Update, 8) |
| 159 kind = messages.StringField(9) |
| 160 |
| 161 |
| 162 class IssueWrapper(messages.Message): |
| 163 """Issue details.""" |
| 164 author = messages.MessageField(AtomPerson, 1) |
| 165 blockedOn = messages.MessageField(IssueRef, 2, repeated=True) |
| 166 blocking = messages.MessageField(IssueRef, 3, repeated=True) |
| 167 canComment = messages.BooleanField(4) |
| 168 canEdit = messages.BooleanField(5) |
| 169 cc = messages.MessageField(AtomPerson, 6, repeated=True) |
| 170 closed = message_types.DateTimeField(7) |
| 171 description = messages.StringField(8) |
| 172 id = messages.IntegerField(9, variant=messages.Variant.INT32) |
| 173 kind = messages.StringField(10) |
| 174 labels = messages.StringField(11, repeated=True) |
| 175 owner = messages.MessageField(AtomPerson, 12) |
| 176 published = message_types.DateTimeField(13) |
| 177 starred = messages.BooleanField(14) |
| 178 stars = messages.IntegerField(15, variant=messages.Variant.INT32) |
| 179 state = messages.EnumField(IssueState, 16) |
| 180 status = messages.StringField(17, required=True) |
| 181 summary = messages.StringField(18, required=True) |
| 182 title = messages.StringField(19) |
| 183 updated = message_types.DateTimeField(20) |
| 184 components = messages.StringField(21, repeated=True) |
| 185 projectId = messages.StringField(22, required=True) |
| 186 mergedInto = messages.MessageField(IssueRef, 23) |
| 187 fieldValues = messages.MessageField(FieldValue, 24, repeated=True) |
| 188 |
| 189 |
| 190 class ProjectWrapper(messages.Message): |
| 191 """Project details.""" |
| 192 kind = messages.StringField(1) |
| 193 name = messages.StringField(2) |
| 194 externalId = messages.StringField(3, required=True) |
| 195 htmlLink = messages.StringField(4, required=True) |
| 196 summary = messages.StringField(5) |
| 197 description = messages.StringField(6) |
| 198 versionControlSystem = messages.StringField(7) |
| 199 repositoryUrls = messages.StringField(8, repeated=True) |
| 200 issuesConfig = messages.MessageField(ProjectIssueConfig, 9) |
| 201 role = messages.EnumField(Role, 10) |
| 202 members = messages.MessageField(AtomPerson, 11, repeated=True) |
| 203 |
| 204 |
| 205 class UserGroupSettingsWrapper(messages.Message): |
| 206 """User group settings.""" |
| 207 groupName = messages.StringField(1, required=True) |
| 208 who_can_view_members = messages.EnumField( |
| 209 usergroup_pb2.MemberVisibility, 2, |
| 210 default=usergroup_pb2.MemberVisibility.MEMBERS) |
| 211 ext_group_type = messages.EnumField(usergroup_pb2.GroupType, 3) |
| 212 last_sync_time = messages.IntegerField( |
| 213 4, default=0, variant=messages.Variant.INT32) |
| 214 |
| 215 |
| 216 class GroupCitizens(messages.Message): |
| 217 """Group members and owners.""" |
| 218 groupOwners = messages.StringField(1, repeated=True) |
| 219 groupMembers = messages.StringField(2, repeated=True) |
| 220 |
| 221 |
| 222 ########################## Comments Message ########################## |
| 223 |
| 224 # pylint: disable=pointless-string-statement |
| 225 |
| 226 """Request to delete/undelete an issue's comments.""" |
| 227 ISSUES_COMMENTS_DELETE_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 228 message_types.VoidMessage, |
| 229 projectId=messages.StringField(1, required=True), |
| 230 issueId=messages.IntegerField( |
| 231 2, required=True, variant=messages.Variant.INT32), |
| 232 commentId=messages.IntegerField( |
| 233 3, required=True, variant=messages.Variant.INT32) |
| 234 ) |
| 235 |
| 236 |
| 237 class IssuesCommentsDeleteResponse(messages.Message): |
| 238 """Response message of request to delete/undelete an issue's comments.""" |
| 239 error = messages.MessageField(ErrorMessage, 1) |
| 240 |
| 241 |
| 242 """Request to insert an issue's comments.""" |
| 243 ISSUES_COMMENTS_INSERT_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 244 IssueCommentWrapper, |
| 245 projectId=messages.StringField(1, required=True), |
| 246 issueId=messages.IntegerField( |
| 247 2, required=True, variant=messages.Variant.INT32), |
| 248 sendEmail=messages.BooleanField(3) |
| 249 ) |
| 250 |
| 251 |
| 252 class IssuesCommentsInsertResponse(messages.Message): |
| 253 """Response message of request to insert an issue's comments.""" |
| 254 error = messages.MessageField(ErrorMessage, 1) |
| 255 id = messages.IntegerField(2, variant=messages.Variant.INT32) |
| 256 kind = messages.StringField(3) |
| 257 author = messages.MessageField(AtomPerson, 4) |
| 258 content = messages.StringField(5) |
| 259 published = message_types.DateTimeField(6) |
| 260 updates = messages.MessageField(Update, 7) |
| 261 canDelete = messages.BooleanField(8) |
| 262 |
| 263 |
| 264 """Request to list an issue's comments.""" |
| 265 ISSUES_COMMENTS_LIST_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 266 message_types.VoidMessage, |
| 267 projectId=messages.StringField(1, required=True), |
| 268 issueId=messages.IntegerField( |
| 269 2, required=True, variant=messages.Variant.INT32), |
| 270 maxResults=messages.IntegerField( |
| 271 3, default=100, variant=messages.Variant.INT32), |
| 272 startIndex=messages.IntegerField( |
| 273 4, default=0, variant=messages.Variant.INT32) |
| 274 ) |
| 275 |
| 276 |
| 277 class IssuesCommentsListResponse(messages.Message): |
| 278 """Response message of request to list an issue's comments.""" |
| 279 error = messages.MessageField(ErrorMessage, 1) |
| 280 items = messages.MessageField(IssueCommentWrapper, 2, repeated=True) |
| 281 totalResults = messages.IntegerField(3, variant=messages.Variant.INT32) |
| 282 kind = messages.StringField(4) |
| 283 |
| 284 |
| 285 ########################## Users Message ########################## |
| 286 |
| 287 """Request to get a user.""" |
| 288 USERS_GET_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 289 message_types.VoidMessage, |
| 290 userId=messages.StringField(1, required=True), |
| 291 ownerProjectsOnly=messages.BooleanField(2, default=False) |
| 292 ) |
| 293 |
| 294 |
| 295 class UsersGetResponse(messages.Message): |
| 296 """Response message of request to get a user.""" |
| 297 error = messages.MessageField(ErrorMessage, 1) |
| 298 id = messages.StringField(2) |
| 299 kind = messages.StringField(3) |
| 300 projects = messages.MessageField(ProjectWrapper, 4, repeated=True) |
| 301 |
| 302 |
| 303 ########################## Issues Message ########################## |
| 304 |
| 305 """Request to get an issue.""" |
| 306 ISSUES_GET_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 307 message_types.VoidMessage, |
| 308 projectId=messages.StringField(1, required=True), |
| 309 issueId=messages.IntegerField( |
| 310 2, required=True, variant=messages.Variant.INT32) |
| 311 ) |
| 312 |
| 313 |
| 314 """Request to insert an issue.""" |
| 315 ISSUES_INSERT_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 316 IssueWrapper, |
| 317 projectId=messages.StringField(1, required=True), |
| 318 sendEmail=messages.BooleanField(2, default=True) |
| 319 ) |
| 320 |
| 321 |
| 322 class IssuesGetInsertResponse(messages.Message): |
| 323 """Response message of request to get/insert an issue.""" |
| 324 error = messages.MessageField(ErrorMessage, 1) |
| 325 kind = messages.StringField(2) |
| 326 id = messages.IntegerField(3, variant=messages.Variant.INT32) |
| 327 title = messages.StringField(4) |
| 328 summary = messages.StringField(5) |
| 329 stars = messages.IntegerField(6, variant=messages.Variant.INT32) |
| 330 starred = messages.BooleanField(7) |
| 331 status = messages.StringField(8) |
| 332 state = messages.EnumField(IssueState, 9) |
| 333 labels = messages.StringField(10, repeated=True) |
| 334 author = messages.MessageField(AtomPerson, 11) |
| 335 owner = messages.MessageField(AtomPerson, 12) |
| 336 cc = messages.MessageField(AtomPerson, 13, repeated=True) |
| 337 updated = message_types.DateTimeField(14) |
| 338 published = message_types.DateTimeField(15) |
| 339 closed = message_types.DateTimeField(16) |
| 340 blockedOn = messages.MessageField(IssueRef, 17, repeated=True) |
| 341 blocking = messages.MessageField(IssueRef, 18, repeated=True) |
| 342 projectId = messages.StringField(19) |
| 343 canComment = messages.BooleanField(20) |
| 344 canEdit = messages.BooleanField(21) |
| 345 components = messages.StringField(22, repeated=True) |
| 346 mergedInto = messages.MessageField(IssueRef, 23) |
| 347 fieldValues = messages.MessageField(FieldValue, 24, repeated=True) |
| 348 |
| 349 |
| 350 """Request to list issues.""" |
| 351 ISSUES_LIST_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 352 message_types.VoidMessage, |
| 353 projectId=messages.StringField(1, required=True), |
| 354 additionalProject=messages.StringField(2, repeated=True), |
| 355 can=messages.EnumField(CannedQuery, 3, default='all'), |
| 356 label=messages.StringField(4), |
| 357 maxResults=messages.IntegerField( |
| 358 5, default=100, variant=messages.Variant.INT32), |
| 359 owner=messages.StringField(6), |
| 360 publishedMax=messages.IntegerField(7, variant=messages.Variant.INT64), |
| 361 publishedMin=messages.IntegerField(8, variant=messages.Variant.INT64), |
| 362 q=messages.StringField(9), |
| 363 sort=messages.StringField(10), |
| 364 startIndex=messages.IntegerField( |
| 365 11, default=0, variant=messages.Variant.INT32), |
| 366 status=messages.StringField(12), |
| 367 updatedMax=messages.IntegerField(13, variant=messages.Variant.INT64), |
| 368 updatedMin=messages.IntegerField(14, variant=messages.Variant.INT64) |
| 369 ) |
| 370 |
| 371 |
| 372 class IssuesListResponse(messages.Message): |
| 373 """Response message of request to list issues.""" |
| 374 error = messages.MessageField(ErrorMessage, 1) |
| 375 items = messages.MessageField(IssueWrapper, 2, repeated=True) |
| 376 totalResults = messages.IntegerField(3, variant=messages.Variant.INT32) |
| 377 kind = messages.StringField(4) |
| 378 |
| 379 |
| 380 """Request to list group settings.""" |
| 381 GROUPS_SETTINGS_LIST_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 382 message_types.VoidMessage, |
| 383 importedGroupsOnly=messages.BooleanField(1, default=False) |
| 384 ) |
| 385 |
| 386 |
| 387 class GroupsSettingsListResponse(messages.Message): |
| 388 """Response message of request to list group settings.""" |
| 389 error = messages.MessageField(ErrorMessage, 1) |
| 390 groupSettings = messages.MessageField( |
| 391 UserGroupSettingsWrapper, 2, repeated=True) |
| 392 |
| 393 |
| 394 """Request to create a group.""" |
| 395 GROUPS_CREATE_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 396 message_types.VoidMessage, |
| 397 groupName = messages.StringField(1, required=True), |
| 398 who_can_view_members = messages.EnumField( |
| 399 usergroup_pb2.MemberVisibility, 2, |
| 400 default=usergroup_pb2.MemberVisibility.MEMBERS, required=True), |
| 401 ext_group_type = messages.EnumField(usergroup_pb2.GroupType, 3) |
| 402 ) |
| 403 |
| 404 |
| 405 class GroupsCreateResponse(messages.Message): |
| 406 """Response message of request to create a group.""" |
| 407 error = messages.MessageField(ErrorMessage, 1) |
| 408 groupID = messages.IntegerField( |
| 409 2, variant=messages.Variant.INT32) |
| 410 |
| 411 |
| 412 """Request to get a group.""" |
| 413 GROUPS_GET_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 414 message_types.VoidMessage, |
| 415 groupName = messages.StringField(1, required=True) |
| 416 ) |
| 417 |
| 418 |
| 419 class GroupsGetResponse(messages.Message): |
| 420 """Response message of request to create a group.""" |
| 421 error = messages.MessageField(ErrorMessage, 1) |
| 422 groupID = messages.IntegerField( |
| 423 2, variant=messages.Variant.INT32) |
| 424 groupSettings = messages.MessageField( |
| 425 UserGroupSettingsWrapper, 3) |
| 426 groupOwners = messages.StringField(4, repeated=True) |
| 427 groupMembers = messages.StringField(5, repeated=True) |
| 428 |
| 429 |
| 430 """Request to update a group.""" |
| 431 GROUPS_UPDATE_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 432 GroupCitizens, |
| 433 groupName = messages.StringField(1, required=True), |
| 434 who_can_view_members = messages.EnumField( |
| 435 usergroup_pb2.MemberVisibility, 2), |
| 436 ext_group_type = messages.EnumField(usergroup_pb2.GroupType, 3), |
| 437 last_sync_time = messages.IntegerField( |
| 438 4, default=0, variant=messages.Variant.INT32), |
| 439 friend_projects = messages.StringField(5, repeated=True), |
| 440 ) |
| 441 |
| 442 |
| 443 class GroupsUpdateResponse(messages.Message): |
| 444 """Response message of request to update a group.""" |
| 445 error = messages.MessageField(ErrorMessage, 1) |
| 446 |
| 447 |
| 448 ########################## Component Message ########################## |
| 449 |
| 450 class Component(messages.Message): |
| 451 """Component PB.""" |
| 452 componentId = messages.IntegerField( |
| 453 1, required=True, variant=messages.Variant.INT32) |
| 454 projectName = messages.StringField(2, required=True) |
| 455 componentPath = messages.StringField(3, required=True) |
| 456 description = messages.StringField(4) |
| 457 admin = messages.StringField(5, repeated=True) |
| 458 cc = messages.StringField(6, repeated=True) |
| 459 deprecated = messages.BooleanField(7, default=False) |
| 460 created = message_types.DateTimeField(8) |
| 461 creator = messages.StringField(9) |
| 462 modified = message_types.DateTimeField(10) |
| 463 modifier = messages.StringField(11) |
| 464 |
| 465 |
| 466 """Request to get components of a project.""" |
| 467 COMPONENTS_LIST_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 468 message_types.VoidMessage, |
| 469 projectId=messages.StringField(1, required=True), |
| 470 ) |
| 471 |
| 472 |
| 473 class ComponentsListResponse(messages.Message): |
| 474 """Response to list components.""" |
| 475 components = messages.MessageField( |
| 476 Component, 1, repeated=True) |
| 477 |
| 478 |
| 479 class ComponentCreateRequestBody(messages.Message): |
| 480 """Request body to create a component.""" |
| 481 parentPath = messages.StringField(1) |
| 482 description = messages.StringField(2) |
| 483 admin = messages.StringField(3, repeated=True) |
| 484 cc = messages.StringField(4, repeated=True) |
| 485 deprecated = messages.BooleanField(5, default=False) |
| 486 |
| 487 |
| 488 """Request to create component of a project.""" |
| 489 COMPONENTS_CREATE_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 490 ComponentCreateRequestBody, |
| 491 projectId=messages.StringField(1, required=True), |
| 492 componentName=messages.StringField(2, required=True), |
| 493 ) |
| 494 |
| 495 |
| 496 """Request to delete a component.""" |
| 497 COMPONENTS_DELETE_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 498 message_types.VoidMessage, |
| 499 projectId=messages.StringField(1, required=True), |
| 500 componentPath=messages.StringField(2, required=True), |
| 501 ) |
| 502 |
| 503 |
| 504 class ComponentUpdateFieldID(messages.Enum): |
| 505 """Possible fields that can be updated in a component.""" |
| 506 LEAF_NAME = 1 |
| 507 DESCRIPTION = 2 |
| 508 ADMIN = 3 |
| 509 CC = 4 |
| 510 DEPRECATED = 5 |
| 511 |
| 512 |
| 513 class ComponentUpdate(messages.Message): |
| 514 """Component update.""" |
| 515 # 'field' allows a field to be cleared |
| 516 field = messages.EnumField(ComponentUpdateFieldID, 1, required=True) |
| 517 leafName = messages.StringField(2) |
| 518 description = messages.StringField(3) |
| 519 admin = messages.StringField(4, repeated=True) |
| 520 cc = messages.StringField(5, repeated=True) |
| 521 deprecated = messages.BooleanField(6) |
| 522 |
| 523 |
| 524 class ComponentUpdateRequestBody(messages.Message): |
| 525 """Request body to update a component.""" |
| 526 updates = messages.MessageField(ComponentUpdate, 1, repeated=True) |
| 527 |
| 528 |
| 529 """Request to update a component.""" |
| 530 COMPONENTS_UPDATE_REQUEST_RESOURCE_CONTAINER = ResourceContainer( |
| 531 ComponentUpdateRequestBody, |
| 532 projectId=messages.StringField(1, required=True), |
| 533 componentPath=messages.StringField(2, required=True), |
| 534 ) |
OLD | NEW |