Retrieves a paginated list of projects for a given organization
:param int organization_Id:
id of the organization for which you want to retrieve the projects list
:param string sortField_name:
optional parameter to sort the projects list on the project names
:param int sortField_order:
optional parameter to sort the projects list in a certain order.
The possible values are: '0 = ascending' -- '1 = descending'.
:param int page_number:
optional parameter to only get the projects in the list on the given page number
:param int page_size:
optional parameter to select what size you want a page of the projects list to be
:param list[int] status:
optional parameter, used to filter what types of projects you want to see. If this parameter is given, then you will only see the projects that conform to 1 of the values in the status.
The possible values are: '0 = ongoing' -- '1 = problem' -- '2 = finished' -- '3 = closed'.
API call function:
def list_projects(self, organization_Id, sortField_name=None, sortField_order=None, page_number=None, page_size=None, status=[]) -> dict:
url = self.project_url + "/organizations/" + str(organization_Id) + "/projects"
#for the optional parameters
url += "?"
if sortField_name is not None:
url += "SortField.Name=" + sortField_name + "&"
if sortField_order is not None:
url += "SortField.Order=" + str(sortField_order) + "&"
if page_number is not None:
url += "PageNumber=" + str(page_number) + "&"
if page_size is not None:
url += "PageSize=" + str(page_size) + "&"
if not len(status) == 0:
for st in status:
url += "Status=" + str(st) + "&"
url = url[:-1]
response = requests.get(url, headers=self.get_header)
if(response.ok):
print("projects list: \n", response.text, "\n")
return response.json()
else:
logger.error(f"retrieving projects list failed: {response.content}")
raise Exception