diff --git a/github/models/owner.py b/github/models/owner.py new file mode 100644 index 0000000..70dcaea --- /dev/null +++ b/github/models/owner.py @@ -0,0 +1,68 @@ +from typing import Any + +class GitHubOwner: + def __init__( + self, + login: str, + id: int, + node_id: str, + avatar_url: str, + gravatar_id: str, + url: str, + html_url: str, + followers_url: str, + following_url: str, + gists_url: str, + starred_url: str, + subscriptions_url: str, + organizations_url: str, + repos_url: str, + events_url: str, + received_events_url: str, + type: str, + user_view_type: str, + site_admin: bool + ): + self.login: str = login + self.id: int = id + self.node_id: str = node_id + self.avatar_url: str = avatar_url + self.gravatar_id: str = gravatar_id + self.url: str = url + self.html_url: str = html_url + self.followers_url: str = followers_url + self.following_url: str = following_url + self.gists_url: str = gists_url + self.starred_url: str = starred_url + self.subscriptions_url: str = subscriptions_url + self.organizations_url: str = organizations_url + self.repos_url: str = repos_url + self.events_url: str = events_url + self.received_events_url: str = received_events_url + self.type: str = type + self.user_view_type: str = user_view_type + self.site_admin: bool = site_admin + + @classmethod + def from_dict(cls, data: Any): + return cls( + data['login'], + data['id'], + data['node_id'], + data['avatar_url'], + data['gravatar_id'], + data['url'], + data['html_url'], + data['followers_url'], + data['following_url'], + data['gists_url'], + data['starred_url'], + data['subscriptions_url'], + data['organizations_url'], + data['repos_url'], + data['events_url'], + data['received_events_url'], + data['type'], + data['user_view_type'], + data['site_admin'] + ) diff --git a/github/models/repo_permissions.py b/github/models/repo_permissions.py new file mode 100644 index 0000000..9095235 --- /dev/null +++ b/github/models/repo_permissions.py @@ -0,0 +1,11 @@ + + +class GitHubRepoPermissions: + def __init__( + self, + admin: bool, + maintain: bool, + push: bool, + triage: bool, + pull: bool + ): \ No newline at end of file diff --git a/github/models/repository.py b/github/models/repository.py new file mode 100644 index 0000000..3d12da6 --- /dev/null +++ b/github/models/repository.py @@ -0,0 +1,85 @@ +from typing import Any, List +from github.models.owner import GitHubOwner + +class GitHubRepository: + def __init__( + self, + id: int, + node_id: str, + name: str, + full_name: str, + private: bool, + owner: GitHubOwner, + html_url: str, + description: str, + fork: bool, + url: str, + forks_url: str, + keys_url: str, + collaborators_url: str, + teams_url: str, + hooks_url: str, + issue_events_url: str, + events_url: str, + assignees_url: str, + branches_url: str, + tags_url: str, + blobs_url: str, + git_tags_url: str, + git_refs_url: str, + trees_url: str, + statuses_url: str, + languages_url: str, + stargazers_url: str, + contributors_url: str, + cubscribers_url: str, + subscription_url: str, + commits_url: str, + issue_comment_url: str, + contents_url: str, + compare_url: str, + merges_url: str, + archive_url: str, + downloads_url: str, + issues_url: str, + pulls_url: str, + milestones_url: str, + notifications_url: str, + labels_url: str, + releases_url: str, + deployments_url: str, + created_at: str, + updated_at: str, + pushed_at: str, + git_url: str, + ssh_url: str, + clone_url: str, + svn_url: str, + homepage: Any, + size: int, + stargazers_count: int, + watchers_count: int, + language: str, + has_issues: bool, + has_projects: bool, + has_downloads: bool, + has_wiki: bool, + has_pages: bool, + has_discussions: bool, + forks_count: int, + mirror_url: str, + archived: bool, + disabled: bool, + open_issues_count: int, + license: str, + allow_forking: bool, + is_template: bool, + web_commit_signoff_required: bool, + topics: List[Any], + visibility: str, + forks: int, + open_issues: int, + watchers: int, + default_branch: str, + permissions: GitHubRepoPermissions + ) \ No newline at end of file diff --git a/github/repos.py b/github/repos.py index 3430ca4..59ffeb8 100644 --- a/github/repos.py +++ b/github/repos.py @@ -50,13 +50,19 @@ def __request_repos_for_user(username: str) -> List[Any]: return repos def insert_repo(repo): + """Insert a repo into the database. + + Args: + repo (_type_): _description_ + """ + repo_id = str(uuid.uuid4()) with DatabaseManager() as db: db.execute(''' - INSERT INTO repositories (id, name, url) - VALUES (?, ?, ?) - ''', (repo_id, repo['name'], repo['html_url']) - ) + INSERT INTO repositories (id, name, url) + VALUES (?, ?, ?) + ''', (repo_id, repo['name'], repo['html_url']) + ) def user_repos_report(username: str): """Handle reporting GitHub repos for user @@ -85,12 +91,16 @@ def user_repos_report(username: str): console.print(table) def handle_args(args): + """Handle args for repo commands + Args: + args (_type_): _description_ + """ if args.report == 'list': user_repos_report(args.user) - + if args.report == 'workflows': wfs = __request_repo_workflows(owner = 'meddlin', repo = 'github-inventory') for w in wfs: workflow = GitHubWorkflow.from_dict(w) - print(workflow.name) \ No newline at end of file + print(workflow.name)