pyArango icon indicating copy to clipboard operation
pyArango copied to clipboard

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

Open Simran-B opened this issue 7 years ago • 5 comments

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.

Simran-B avatar Jul 20 '18 14:07 Simran-B

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'}
)

dilipvamsi avatar Jun 02 '19 16:06 dilipvamsi

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

tariqdaouda avatar Jun 03 '19 04:06 tariqdaouda

Okay, I will look into it.

dilipvamsi avatar Jun 03 '19 06:06 dilipvamsi

Thanks

tariqdaouda avatar Jun 06 '19 18:06 tariqdaouda

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.

dilipvamsi avatar Jun 10 '19 10:06 dilipvamsi