XCP-ng
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    XO Rest API Supported Queries

    Scheduled Pinned Locked Moved REST API
    16 Posts 3 Posters 1.4k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • julien-fJ Offline
      julien-f Vates 🪐 Co-Founder XO Team @DustyArmstrong
      last edited by

      @DustyArmstrong

      1. The parameter used for filtering is filter not s, if you saw the last one in the documentation, it's an error, please let me know and I'll fix it
      2. Filtering and limiting is not implemented for backup logs yet, I'll do it now.
      DustyArmstrongD 1 Reply Last reply Reply Quote 0
      • DustyArmstrongD Offline
        DustyArmstrong @julien-f
        last edited by DustyArmstrong

        @julien-f Thanks Julien.

        I am just going based off of the REST API docs https://xen-orchestra.com/docs/restapi.html. These refer to https://xen-orchestra.com/docs/manage_infrastructure.html#live-filter-search which is what I've been basing it off as the API docs don't say what formatting to use, I assumed it was the same.

        Edit: to be fair I think I probably just misunderstood, the REST docs do say filter but it linked to the syntax page which says use s maybe mixed me up. Ideally if the docs could give quick examples of how to use the parameters that would be great, but obviously that's just a "nice to have" for the inexperienced people like me, not a demand.

        julien-fJ 1 Reply Last reply Reply Quote 0
        • DustyArmstrongD Offline
          DustyArmstrong @olivierlambert
          last edited by

          @olivierlambert It's very basic for now! I have just created a dash with VM Deltas colored status success/fail by date (the id is of course the epoch so that's handy), a LAST GOOD BACKUP for deltas by hours since i.e. 9 hours ago, same again for Pool Metadata and finally a list of all VMs and their state i.e. Running/Halted.

          I am using the Infinity plugin to achieve it. Even without limit and filter it's still very useful to me as I had no good way to map XO backups into Grafana til I discovered the API, so many thanks for implementing! My main reason for wanting limit and filter is so the query returns less overall data (loading faster on the dash hopefully) and so I can separate out each backup job/component a bit better for manipulation (like the last good backup for that specific job).

          1 Reply Last reply Reply Quote 0
          • julien-fJ Offline
            julien-f Vates 🪐 Co-Founder XO Team @DustyArmstrong
            last edited by

            @DustyArmstrong filter and limit are now supported for backups/logs: https://github.com/vatesfr/xen-orchestra/commit/8a26e081027c5410757dcc7ae4ece6ffa7bd81a9

            0 julien-f committed to vatesfr/xen-orchestra
            feat(xo-server/rest-api): `filter`/`limit` support for `{backups/restore}/logs`
            
            Fixes https://xcp-ng.org/forum/post/64789
            DustyArmstrongD 2 Replies Last reply Reply Quote 1
            • DustyArmstrongD Offline
              DustyArmstrong @julien-f
              last edited by

              @julien-f That's awesome, thanks!

              1 Reply Last reply Reply Quote 0
              • DustyArmstrongD Offline
                DustyArmstrong @julien-f
                last edited by DustyArmstrong

                @julien-f Sorry to bring up again, have now updated and the limit is working, but it returns the data in reverse order (oldest backup is shown first). Is there any functionality present in the API at the moment to order it with newest first? If not no issue, I can just go back to doing it how I was.

                1 Reply Last reply Reply Quote 0
                • olivierlambertO Offline
                  olivierlambert Vates 🪐 Co-Founder CEO
                  last edited by

                  Good question for @julien-f
                  He's not available right now, but I will remind him to take a look when he's around 🙂

                  DustyArmstrongD 1 Reply Last reply Reply Quote 0
                  • DustyArmstrongD Offline
                    DustyArmstrong @olivierlambert
                    last edited by

                    @olivierlambert Thanks! I really do appreciate the quick responses and implementations. The filter works perfectly - so does the limit of course, it's just the ordering the way it is restricts its usefulness as I need to see the most recent backup info rather than the oldest.

                    I did try playing around with the web UI, you can sort by ID in Backup - /backup/overview?s_logs=1_0_desc- - but didn't know how/if it translated to the API.

                    julien-fJ 1 Reply Last reply Reply Quote 0
                    • julien-fJ Offline
                      julien-f Vates 🪐 Co-Founder XO Team @DustyArmstrong
                      last edited by

                      @DustyArmstrong I'm reluctant to add a sort feature, but I think it makes sense for the limit to be applied at the end of the sorted collection 🙂

                      DustyArmstrongD 1 Reply Last reply Reply Quote 0
                      • DustyArmstrongD Offline
                        DustyArmstrong @julien-f
                        last edited by DustyArmstrong

                        @julien-f EDIT: I have just seen your commit from yesterday that looks to resolve my below post! Sorry I read your comment about sorting as the limit ordering ("sorting") wouldn't be implemented. My query around "sorting" was in reference to exactly what you have implemented so, many thanks!

                        @DustyArmstrong said in XO Rest API Supported Queries:

                        @julien-f Sorry to bring up again, have now updated and the limit is working, but it returns the data in reverse order (oldest backup is shown first). Is there any functionality present in the API at the moment to order it with newest first? If not no issue, I can just go back to doing it how I was.

                        julien-fJ 1 Reply Last reply Reply Quote 0
                        • julien-fJ Offline
                          julien-f Vates 🪐 Co-Founder XO Team @DustyArmstrong
                          last edited by

                          @DustyArmstrong Perfect, thanks for your feedback 🙂

                          1 Reply Last reply Reply Quote 0
                          • olivierlambertO olivierlambert moved this topic from Xen Orchestra on
                          • First post
                            Last post