averbis / averbis-python-api

Conveniently access the REST API of Averbis products using Python
Apache License 2.0
12 stars 4 forks source link

Add support for experimental textanalysis resource api #70

Closed nadre closed 3 years ago

nadre commented 3 years ago

Is your feature request related to a problem? Please describe. I want to be able to upload (zip), download (zip), list (json) and delete the resources of the global product, a project or a pipeline.

Describe the solution you'd like I would add a Resources class that implements the methods and can be generated by:

resources = client.get_global_textanalysis_resources()
resources = project.get_textanalysis_resources()
resources = pipeline.get_textanalysis_resources()

 # and then

> resources.list()
> ['model.hd5f', 'some.dict']

> resources.upload_file(source='/some/dir/my_file.txt')
> ['my_resource.txt']

> resources.upload_file(source='/some/dir/my_file.txt', target_path='dir1/dir2')
> ['dir1/dir2/my_resource.txt']

> resources.upload_zip(source='/some/dir/resources.zip')
> [** content of zip **]

> resources.upload_folder(source='/some/dir/)
> [** content of folder **]

> resources.download_zip(target='/some/dir/resources.zip')
> ** download a zip containing all resources **

> resources.delete()
> []

Describe alternatives you've considered Use curl and zip the stuff by yourself.

Additional context It's all experimental!

These are the endpoints that need to be implemented: image

nadre commented 3 years ago

The methods:

> resources.upload_file(source='/some/dir/my_file.txt')
> ['my_resource.txt']

> resources.upload_file(source='/some/dir/my_file.txt', target_path='dir1/dir2')
> ['dir1/dir2/my_resource.txt']

> resources.upload_zip(source='/some/dir/resources.zip')
> [** content of zip **]

> resources.upload_folder(source='/some/dir/)
> [** content of folder **]

can be reduced to one method upload()

nadre commented 3 years ago

This method is quite drastic, better rename it to delete_all()

> resources.delete()
> []
nadre commented 3 years ago

No need for the Resources class, better call

list_resources()
upload_resources()
download_resources()
delete_all_resources()

on client, project, pipeline

Philly-B commented 3 years ago

@reckart This issues pull request is ready for review, let me know if anything is missing.

Philly-B commented 3 years ago

Maybe @DavidHuebner can do the review as well.