blackducksoftware / hub-rest-api-python

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

resource name 'project-groups' not found in available resources #266

Closed urld closed 5 months ago

urld commented 5 months ago

I am trying to iterate through all projects that belong to certain project groups, that are known by name. e.g. client.get_resource("project-groups"). Hovewer i am just getting the following error, since project-groups is not listed in the root api request for some reason.

resource name 'project-groups' not found in available resources
...
  File "C:\Users\durl\AppData\Local\Programs\Python\Python311\Lib\site-packages\blackduck\Client.py", line 173, in get_resource
    raise KeyError(msg)
KeyError: "resource name 'project-groups' not found in available resources"

If i handcraft a request to /api/project-groups however, i get a valid response.

Is there some way to skip the validation of the listed resources? I dont really get why the list is not complete, even though the resources are accessible if i just ignore the root endpoint.

Black Duck REST API: 2023.7.2 pip: blackduck 1.1.0

OffBy0x01 commented 5 months ago

This is often the case with private/internal resources; as there is no guarantee of the endpoint's support/continuity they are not added to the resource list.The get_resource handler is specifically designed to perform these checks and this wont change anytime soon.

However, get_resource is just a wrapper for get_items & get_json which can be used the way you expect. Use get_items if you'd like it as a paginated generator or get_json for the raw json response.