How to sort revisions by created date in the API

I am trying to use the Rancher API to get the list of revisions of a deployment that are sorted by the key created.

From the revisions API link, I see the only links are uuid.

"sort": {
    "order": "asc",
    "reverse": "https://rancher.test.com/v3/project/c-cf4pg:p-h2hsh/workloads/deployment:test:ubuntu-test1/revisions?order=desc",
    "links": {
        "uuid": "https://rancher.test.com/v3/project/c-cf4pg:p-h2hsh/workloads/deployment:test:ubuntu-test1/revisions?sort=uuid"
    }
},

In the Rancher web UI, if I go into a Workload, and click the … button and select “Rollback”, it gives me a list of the revisions ordered by age, which is what I want from the API.

UI-revisions

If I iterate over the revisions from the API response, they are ordered by the replicaset ID in alphabetical order.

replicaset:test:ubuntu-test1-595c8c64c
replicaset:test:ubuntu-test1-5fd9fb77b6
replicaset:test:ubuntu-test1-67764499bd
replicaset:test:ubuntu-test1-694ddb8d5b
replicaset:test:ubuntu-test1-6c6b5587b7
replicaset:test:ubuntu-test1-74fc98bcfd
replicaset:test:ubuntu-test1-76bd475dd4
replicaset:test:ubuntu-test1-78945579b8
replicaset:test:ubuntu-test1-7d4947cd65
replicaset:test:ubuntu-test1-f9bdc9547
replicaset:test:ubuntu-test1-fc48dc54

Is there a way to get the API to order by created date or do I just need to manually re-order the response?

1 Like