| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 590ea0d commit 7025743
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -430,6 +430,10 @@ Delete a snippet:: | |||
| 430 | 430 | # or | |
| 431 | 431 | snippet.delete() | |
| 432 | 432 | ||
| 433 | + Get user agent detail (admin only):: | ||
| 434 | + | ||
| 435 | + detail = snippet.user_agent_detail() | ||
| 436 | + | ||
| 433 | 437 | Notes | |
| 434 | 438 | ===== | |
| 435 | 439 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,3 +52,7 @@ Delete a snippet:: | |||
| 52 | 52 | gl.snippets.delete(snippet_id) | |
| 53 | 53 | # or | |
| 54 | 54 | snippet.delete() | |
| 55 | + | ||
| 56 | + Get user agent detail (admin only):: | ||
| 57 | + | ||
| 58 | + detail = snippet.user_agent_detail() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -371,6 +371,23 @@ def delete(self, **kwargs): | |||
| 371 | 371 | self.manager.delete(self.get_id()) | |
| 372 | 372 | ||
| 373 | 373 | ||
| 374 | + class UserAgentDetailMixin(object): | ||
| 375 | + @cli.register_custom_action(('Snippet', 'ProjectSnippet', 'ProjectIssue')) | ||
| 376 | + @exc.on_http_error(exc.GitlabGetError) | ||
| 377 | + def user_agent_detail(self, **kwargs): | ||
| 378 | + """Get the user agent detail. | ||
| 379 | + | ||
| 380 | + Args: | ||
| 381 | + **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 382 | + | ||
| 383 | + Raises: | ||
| 384 | + GitlabAuthenticationError: If authentication is not correct | ||
| 385 | + GitlabGetError: If the server cannot perform the request | ||
| 386 | + """ | ||
| 387 | + path = '%s/%s/user_agent_detail' % (self.manager.path, self.get_id()) | ||
| 388 | + return self.manager.gitlab.http_get(path, **kwargs) | ||
| 389 | + | ||
| 390 | + | ||
| 374 | 391 | class AccessRequestMixin(object): | |
| 375 | 392 | @cli.register_custom_action(('ProjectAccessRequest', 'GroupAccessRequest'), | |
| 376 | 393 | tuple(), ('access_level', )) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,6 +73,13 @@ class O(SetMixin): | |||
| 73 | 73 | obj = O() | |
| 74 | 74 | self.assertTrue(hasattr(obj, 'set')) | |
| 75 | 75 | ||
| 76 | + def test_user_agent_detail_mixin(self): | ||
| 77 | + class O(UserAgentDetailMixin): | ||
| 78 | + pass | ||
| 79 | + | ||
| 80 | + obj = O() | ||
| 81 | + self.assertTrue(hasattr(obj, 'user_agent_detail')) | ||
| 82 | + | ||
| 76 | 83 | ||
| 77 | 84 | class TestMetaMixins(unittest.TestCase): | |
| 78 | 85 | def test_retrieve_mixin(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -786,7 +786,7 @@ class LicenseManager(RetrieveMixin, RESTManager): | |||
| 786 | 786 | _optional_get_attrs = ('project', 'fullname') | |
| 787 | 787 | ||
| 788 | 788 | ||
| 789 | - class Snippet(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 789 | + class Snippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 790 | 790 | _short_print_attr = 'title' | |
| 791 | 791 | ||
| 792 | 792 | @cli.register_custom_action('Snippet') | |
@@ -1386,8 +1386,9 @@ class ProjectIssueDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): | |||
| 1386 | 1386 | _create_attrs = (('body',), ('created_at',)) | |
| 1387 | 1387 | ||
| 1388 | 1388 | ||
| 1389 | - class ProjectIssue(SubscribableMixin, TodoMixin, TimeTrackingMixin, SaveMixin, | ||
| 1390 | - ObjectDeleteMixin, RESTObject): | ||
| 1389 | + class ProjectIssue(UserAgentDetailMixin, SubscribableMixin, TodoMixin, | ||
| 1390 | + TimeTrackingMixin, SaveMixin, ObjectDeleteMixin, | ||
| 1391 | + RESTObject): | ||
| 1391 | 1392 | _short_print_attr = 'title' | |
| 1392 | 1393 | _id_attr = 'iid' | |
| 1393 | 1394 | _managers = ( | |
@@ -1396,21 +1397,6 @@ class ProjectIssue(SubscribableMixin, TodoMixin, TimeTrackingMixin, SaveMixin, | |||
| 1396 | 1397 | ('notes', 'ProjectIssueNoteManager'), | |
| 1397 | 1398 | ) | |
| 1398 | 1399 | ||
| 1399 | - @cli.register_custom_action('ProjectIssue') | ||
| 1400 | - @exc.on_http_error(exc.GitlabUpdateError) | ||
| 1401 | - def user_agent_detail(self, **kwargs): | ||
| 1402 | - """Get user agent detail. | ||
| 1403 | - | ||
| 1404 | - Args: | ||
| 1405 | - **kwargs: Extra options to send to the server (e.g. sudo) | ||
| 1406 | - | ||
| 1407 | - Raises: | ||
| 1408 | - GitlabAuthenticationError: If authentication is not correct | ||
| 1409 | - GitlabGetError: If the detail could not be retrieved | ||
| 1410 | - """ | ||
| 1411 | - path = '%s/%s/user_agent_detail' % (self.manager.path, self.get_id()) | ||
| 1412 | - return self.manager.gitlab.http_get(path, **kwargs) | ||
| 1413 | - | ||
| 1414 | 1400 | @cli.register_custom_action('ProjectIssue', ('to_project_id',)) | |
| 1415 | 1401 | @exc.on_http_error(exc.GitlabUpdateError) | |
| 1416 | 1402 | def move(self, to_project_id, **kwargs): | |
@@ -2291,7 +2277,8 @@ class ProjectSnippetDiscussionManager(RetrieveMixin, CreateMixin, RESTManager): | |||
| 2291 | 2277 | _create_attrs = (('body',), ('created_at',)) | |
| 2292 | 2278 | ||
| 2293 | 2279 | ||
| 2294 | - class ProjectSnippet(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 2280 | + class ProjectSnippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, | ||
| 2281 | + RESTObject): | ||
| 2295 | 2282 | _url = '/projects/%(project_id)s/snippets' | |
| 2296 | 2283 | _short_print_attr = 'title' | |
| 2297 | 2284 | _managers = ( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -506,6 +506,8 @@ | |||
| 506 | 506 | assert(len(issue1.notes.list()) == 0) | |
| 507 | 507 | assert(isinstance(issue1.user_agent_detail(), dict)) | |
| 508 | 508 | ||
| 509 | + assert(issue1.user_agent_detail()['user_agent']) | ||
| 510 | + | ||
| 509 | 511 | discussion = issue1.discussions.create({'body': 'Discussion body'}) | |
| 510 | 512 | assert(len(issue1.discussions.list()) == 1) | |
| 511 | 513 | d_note = discussion.notes.create({'body': 'first note'}) | |
@@ -534,6 +536,8 @@ | |||
| 534 | 536 | 'visibility': gitlab.v4.objects.VISIBILITY_PRIVATE} | |
| 535 | 537 | ) | |
| 536 | 538 | ||
| 539 | + assert(snippet.user_agent_detail()['user_agent']) | ||
| 540 | + | ||
| 537 | 541 | discussion = snippet.discussions.create({'body': 'Discussion body'}) | |
| 538 | 542 | assert(len(snippet.discussions.list()) == 1) | |
| 539 | 543 | d_note = discussion.notes.create({'body': 'first note'}) | |
@@ -699,6 +703,8 @@ | |||
| 699 | 703 | content = snippet.content() | |
| 700 | 704 | assert(content == 'import gitlab') | |
| 701 | 705 | ||
| 706 | + assert(snippet.user_agent_detail()['user_agent']) | ||
| 707 | + | ||
| 702 | 708 | snippet.delete() | |
| 703 | 709 | snippets = gl.snippets.list(all=True) | |
| 704 | 710 | assert(len(snippets) == 0) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments