ohioit / ansible-collection-github

Ansible Collection for GitHub
GNU General Public License v3.0
0 stars 2 forks source link

Repo Information Module #1

Open robert4man opened 3 years ago

robert4man commented 3 years ago

As an Ansible user I want to fetch information about repositories I have access to for use in loops. Scope should be limited to an org. Should return a list of dicts containing information about each repository such as name, owner, description, private, is_template, archived, language, visibility, and url.

Reference: https://docs.github.com/en/rest/reference/repos#list-organization-repositories

ikogan commented 3 years ago

I'd like this to be filterable by some of these attributes, for example, name, is_template, archived, owner, and private as well. Additionally, the structure of the output should match, as much as is reasonable, the output from the API itself so it's easier to understand from reading docs. I think a few other fields may be immediately useful, for example:

I mean, should we just return the entire JSON dict we get from json.loads() rather than filtering the fields?

robert4man commented 3 years ago

There is a lot more in the JSON than we will want or need, and I didn't want the payload getting too large. We are expecting several hundred repositories and the primary intent for this module is to fetch a list of repositories for loops, but a few key data points seem obviously useful. Adding more later should not be terribly difficult.

ikogan commented 3 years ago

The URLs it gives you, for example, are also useful for things like subsequent calls. For example, get a list of your repos, iterate over each and use the branches_url to pull down the branches, or the git_url to clone them. Maybe you want to make a change to each but you don't have all the permissions so you can use permissions.push. The payload is going to come back whether you like it or not, you can't tell the API to limit certain fields as far as I can see. The API is already paginated so the payload is going to be limited per call. Speaking of which, that kind of begs for returning an Iterable of dicts instead of a list.

Also, is it better to use https://pygithub.readthedocs.io/en/latest/introduction.html rather than querying the API directly?

robert4man commented 3 years ago

We will probably end up using PyGithub for all of these modules. I am simply providing the GitHub API docs for reference.