agentlang-ai / agentlang

Generative AI-powered Programming Language
Apache License 2.0
119 stars 4 forks source link

RESTful API Support #399

Closed pythonhacker closed 1 year ago

pythonhacker commented 2 years ago

Currently the default CRUD operations for entities don't follow a RESTful model.

CRUD OP Current RESTFul Version Comments
READ POST /_e/Namespace.Component/Lookup_Entity -d'{"Namespace.Component/Lookup_Entity": {"Id": "<id>"}}' GET /Namespace.Component/Entity/<id> READ should always be a GET not a POST
CREATE POST /_e/Namespace.Component/Upsert_Entity -d'{"Namespace.Compnent/Upsert_Entity": {"Instance": {field1: val1, field2: val2, field3: val3 ...}}}' POST /Namespace.Component/Entity -d'{field1: va1, field2: val2, field3: val3 ...}'
UPDATE Default API does not exist PUT /Namespace.Component/Entity/<id> -d'{field1: updated_val1, fieldm: updated_valm ... }' Need to write custom event/dataflow for this now
DELETE POST /_e/Namespace.Component/Delete_Entity -d'{"Namespace.Component/Delete_Entity": {"Id": "<id>"}}' PUT /Namespace.Component/Entity/delete/<id> OR DELETE /Namespace.Component/Entity/<id>
pythonhacker commented 2 years ago

This can be done by writing a RESTFul HTTP API layer on top of the existing APIs supported for entities. I also think we should avoid the _e prefix in the RESTFul APIs. @vmatv8 - Pls comment on this and I will implement it.

vijayfractl commented 2 years ago

@pythonhacker I think we can have the RESTful model as the default, there is no need for a wrapper. Business dataflows can be exposed via the POST /_e/event endpoint, just as we have right now. @fractlrao What do you think?

fractlrao commented 2 years ago

Supporting a RESTful interface directly, instead of as an additional layer, would be helpful.

pythonhacker commented 2 years ago

Thanks for the comments @fractlrao @vmatv8 - A variation from the URL scheme I suggested /Namespace.Component/Entity is /Namespace/Component/Entity. Let me know your thoughts about it. And kindly assign this to me @vmatv8 .

vijayfractl commented 2 years ago

I kept the /_e/ prefix to identify endpoints that directly evaluate events, i.e non-REST APIs. This is just a suggestion, I am fine with other naming schemes.

vijayfractl commented 1 year ago

Will be tracked under https://github.com/fractl-io/fractl/issues/815