blackducksoftware / hub-rest-api-python

HUB REST API Python bindings
Apache License 2.0
89 stars 104 forks source link

Adding convenience methods for getting or creating objects #220

Open gsnyder2007 opened 2 years ago

gsnyder2007 commented 2 years ago

Finally getting back to providing these convenience methods for,

  1. Getting an object by a field value, e.g. name="the name" or versionName="the version name" or etc
  2. Getting or Creating an object by a field value, e.g. name="the name" and if one doesn't exist, create it

@admacdonald1 you will recognize your suggested code for the get_resource_by() method. I've also attempted a get_or_create_by() and have included some sample code that uses it - see crud_project.py, crud_version.py, and update_version_settings.py (all in the .../examples/client folder).

I set the version for this proposal to v1.1.0 since it's a minor improvement to the actual interface (as opposed to a simple fix).

Let me know your thoughts.