| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ API examples | |||
| 14 | 14 | gl_objects/commits | |
| 15 | 15 | gl_objects/deploy_keys | |
| 16 | 16 | gl_objects/deployments | |
| 17 | + gl_objects/discussions | ||
| 17 | 18 | gl_objects/environments | |
| 18 | 19 | gl_objects/events | |
| 19 | 20 | gl_objects/features | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1159,10 +1159,39 @@ class ProjectCommitCommentManager(ListMixin, CreateMixin, RESTManager): | |||
| 1159 | 1159 | _create_attrs = (('note', ), ('path', 'line', 'line_type')) | |
| 1160 | 1160 | ||
| 1161 | 1161 | ||
| 1162 | + class ProjectCommitDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1163 | + pass | ||
| 1164 | + | ||
| 1165 | + | ||
| 1166 | + class ProjectCommitDiscussionNoteManager(GetMixin, CreateMixin, UpdateMixin, | ||
| 1167 | + DeleteMixin, RESTManager): | ||
| 1168 | + _path = ('/projects/%(project_id)s/repository/commits/%(commit_id)s/' | ||
| 1169 | + 'discussions/%(discussion_id)s/notes') | ||
| 1170 | + _obj_cls = ProjectCommitDiscussionNote | ||
| 1171 | + _from_parent_attrs = {'project_id': 'project_id', | ||
| 1172 | + 'commit_id': 'commit_id', | ||
| 1173 | + 'discussion_id': 'id'} | ||
| 1174 | + _create_attrs = (('body',), ('created_at', 'position')) | ||
| 1175 | + _update_attrs = (('body',), tuple()) | ||
| 1176 | + | ||
| 1177 | + | ||
| 1178 | + class ProjectCommitDiscussion(RESTObject): | ||
| 1179 | + _managers = (('notes', 'ProjectCommitDiscussionNoteManager'),) | ||
| 1180 | + | ||
| 1181 | + | ||
| 1182 | + class ProjectCommitDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): | ||
| 1183 | + _path = ('/projects/%(project_id)s/repository/commits/%(commit_id)s/' | ||
| 1184 | + 'discussions') | ||
| 1185 | + _obj_cls = ProjectCommitDiscussion | ||
| 1186 | + _from_parent_attrs = {'project_id': 'project_id', 'commit_id': 'id'} | ||
| 1187 | + _create_attrs = (('body',), ('created_at',)) | ||
| 1188 | + | ||
| 1189 | + | ||
| 1162 | 1190 | class ProjectCommit(RESTObject): | |
| 1163 | 1191 | _short_print_attr = 'title' | |
| 1164 | 1192 | _managers = ( | |
| 1165 | 1193 | ('comments', 'ProjectCommitCommentManager'), | |
| 1194 | + ('discussions', 'ProjectCommitDiscussionManager'), | ||
| 1166 | 1195 | ('statuses', 'ProjectCommitStatusManager'), | |
| 1167 | 1196 | ) | |
| 1168 | 1197 | ||
@@ -1330,13 +1359,41 @@ class ProjectIssueNoteManager(CRUDMixin, RESTManager): | |||
| 1330 | 1359 | _update_attrs = (('body', ), tuple()) | |
| 1331 | 1360 | ||
| 1332 | 1361 | ||
| 1362 | + class ProjectIssueDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1363 | + pass | ||
| 1364 | + | ||
| 1365 | + | ||
| 1366 | + class ProjectIssueDiscussionNoteManager(GetMixin, CreateMixin, UpdateMixin, | ||
| 1367 | + DeleteMixin, RESTManager): | ||
| 1368 | + _path = ('/projects/%(project_id)s/issues/%(issue_iid)s/' | ||
| 1369 | + 'discussions/%(discussion_id)s/notes') | ||
| 1370 | + _obj_cls = ProjectIssueDiscussionNote | ||
| 1371 | + _from_parent_attrs = {'project_id': 'project_id', | ||
| 1372 | + 'issue_iid': 'issue_iid', | ||
| 1373 | + 'discussion_id': 'id'} | ||
| 1374 | + _create_attrs = (('body',), ('created_at',)) | ||
| 1375 | + _update_attrs = (('body',), tuple()) | ||
| 1376 | + | ||
| 1377 | + | ||
| 1378 | + class ProjectIssueDiscussion(RESTObject): | ||
| 1379 | + _managers = (('notes', 'ProjectIssueDiscussionNoteManager'),) | ||
| 1380 | + | ||
| 1381 | + | ||
| 1382 | + class ProjectIssueDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): | ||
| 1383 | + _path = '/projects/%(project_id)s/issues/%(issue_iid)s/discussions' | ||
| 1384 | + _obj_cls = ProjectIssueDiscussion | ||
| 1385 | + _from_parent_attrs = {'project_id': 'project_id', 'issue_iid': 'iid'} | ||
| 1386 | + _create_attrs = (('body',), ('created_at',)) | ||
| 1387 | + | ||
| 1388 | + | ||
| 1333 | 1389 | class ProjectIssue(SubscribableMixin, TodoMixin, TimeTrackingMixin, SaveMixin, | |
| 1334 | 1390 | ObjectDeleteMixin, RESTObject): | |
| 1335 | 1391 | _short_print_attr = 'title' | |
| 1336 | 1392 | _id_attr = 'iid' | |
| 1337 | 1393 | _managers = ( | |
| 1338 | - ('notes', 'ProjectIssueNoteManager'), | ||
| 1339 | 1394 | ('awardemojis', 'ProjectIssueAwardEmojiManager'), | |
| 1395 | + ('discussions', 'ProjectIssueDiscussionManager'), | ||
| 1396 | + ('notes', 'ProjectIssueNoteManager'), | ||
| 1340 | 1397 | ) | |
| 1341 | 1398 | ||
| 1342 | 1399 | @cli.register_custom_action('ProjectIssue') | |
@@ -1510,7 +1567,7 @@ class ProjectMergeRequestNoteAwardEmojiManager(NoUpdateMixin, RESTManager): | |||
| 1510 | 1567 | '/notes/%(note_id)s/award_emoji') | |
| 1511 | 1568 | _obj_cls = ProjectMergeRequestNoteAwardEmoji | |
| 1512 | 1569 | _from_parent_attrs = {'project_id': 'project_id', | |
| 1513 | - 'mr_iid': 'issue_iid', | ||
| 1570 | + 'mr_iid': 'mr_iid', | ||
| 1514 | 1571 | 'note_id': 'id'} | |
| 1515 | 1572 | _create_attrs = (('name', ), tuple()) | |
| 1516 | 1573 | ||
@@ -1527,13 +1584,45 @@ class ProjectMergeRequestNoteManager(CRUDMixin, RESTManager): | |||
| 1527 | 1584 | _update_attrs = (('body', ), tuple()) | |
| 1528 | 1585 | ||
| 1529 | 1586 | ||
| 1587 | + class ProjectMergeRequestDiscussionNote(SaveMixin, ObjectDeleteMixin, | ||
| 1588 | + RESTObject): | ||
| 1589 | + pass | ||
| 1590 | + | ||
| 1591 | + | ||
| 1592 | + class ProjectMergeRequestDiscussionNoteManager(GetMixin, CreateMixin, | ||
| 1593 | + UpdateMixin, DeleteMixin, | ||
| 1594 | + RESTManager): | ||
| 1595 | + _path = ('/projects/%(project_id)s/merge_requests/%(mr_iid)s/' | ||
| 1596 | + 'discussions/%(discussion_id)s/notes') | ||
| 1597 | + _obj_cls = ProjectMergeRequestDiscussionNote | ||
| 1598 | + _from_parent_attrs = {'project_id': 'project_id', | ||
| 1599 | + 'mr_iid': 'mr_iid', | ||
| 1600 | + 'discussion_id': 'id'} | ||
| 1601 | + _create_attrs = (('body',), ('created_at',)) | ||
| 1602 | + _update_attrs = (('body',), tuple()) | ||
| 1603 | + | ||
| 1604 | + | ||
| 1605 | + class ProjectMergeRequestDiscussion(SaveMixin, RESTObject): | ||
| 1606 | + _managers = (('notes', 'ProjectMergeRequestDiscussionNoteManager'),) | ||
| 1607 | + | ||
| 1608 | + | ||
| 1609 | + class ProjectMergeRequestDiscussionManager(RetrieveMixin, CreateMixin, | ||
| 1610 | + UpdateMixin, RESTManager): | ||
| 1611 | + _path = '/projects/%(project_id)s/merge_requests/%(mr_iid)s/discussions' | ||
| 1612 | + _obj_cls = ProjectMergeRequestDiscussion | ||
| 1613 | + _from_parent_attrs = {'project_id': 'project_id', 'mr_iid': 'iid'} | ||
| 1614 | + _create_attrs = (('body',), ('created_at', 'position')) | ||
| 1615 | + _update_attrs = (('resolved',), tuple()) | ||
| 1616 | + | ||
| 1617 | + | ||
| 1530 | 1618 | class ProjectMergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, | |
| 1531 | 1619 | SaveMixin, ObjectDeleteMixin, RESTObject): | |
| 1532 | 1620 | _id_attr = 'iid' | |
| 1533 | 1621 | ||
| 1534 | 1622 | _managers = ( | |
| 1535 | 1623 | ('awardemojis', 'ProjectMergeRequestAwardEmojiManager'), | |
| 1536 | 1624 | ('diffs', 'ProjectMergeRequestDiffManager'), | |
| 1625 | + ('discussions', 'ProjectMergeRequestDiscussionManager'), | ||
| 1537 | 1626 | ('notes', 'ProjectMergeRequestNoteManager'), | |
| 1538 | 1627 | ) | |
| 1539 | 1628 | ||
@@ -2175,11 +2264,39 @@ class ProjectSnippetAwardEmojiManager(NoUpdateMixin, RESTManager): | |||
| 2175 | 2264 | _create_attrs = (('name', ), tuple()) | |
| 2176 | 2265 | ||
| 2177 | 2266 | ||
| 2267 | + class ProjectSnippetDiscussionNote(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 2268 | + pass | ||
| 2269 | + | ||
| 2270 | + | ||
| 2271 | + class ProjectSnippetDiscussionNoteManager(GetMixin, CreateMixin, UpdateMixin, | ||
| 2272 | + DeleteMixin, RESTManager): | ||
| 2273 | + _path = ('/projects/%(project_id)s/snippets/%(snippet_id)s/' | ||
| 2274 | + 'discussions/%(discussion_id)s/notes') | ||
| 2275 | + _obj_cls = ProjectSnippetDiscussionNote | ||
| 2276 | + _from_parent_attrs = {'project_id': 'project_id', | ||
| 2277 | + 'snippet_id': 'snippet_id', | ||
| 2278 | + 'discussion_id': 'id'} | ||
| 2279 | + _create_attrs = (('body',), ('created_at',)) | ||
| 2280 | + _update_attrs = (('body',), tuple()) | ||
| 2281 | + | ||
| 2282 | + | ||
| 2283 | + class ProjectSnippetDiscussion(RESTObject): | ||
| 2284 | + _managers = (('notes', 'ProjectSnippetDiscussionNoteManager'),) | ||
| 2285 | + | ||
| 2286 | + | ||
| 2287 | + class ProjectSnippetDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): | ||
| 2288 | + _path = '/projects/%(project_id)s/snippets/%(snippet_id)s/discussions' | ||
| 2289 | + _obj_cls = ProjectSnippetDiscussion | ||
| 2290 | + _from_parent_attrs = {'project_id': 'project_id', 'snippet_id': 'id'} | ||
| 2291 | + _create_attrs = (('body',), ('created_at',)) | ||
| 2292 | + | ||
| 2293 | + | ||
| 2178 | 2294 | class ProjectSnippet(SaveMixin, ObjectDeleteMixin, RESTObject): | |
| 2179 | 2295 | _url = '/projects/%(project_id)s/snippets' | |
| 2180 | 2296 | _short_print_attr = 'title' | |
| 2181 | 2297 | _managers = ( | |
| 2182 | 2298 | ('awardemojis', 'ProjectSnippetAwardEmojiManager'), | |
| 2299 | + ('discussions', 'ProjectSnippetDiscussionManager'), | ||
| 2183 | 2300 | ('notes', 'ProjectSnippetNoteManager'), | |
| 2184 | 2301 | ) | |
| 2185 | 2302 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -379,6 +379,20 @@ | |||
| 379 | 379 | commit.comments.create({'note': 'This is a commit comment'}) | |
| 380 | 380 | assert(len(commit.comments.list()) == 1) | |
| 381 | 381 | ||
| 382 | + # commit discussion | ||
| 383 | + count = len(commit.discussions.list()) | ||
| 384 | + discussion = commit.discussions.create({'body': 'Discussion body'}) | ||
| 385 | + assert(len(commit.discussions.list()) == (count + 1)) | ||
| 386 | + d_note = discussion.notes.create({'body': 'first note'}) | ||
| 387 | + d_note_from_get = discussion.notes.get(d_note.id) | ||
| 388 | + d_note_from_get.body = 'updated body' | ||
| 389 | + d_note_from_get.save() | ||
| 390 | + discussion = commit.discussions.get(discussion.id) | ||
| 391 | + assert(discussion.attributes['notes'][-1]['body'] == 'updated body') | ||
| 392 | + d_note_from_get.delete() | ||
| 393 | + discussion = commit.discussions.get(discussion.id) | ||
| 394 | + assert(len(discussion.attributes['notes']) == 1) | ||
| 395 | + | ||
| 382 | 396 | # housekeeping | |
| 383 | 397 | admin_project.housekeeping() | |
| 384 | 398 | ||
@@ -492,6 +506,18 @@ | |||
| 492 | 506 | assert(len(issue1.notes.list()) == 0) | |
| 493 | 507 | assert(isinstance(issue1.user_agent_detail(), dict)) | |
| 494 | 508 | ||
| 509 | + discussion = issue1.discussions.create({'body': 'Discussion body'}) | ||
| 510 | + assert(len(issue1.discussions.list()) == 1) | ||
| 511 | + d_note = discussion.notes.create({'body': 'first note'}) | ||
| 512 | + d_note_from_get = discussion.notes.get(d_note.id) | ||
| 513 | + d_note_from_get.body = 'updated body' | ||
| 514 | + d_note_from_get.save() | ||
| 515 | + discussion = issue1.discussions.get(discussion.id) | ||
| 516 | + assert(discussion.attributes['notes'][-1]['body'] == 'updated body') | ||
| 517 | + d_note_from_get.delete() | ||
| 518 | + discussion = issue1.discussions.get(discussion.id) | ||
| 519 | + assert(len(discussion.attributes['notes']) == 1) | ||
| 520 | + | ||
| 495 | 521 | # tags | |
| 496 | 522 | tag1 = admin_project.tags.create({'tag_name': 'v1.0', 'ref': 'master'}) | |
| 497 | 523 | assert(len(admin_project.tags.list()) == 1) | |
@@ -507,6 +533,19 @@ | |||
| 507 | 533 | {'title': 'snip1', 'file_name': 'foo.py', 'code': 'initial content', | |
| 508 | 534 | 'visibility': gitlab.v4.objects.VISIBILITY_PRIVATE} | |
| 509 | 535 | ) | |
| 536 | + | ||
| 537 | + discussion = snippet.discussions.create({'body': 'Discussion body'}) | ||
| 538 | + assert(len(snippet.discussions.list()) == 1) | ||
| 539 | + d_note = discussion.notes.create({'body': 'first note'}) | ||
| 540 | + d_note_from_get = discussion.notes.get(d_note.id) | ||
| 541 | + d_note_from_get.body = 'updated body' | ||
| 542 | + d_note_from_get.save() | ||
| 543 | + discussion = snippet.discussions.get(discussion.id) | ||
| 544 | + assert(discussion.attributes['notes'][-1]['body'] == 'updated body') | ||
| 545 | + d_note_from_get.delete() | ||
| 546 | + discussion = snippet.discussions.get(discussion.id) | ||
| 547 | + assert(len(discussion.attributes['notes']) == 1) | ||
| 548 | + | ||
| 510 | 549 | snippet.file_name = 'bar.py' | |
| 511 | 550 | snippet.save() | |
| 512 | 551 | snippet = admin_project.snippets.get(snippet.id) | |
@@ -541,6 +580,19 @@ | |||
| 541 | 580 | 'target_branch': 'master', | |
| 542 | 581 | 'title': 'MR readme2'}) | |
| 543 | 582 | ||
| 583 | + # discussion | ||
| 584 | + discussion = mr.discussions.create({'body': 'Discussion body'}) | ||
| 585 | + assert(len(mr.discussions.list()) == 1) | ||
| 586 | + d_note = discussion.notes.create({'body': 'first note'}) | ||
| 587 | + d_note_from_get = discussion.notes.get(d_note.id) | ||
| 588 | + d_note_from_get.body = 'updated body' | ||
| 589 | + d_note_from_get.save() | ||
| 590 | + discussion = mr.discussions.get(discussion.id) | ||
| 591 | + assert(discussion.attributes['notes'][-1]['body'] == 'updated body') | ||
| 592 | + d_note_from_get.delete() | ||
| 593 | + discussion = mr.discussions.get(discussion.id) | ||
| 594 | + assert(len(discussion.attributes['notes']) == 1) | ||
| 595 | + | ||
| 544 | 596 | # basic testing: only make sure that the methods exist | |
| 545 | 597 | mr.commits() | |
| 546 | 598 | mr.changes() | |
@@ -646,7 +698,10 @@ | |||
| 646 | 698 | assert(snippet.title == 'updated_title') | |
| 647 | 699 | content = snippet.content() | |
| 648 | 700 | assert(content == 'import gitlab') | |
| 701 | + | ||
| 649 | 702 | snippet.delete() | |
| 703 | + snippets = gl.snippets.list(all=True) | ||
| 704 | + assert(len(snippets) == 0) | ||
| 650 | 705 | ||
| 651 | 706 | # user activities | |
| 652 | 707 | gl.user_activities.list() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments