snyk-labs / pysnyk

A Python client for the Snyk API.
https://snyk.docs.apiary.io/
MIT License
88 stars 116 forks source link

[BUG]: imageCluster not available from projects lists #199

Closed steven-hadfield closed 10 months ago

steven-hadfield commented 1 year ago

Is there an existing issue for this?

Description of the bug

imageCluster as a project attribute was removed as part of the transition to the REST API projects list endpoint ( https://github.com/snyk-labs/pysnyk/commit/279e315e2f2b9ca6b70f24bb49085bae9e96c40c#diff-0ee8050625a6c754525c3c7abd7e7033907af25a74c1e4f7c8508219310bb099L583 ). The result is that attempts to use the imageCluster is not unavailable with pysnyk > 0.9.6

Steps To Reproduce

  1. Retrieve list of all projects for a given organization
  2. Iterate over the list an attempt to use the imageCluster attribute

Example:

client = SnykClient(token='...')
org_id = '...'
projects = client.organizations.get(org_id).projects.all()
for project in projects:
    if project.origin == 'kubernetes':
        print(project.imageCluster)

Result 0.9.7+ AttributeError: 'Project' object has no attribute 'imageCluster'

Additional Information

The new REST API added support for the image cluster metadata the last week of September within data[i].relationships.target.data.meta.integration_data.cluster and so would like to have that attribute available again to maintain feature parity with 0.9.6.

lili2311 commented 1 year ago

Hi @steven-hadfield I've included imageCluster in the latest release, could you confirm this is now working as expected for you?

steven-hadfield commented 1 year ago

Thanks @lili2311 I tried the example above and the error still occurs. I reviewed the MR that was merged and I saw that the data is incorporated from the list operation, but the imageCluster still isn't an attribute available on the Project model.

lili2311 commented 1 year ago

thats my bad, please try again? This is working for me locally https://github.com/snyk-labs/pysnyk/releases/tag/v0.9.16

steven-hadfield commented 10 months ago

Sorry for the delayed response, but it appears to be working. Thanks!