Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Jira] Added get_version and move_version #1333

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,15 @@ def get_project_versions_paginated(
url = "{base_url}/{key}/version".format(base_url=base_url, key=key)
return self.get(url, params=params)

def get_version(self, version):
"""
Returns a specific version with the given id.
:param version: The id of the version to return
"""
base_url = self.resource_url("version")
url = "{base_url}/{version}".format(base_url=base_url, version=version)
return self.get(url)

def add_version(
self,
project_key,
Expand Down Expand Up @@ -2550,6 +2559,26 @@ def update_version(
url = "{base_url}/{version}".format(base_url=base_url, version=version)
return self.put(url, data=payload)

def move_version(self, version, after=None, position=None):
"""
Reposition a project version
:param version: The version id to move
:param after: The version id to move version below
:param position: A position to move the version to
"""
base_url = self.resource_url("version")
url = "{base_url}/{version}/move".format(base_url=base_url, version=version)
if after is None and position is None:
raise ValueError('Must provide one of `after` or `position`')
if after:
after_url = self.get_version(after).get('self')
return self.post(url, data={'after': after_url})
if position:
position = position.lower().capitalize()
if position not in ['Earlier', 'Later', 'First', 'Last']:
raise ValueError('position must be one of Earlier, Later, First, or Last. Got {pos}'.format(pos=position))
return self.post(url, data={'position': position})

def get_project_roles(self, project_key):
"""
Provide associated project roles
Expand Down
Loading