Skip to content

Support Organization/Repository custom properties#2968

Merged
EnricoMi merged 19 commits intoPyGithub:mainfrom
jackylamhk:feat/repo-custom-properties
Jul 28, 2024
Merged

Support Organization/Repository custom properties#2968
EnricoMi merged 19 commits intoPyGithub:mainfrom
jackylamhk:feat/repo-custom-properties

Conversation

@jackylamhk
Copy link
Copy Markdown
Contributor

@jackylamhk jackylamhk commented May 13, 2024

Fixes #2895.

Copy link
Copy Markdown
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown

@hnavarro-kernet hnavarro-kernet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind implementing organization custom properties?
https://docs.github.com/en/rest/orgs/custom-properties

If not don't doubt to tag me in, I'd love this feature as my org recently moved to Github and find this valuable.

Thank you for your work!

"""
url = f"{self.url}/properties/values"
_, data = self._requester.requestJsonAndCheck("GET", url)
return {p["property_name"]: p["value"] for p in data}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would return the data directly as expected by the docs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the repo / and /properties/values return different schemas - I would prefer sticking to dict[str, *] to make it easier to work with. Let me know if you think otherwise :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue I think can of is if GitHub decides to expand the dict with more properties - but otherwise this would make the API easier to work with.

@hnavarro-kernet
Copy link
Copy Markdown

Closes #2895

@jackylamhk
Copy link
Copy Markdown
Contributor Author

jackylamhk commented May 22, 2024

Would you mind implementing organization custom properties? https://docs.github.com/en/rest/orgs/custom-properties

If not don't doubt to tag me in, I'd love this feature as my org recently moved to Github and find this valuable.

Thank you for your work!

Done - didn't realize it's already returned in the root GET. You're welcome!

@jackylamhk jackylamhk changed the title feat: Repository custom properties methods feat: Repository custom properties May 22, 2024
@hnavarro-kernet
Copy link
Copy Markdown

Would you mind implementing organization custom properties? https://docs.github.com/en/rest/orgs/custom-properties
If not don't doubt to tag me in, I'd love this feature as my org recently moved to Github and find this valuable.
Thank you for your work!

Done - didn't realize it's already returned in the root GET. You're welcome!

There might have been a misunderstanding here, I meant implementing Organization.get_custom_properties, not only Repository,get_custom_properties as mentioned in the docs: https://docs.github.com/en/rest/orgs/custom-properties

@jackylamhk jackylamhk changed the title feat: Repository custom properties feat: Organization/Repository custom properties May 24, 2024
@jackylamhk
Copy link
Copy Markdown
Contributor Author

Would you mind implementing organization custom properties? https://docs.github.com/en/rest/orgs/custom-properties
If not don't doubt to tag me in, I'd love this feature as my org recently moved to Github and find this valuable.
Thank you for your work!

Done - didn't realize it's already returned in the root GET. You're welcome!

There might have been a misunderstanding here, I meant implementing Organization.get_custom_properties, not only Repository,get_custom_properties as mentioned in the docs: https://docs.github.com/en/rest/orgs/custom-properties

My bad, I was looking at the issue you linked earlier. I've written a new OrganizationCustomProperty class and the get methods, let me know if it looks good; I'll finish writing the test cases and update methods.

Considering using the same class for the repo method returns too.

Copy link
Copy Markdown
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename the get_all_custom_properties method?

Copy link
Copy Markdown
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great if you could also add the same tests for Organization as you have added for Repository!

@EnricoMi EnricoMi changed the title feat: Organization/Repository custom properties Support Organization/Repository custom properties May 31, 2024
from github.GithubObject import Attribute, NonCompletableGithubObject, NotSet, Opt, is_optional


class CustomProperty:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this class to something less confusing (CustomProperty/OrganizationCustomProperty)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to make suggestions - can't come up with something simpler.

@notdodo
Copy link
Copy Markdown

notdodo commented Jul 8, 2024

any update on this?

@jackylamhk
Copy link
Copy Markdown
Contributor Author

any update on this?

Should be good to go pending review, just need a better name for the new classes.

Copy link
Copy Markdown
Collaborator

@EnricoMi EnricoMi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is not great, but cannot come up with anything more sane. Happy to refactor with better namer. LGTM!

@EnricoMi EnricoMi added this pull request to the merge queue Jul 28, 2024
Merged via the queue into PyGithub:main with commit c5e6b70 Jul 28, 2024
requester=self._requester,
headers=headers,
attributes=data,
completed=False,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackylamhk any particular reason you decided for completed=False here? Looks like GET {self.url}/properties/schema/{urllib.parse.quote(property_name)} should return the complete object, right?

Note that OrganizationCustomProperty is a NonCompletableGithubObject, which cannot be completed anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly - I can't recall why I did that, but I think you might be right. It could be that the API doesn't return all the attributes as I see a few optional ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support properties for repositories

4 participants