Get Lifecycle Environments Sorted in API call

Problem:
API call (/katello/api/organizations/:organization_id/environments) returns Lifecycle Environments sorted by name

Expected outcome:
API call returns Lifecycle Environments sorted by order

Foreman and Proxy versions:
1.24.2

Foreman and Proxy plugin versions:
Katello 3.14.1

Distribution and version:

Other relevant data:
There appears to be no way of changing the parameters of the API call to fetch them in the order in which the lifecycle occurs. If there a way to get them in order, or do I need to write an algorithm to sort them after making the API call?

You might try the following request paramters to modify the sort order:
‘sortBy=name’
‘sortOrder=ASC’

In your question I assumed that by “order” you mean some sorting that isn’t alphabetically by name. Please let me know if that is incorrect.

In any case, you can try to vary the sort field with ‘sortBy’ and then change the sort order of that field using ‘sortOrder’, for example.

@uml-cs did my suggestion help you with your issue?

Sorry for the delayed response! Things have been crazy with the current situation.

Unfortunately the sort order that I’m looking for isn’t one that SQL handles directly (as far as I know at least). Specifically I’m looking to have them sorted in the order that they appear in the content view promotion screen (screenshot below). The API call does return the ordering in what’s essentially a doubly linked list that I could then sort myself. However, I was looking to see if there was an existing solution.

image

Ah! that page actually uses a different api:

https://theforeman.org/plugins/katello/3.14/api/apidoc/v2/lifecycle_environments/paths.html

GET /katello/api/organizations/:organization_id/environments/paths

that has a special response to generate that path structure.

Awesome! That was exactly what we were looking form.

Thank you!