Skip to content

Commit

Permalink
Add support for user_agent_detail (issues)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauvain Pocentek committed Nov 11, 2017
1 parent ad35482 commit 397d677
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/gl_objects/issues.py
Expand Up @@ -85,3 +85,7 @@
# project issue reset time spent
issue.reset_time_spent()
# end project issue reset time spent

# project issue useragent
detail = issue.user_agent_detail()
# end project issue useragent
5 changes: 5 additions & 0 deletions docs/gl_objects/issues.rst
Expand Up @@ -176,3 +176,8 @@ Reset spent time for an issue:
:start-after: # project issue reset time spent
:end-before: # end project issue reset time spent

Get user agent detail for the issue (admin only):

.. literalinclude:: issues.py
:start-after: # project issue useragent
:end-before: # end project issue useragent
15 changes: 15 additions & 0 deletions gitlab/v4/objects.py
Expand Up @@ -1128,6 +1128,21 @@ class ProjectIssue(SubscribableMixin, TodoMixin, TimeTrackingMixin, SaveMixin,
_id_attr = 'iid'
_managers = (('notes', 'ProjectIssueNoteManager'), )

@cli.register_custom_action('ProjectIssue')
@exc.on_http_error(exc.GitlabUpdateError)
def user_agent_detail(self, **kwargs):
"""Get user agent detail.
Args:
**kwargs: Extra options to send to the server (e.g. sudo)
Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabGetError: If the detail could not be retrieved
"""
path = '%s/%s/user_agent_detail' % (self.manager.path, self.get_id())
return self.manager.gitlab.http_get(path, **kwargs)

@cli.register_custom_action('ProjectIssue', ('to_project_id',))
@exc.on_http_error(exc.GitlabUpdateError)
def move(self, to_project_id, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions tools/python_test_v4.py
Expand Up @@ -435,6 +435,7 @@
assert(len(issue1.notes.list()) == 1)
note.delete()
assert(len(issue1.notes.list()) == 0)
assert(isinstance(issue1.user_agent_detail(), dict))

# tags
tag1 = admin_project.tags.create({'tag_name': 'v1.0', 'ref': 'master'})
Expand Down

0 comments on commit 397d677

Please sign in to comment.