blackducksoftware / hub-rest-api-python

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

Question : find a resource based on its internal id #227

Closed TristanFAURE closed 4 months ago

TristanFAURE commented 1 year ago

Hello all first thank you for this python library very convenient and useful. I have a question about getting a ressource from its internal id.

I found a workaround using get_json method:

bd = Client(base_url=args.url, token=args.token)
json = bd.get_json(f'api/components/{component_id}')

But I would prefer to not be dependent to the URL structure I would prefer something like that but I did not succeed to write the correct query:

bd = Client(base_url=args.url, token=args.token)
params = {
        'q': [f"<someting_UUID_guid???>:{component}"],
        'limit': 1
}
components = [c for c in bd.get_resource('components', params=params) if c['<someting_UUID_guid???>'] == component]

Is it possible to have the unique id as a parameter of the query ? If not is it possible to add it ? Regards

OffBy0x01 commented 1 year ago

Although there are some blackduck folks among us maintainers, for product enhancements & feedback you'd be better off reaching out to Sig support or your technical account manager.

That said, the API is not designed to work that way, it would require fundamental changes which we are unlikely to see.

There are very few scenarios where you'd need to cut and paste uuids, have you considered just using the full url for each resource? It is available via the built-inhref field.

TristanFAURE commented 1 year ago

Thanks for your answer Yes I will reach my support team.

Actually why I wanted to use uuid is because I want to implement an export / import process : as a user I export blackduck data in csv format as a user i edit the csv to update values (particularly custom fields) as a user i run a script to import updated data.

Because uuids are generated in the blackduck csv report it was convenient for me to reuse them to find my objects to update