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 flag `exist_ok` when creating project #123

Closed DavidHuebner closed 2 years ago

DavidHuebner commented 2 years ago

Is your feature request related to a problem? Please describe. Frequently, we have the following code block to get/create a project depending on whether it already exists or needs to be created:

if client.exists_project("test_project"):
    project = client.get_project("test_project")
else:
    project = client.create_project("test_project")

Describe the solution you'd like The new flag exist_ok in create_project() should encapsulate this logic and (if set to true) should create a project if it does not exist yet and return the existing project otherwise.

Additional context I am not sure if this flag is helpful for document_collection, pipeline or process as well.