Skip to content

Commit

Permalink
Merge branch 'atlassian-api:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
gkowalc authored Feb 9, 2024
2 parents ef752ab + fe2cfb6 commit 999de01
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions atlassian/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -2526,6 +2526,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 @@ -2601,6 +2610,28 @@ 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

0 comments on commit 999de01

Please sign in to comment.