Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a proper react-admin dataProvider around the open-balena-api OData api #21

Open
shaunco opened this issue Feb 13, 2025 · 8 comments

Comments

@shaunco
Copy link
Contributor

shaunco commented Feb 13, 2025

While #20 will likely be a quick fix, longer term, being directly dependent on the Balena DB schema is quite fragile.

For most ob-ui functionality, an OData react-admin dataProvider (or here) that wraps the Balena API would be far more stable since open-balena-api maintains backwards compatibility on v1, v2, v3, v4, v5, and v6 calls. (mapping them internally to the current v7 calls).

There might still be a few ob-ui features that require direct database/registry/s3 calls, like deleting releases (with all the nested image/storage cleanup).

@dcaputo-harmoni
Copy link
Owner

@shaunco This is a great idea and something I have had on my list for a long time. It would be a huge upgrade to openbalen-admin, providing all of the benefits of the SBVR rules / validation as well. The pinejs package can even handle database connection management / pooling. Just need to find a way to make days a bit longer to squeeze it in....

@shaunco
Copy link
Contributor Author

shaunco commented Feb 15, 2025

I'll tinker with this over the next few weeks and see if I can come up with a first pass at an OData dataProvider

@dcaputo-harmoni
Copy link
Owner

Awesome. Just FYI - and I mention this because I was just tinkering with this code last week when we implemented a read/write split postgres cluster - I think the relevant line is here. We would need to initialize pinejs (which is passed a database config as well as the SBVR rules), and then invoke it for the various resources like this example for device types. The alternative is to use the exposed api of open-balena-api directly, but the issue there is that they don't actually expose api endpoints for things we need such as users.

@shaunco
Copy link
Contributor Author

shaunco commented Feb 15, 2025

Thanks! Will take a look at those, but I'd like to avoid pinejs if possible 😬

My plan was to simply translate the resource types/ids/data and query strings that come into the dataProvider methods into OData requests. I've recently done a bunch of this in go and shell scripts (we have a nightly shell script that removes old/unused releases). There is pretty decent overlap between the two interfaces ... I might fall flat on my face and end up the pinejs route though, haha.

@dcaputo-harmoni
Copy link
Owner

Ok, that would be a lot simpler for sure! Good luck

@mkrenzke
Copy link
Contributor

@shaunco I'd highly appreciate to get rid of Postgrest entirely. From my point of view it's not quite handy.

For those features not supported through the API, we could also implement new endpoints in the express-server which I'd prefer rather than working with pinejs. I'd be glad to help if support is needed.

@shaunco
Copy link
Contributor Author

shaunco commented Feb 20, 2025

I'll try to post a pass in the next few days, but will need to iterate on it in a branch to avoid disrupting the main branch.

@dcaputo-harmoni
Copy link
Owner

@shaunco Just FYI, we are using API for some automation pipelines that move devices between openbalena environments, and I'm finding some pretty steep limitations - for example, users can only view their own API keys, including the global admin user. Not sure how we will get around this if using API as the dataprovider source, but just want to flag it - might need a database supplement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants