ArangoDB-Community / pyArango

Python Driver for ArangoDB with built-in validation
https://pyarango.readthedocs.io/en/latest/
Apache License 2.0
238 stars 90 forks source link

No way to pass payload via action() method, but some HTTP routes require a body #107

Open Simran-B opened 6 years ago

Simran-B commented 6 years ago

ArangoDB version: 3.3.12 pyArango version: 1.3.1 (via pip)

See https://stackoverflow.com/questions/51362259/rename-collection-with-pyarango

To rename a collection, it is necessary to pass a JSON body {"name":"newname"} in a PUT request to /_api/collection/<collectionHandle>/rename. The .action() method only supports passing on URL path params however.

The HTTP docs also describe that there would be a path parameter ?collection-name=newname but it is not support anymore (I tried with curl but got errors back about name being empty as if no parameter for name or collection-name was passed).

It would be nice if the action method and possibly others too would support passing a body.

dilipvamsi commented 5 years ago

Hi @Simran-B @tariqdaouda , I was thinking about adding functionality to do a rest call to db object and connection object for any action that needs to be done.

connection.action.post(
    '/_api/collection/<collectionHandle>/rename', json={'name': 'newname'}
)
tariqdaouda commented 5 years ago

Like a way a to send arbitrary calls to the db? I think that would be cool and would add a lot of flexibility.

Alternatively, I have written a driver for the Stock market AlphaVantage API. It uses a trick to define API calls without having to actually implement them. That could serve as an inspiration:

https://github.com/tariqdaouda/pyAlphaVantage/blob/master/pyAlphaVantageAPI/AlphaVantageAPI.py

dilipvamsi commented 5 years ago

Okay, I will look into it.

tariqdaouda commented 5 years ago

Thanks

dilipvamsi commented 5 years ago

Hi @tariqdaouda @Simran-B , Please check the pull request(https://github.com/ArangoDB-Community/pyArango/pull/155) which has the implementation for action in Connection and DB, which can be later used for creating functions which represent the rest apis provided by ArangoDB.