Deepomatic / deepomatic-client-python

Python Client
Other
14 stars 0 forks source link

Allow to use the same client for multiple users #92

Open maingoh opened 3 years ago

maingoh commented 3 years ago

This would allow to use the same requests.Session with multiple users. This imply overriding the api key while doing the request.

Probably we should have an interface like this:

user = Client(host=host).User(api_key=api_key)
user.RecognitionSpec.retrieve()

Or

client = Client(host=host)
user = User(client=client, api_key=api_key)
user.RecognitionSpec.retrieve()

It might be a breaking changes. We could somehow make it retrocompatible though.

vdel commented 3 years ago

Why is it necessary? Why does it make things easier for user?

maingoh commented 3 years ago

It makes things easier for us. Caching a client for each user is not very convenient and optimized. The change for a single user is not very complicated also. We can also try to be retrocompatible, keep the previous auth for single user:

client = Client(api_key=api_key, host=host)

For multiple users:

session = Session(host=host)
user = session.user(api_key=api_key)
vdel commented 3 years ago

I believe you but can you be more specific about easier for us ? In what context do you need to handle multiple users with one client ?

The only use-case I see so far is Vesta when performing actions on Vulcan on behalf of a user ?

maingoh commented 3 years ago

Another use case is the customer api forwarding some requests to api.deepomatic.com using different api keys.

This is not urgent anyway, we are caching one client per user for now.