PyGithub-asyncio 3.0.0b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- githubasyncio/AccessToken.py +159 -0
- githubasyncio/AdvisoryBase.py +163 -0
- githubasyncio/AdvisoryCredit.py +131 -0
- githubasyncio/AdvisoryCreditDetailed.py +110 -0
- githubasyncio/AdvisoryVulnerability.py +191 -0
- githubasyncio/AdvisoryVulnerabilityPackage.py +93 -0
- githubasyncio/AppAuthentication.py +58 -0
- githubasyncio/ApplicationOAuth.py +200 -0
- githubasyncio/Artifact.py +183 -0
- githubasyncio/Auth.py +560 -0
- githubasyncio/AuthenticatedUser.py +1251 -0
- githubasyncio/Authorization.py +192 -0
- githubasyncio/AuthorizationApplication.py +73 -0
- githubasyncio/Autolink.py +104 -0
- githubasyncio/Branch.py +689 -0
- githubasyncio/BranchProtection.py +224 -0
- githubasyncio/CVSS.py +83 -0
- githubasyncio/CWE.py +75 -0
- githubasyncio/CheckRun.py +315 -0
- githubasyncio/CheckRunAnnotation.py +134 -0
- githubasyncio/CheckRunOutput.py +108 -0
- githubasyncio/CheckSuite.py +319 -0
- githubasyncio/Clones.py +97 -0
- githubasyncio/CodeScanAlert.py +215 -0
- githubasyncio/CodeScanAlertInstance.py +134 -0
- githubasyncio/CodeScanAlertInstanceLocation.py +102 -0
- githubasyncio/CodeScanRule.py +134 -0
- githubasyncio/CodeScanTool.py +94 -0
- githubasyncio/CodeSecurityConfig.py +301 -0
- githubasyncio/CodeSecurityConfigRepository.py +70 -0
- githubasyncio/Commit.py +442 -0
- githubasyncio/CommitCombinedStatus.py +126 -0
- githubasyncio/CommitComment.py +270 -0
- githubasyncio/CommitStats.py +78 -0
- githubasyncio/CommitStatus.py +169 -0
- githubasyncio/Comparison.py +219 -0
- githubasyncio/Consts.py +197 -0
- githubasyncio/ContentFile.py +304 -0
- githubasyncio/Copilot.py +97 -0
- githubasyncio/CopilotSeat.py +132 -0
- githubasyncio/DefaultCodeSecurityConfig.py +93 -0
- githubasyncio/DependabotAlert.py +184 -0
- githubasyncio/DependabotAlertAdvisory.py +82 -0
- githubasyncio/DependabotAlertDependency.py +100 -0
- githubasyncio/DependabotAlertVulnerability.py +85 -0
- githubasyncio/Deployment.py +314 -0
- githubasyncio/DeploymentBranchPolicy.py +102 -0
- githubasyncio/DeploymentStatus.py +201 -0
- githubasyncio/DiscussionBase.py +140 -0
- githubasyncio/DiscussionCommentBase.py +140 -0
- githubasyncio/Download.py +256 -0
- githubasyncio/Enterprise.py +175 -0
- githubasyncio/EnterpriseConsumedLicenses.py +138 -0
- githubasyncio/Environment.py +354 -0
- githubasyncio/EnvironmentDeploymentBranchPolicy.py +87 -0
- githubasyncio/EnvironmentProtectionRule.py +117 -0
- githubasyncio/EnvironmentProtectionRuleReviewer.py +110 -0
- githubasyncio/Event.py +134 -0
- githubasyncio/File.py +142 -0
- githubasyncio/GeneratedReleaseNotes.py +68 -0
- githubasyncio/Gist.py +373 -0
- githubasyncio/GistComment.py +162 -0
- githubasyncio/GistFile.py +106 -0
- githubasyncio/GistHistoryState.py +245 -0
- githubasyncio/GitAuthor.py +94 -0
- githubasyncio/GitBlob.py +123 -0
- githubasyncio/GitCommit.py +208 -0
- githubasyncio/GitCommitVerification.py +103 -0
- githubasyncio/GitObject.py +84 -0
- githubasyncio/GitRef.py +122 -0
- githubasyncio/GitRelease.py +476 -0
- githubasyncio/GitReleaseAsset.py +232 -0
- githubasyncio/GitTag.py +143 -0
- githubasyncio/GitTree.py +113 -0
- githubasyncio/GitTreeElement.py +104 -0
- githubasyncio/GithubApp.py +236 -0
- githubasyncio/GithubException.py +226 -0
- githubasyncio/GithubIntegration.py +365 -0
- githubasyncio/GithubObject.py +910 -0
- githubasyncio/GithubRetry.py +253 -0
- githubasyncio/GitignoreTemplate.py +88 -0
- githubasyncio/GlobalAdvisory.py +141 -0
- githubasyncio/Hook.py +238 -0
- githubasyncio/HookDelivery.py +243 -0
- githubasyncio/HookDescription.py +85 -0
- githubasyncio/HookResponse.py +83 -0
- githubasyncio/InputFileContent.py +63 -0
- githubasyncio/InputGitAuthor.py +71 -0
- githubasyncio/InputGitTreeElement.py +79 -0
- githubasyncio/Installation.py +298 -0
- githubasyncio/InstallationAuthorization.py +138 -0
- githubasyncio/Invitation.py +171 -0
- githubasyncio/Issue.py +955 -0
- githubasyncio/IssueComment.py +309 -0
- githubasyncio/IssueDependenciesSummary.py +77 -0
- githubasyncio/IssueEvent.py +296 -0
- githubasyncio/IssuePullRequest.py +97 -0
- githubasyncio/IssueType.py +123 -0
- githubasyncio/Label.py +186 -0
- githubasyncio/License.py +169 -0
- githubasyncio/MainClass.py +1142 -0
- githubasyncio/Membership.py +154 -0
- githubasyncio/MergedUpstream.py +71 -0
- githubasyncio/Migration.py +281 -0
- githubasyncio/Milestone.py +255 -0
- githubasyncio/NamedEnterpriseUser.py +207 -0
- githubasyncio/NamedUser.py +841 -0
- githubasyncio/Notification.py +182 -0
- githubasyncio/NotificationSubject.py +96 -0
- githubasyncio/Organization.py +2462 -0
- githubasyncio/OrganizationCodeScanAlert.py +65 -0
- githubasyncio/OrganizationCustomProperty.py +215 -0
- githubasyncio/OrganizationDependabotAlert.py +75 -0
- githubasyncio/OrganizationSecret.py +191 -0
- githubasyncio/OrganizationSecretScanAlert.py +112 -0
- githubasyncio/OrganizationVariable.py +141 -0
- githubasyncio/PaginatedList.py +652 -0
- githubasyncio/Path.py +102 -0
- githubasyncio/Permissions.py +113 -0
- githubasyncio/Plan.py +108 -0
- githubasyncio/Project.py +286 -0
- githubasyncio/ProjectCard.py +257 -0
- githubasyncio/ProjectColumn.py +227 -0
- githubasyncio/PublicKey.py +138 -0
- githubasyncio/PullRequest.py +1202 -0
- githubasyncio/PullRequestComment.py +401 -0
- githubasyncio/PullRequestMergeStatus.py +89 -0
- githubasyncio/PullRequestPart.py +110 -0
- githubasyncio/PullRequestReview.py +214 -0
- githubasyncio/Rate.py +123 -0
- githubasyncio/RateLimit.py +210 -0
- githubasyncio/RateLimitOverview.py +104 -0
- githubasyncio/Reaction.py +128 -0
- githubasyncio/Referrer.py +94 -0
- githubasyncio/RepoCodeSecurityConfig.py +93 -0
- githubasyncio/Repository.py +5211 -0
- githubasyncio/RepositoryAdvisory.py +431 -0
- githubasyncio/RepositoryDiscussion.py +221 -0
- githubasyncio/RepositoryDiscussionCategory.py +150 -0
- githubasyncio/RepositoryDiscussionComment.py +159 -0
- githubasyncio/RepositoryKey.py +166 -0
- githubasyncio/RepositoryPreferences.py +82 -0
- githubasyncio/RepositoryRulesetBypassActor.py +75 -0
- githubasyncio/Requester.py +1518 -0
- githubasyncio/RequiredPullRequestReviews.py +269 -0
- githubasyncio/RequiredStatusChecks.py +153 -0
- githubasyncio/Rule.py +134 -0
- githubasyncio/Ruleset.py +292 -0
- githubasyncio/Secret.py +139 -0
- githubasyncio/SecretScanAlert.py +317 -0
- githubasyncio/SecretScanAlertInstance.py +128 -0
- githubasyncio/SecurityAndAnalysis.py +188 -0
- githubasyncio/SecurityAndAnalysisFeature.py +79 -0
- githubasyncio/SelfHostedActionsRunner.py +129 -0
- githubasyncio/SelfHostedActionsRunnerApplication.py +92 -0
- githubasyncio/SelfHostedActionsRunnerJitConfig.py +74 -0
- githubasyncio/SelfHostedActionsRunnerToken.py +118 -0
- githubasyncio/SourceImport.py +260 -0
- githubasyncio/Stargazer.py +88 -0
- githubasyncio/StatsCodeFrequency.py +81 -0
- githubasyncio/StatsCommitActivity.py +86 -0
- githubasyncio/StatsContributor.py +138 -0
- githubasyncio/StatsParticipation.py +78 -0
- githubasyncio/StatsPunchCard.py +76 -0
- githubasyncio/SubIssueSummary.py +70 -0
- githubasyncio/Tag.py +108 -0
- githubasyncio/Team.py +618 -0
- githubasyncio/TeamDiscussion.py +137 -0
- githubasyncio/TimelineEvent.py +164 -0
- githubasyncio/TimelineEventSource.py +81 -0
- githubasyncio/Topic.py +177 -0
- githubasyncio/Traffic.py +95 -0
- githubasyncio/UserKey.py +141 -0
- githubasyncio/Variable.py +155 -0
- githubasyncio/View.py +97 -0
- githubasyncio/Workflow.py +335 -0
- githubasyncio/WorkflowJob.py +253 -0
- githubasyncio/WorkflowRun.py +480 -0
- githubasyncio/WorkflowStep.py +118 -0
- githubasyncio/__init__.py +38 -0
- githubasyncio/compat/__init__.py +52 -0
- githubasyncio/requestlib/__init__.py +29 -0
- pygithub_asyncio-3.0.0b1.dist-info/METADATA +102 -0
- pygithub_asyncio-3.0.0b1.dist-info/RECORD +188 -0
- pygithub_asyncio-3.0.0b1.dist-info/WHEEL +5 -0
- pygithub_asyncio-3.0.0b1.dist-info/licenses/COPYING +674 -0
- pygithub_asyncio-3.0.0b1.dist-info/licenses/COPYING.LESSER +165 -0
- pygithub_asyncio-3.0.0b1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1142 @@
|
|
|
1
|
+
# FILE AUTO GENERATED DO NOT TOUCH
|
|
2
|
+
############################ Copyrights and license ############################
|
|
3
|
+
# #
|
|
4
|
+
# Copyright 2012 Dima Kukushkin <dima@kukushkin.me> #
|
|
5
|
+
# Copyright 2012 Luke Cawood <luke.cawood@99designs.com> #
|
|
6
|
+
# Copyright 2012 Michael Woodworth <mwoodworth@upverter.com> #
|
|
7
|
+
# Copyright 2012 Steve English <steve.english@navetas.com> #
|
|
8
|
+
# Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
|
|
9
|
+
# Copyright 2012 Zearin <zearin@gonk.net> #
|
|
10
|
+
# Copyright 2013 AKFish <akfish@gmail.com> #
|
|
11
|
+
# Copyright 2013 Ed Jackson <ed.jackson@gmail.com> #
|
|
12
|
+
# Copyright 2013 Jonathan J Hunt <hunt@braincorporation.com> #
|
|
13
|
+
# Copyright 2013 Steve Brown <steve@evolvedlight.co.uk> #
|
|
14
|
+
# Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
|
|
15
|
+
# Copyright 2014 C. R. Oldham <cro@ncbt.org> #
|
|
16
|
+
# Copyright 2014 Thialfihar <thi@thialfihar.org> #
|
|
17
|
+
# Copyright 2014 Tyler Treat <ttreat31@gmail.com> #
|
|
18
|
+
# Copyright 2014 Vincent Jacques <vincent@vincent-jacques.net> #
|
|
19
|
+
# Copyright 2015 Daniel Pocock <daniel@pocock.pro> #
|
|
20
|
+
# Copyright 2015 Joseph Rawson <joseph.rawson.works@littledebian.org> #
|
|
21
|
+
# Copyright 2015 Uriel Corfa <uriel@corfa.fr> #
|
|
22
|
+
# Copyright 2016 Jannis Gebauer <ja.geb@me.com> #
|
|
23
|
+
# Copyright 2016 Peter Buckley <dx-pbuckley@users.noreply.github.com> #
|
|
24
|
+
# Copyright 2017 Colin Hoglund <colinhoglund@users.noreply.github.com> #
|
|
25
|
+
# Copyright 2017 Jannis Gebauer <ja.geb@me.com> #
|
|
26
|
+
# Copyright 2018 Agor Maxime <maxime.agor23@gmail.com> #
|
|
27
|
+
# Copyright 2018 Arda Kuyumcu <kuyumcuarda@gmail.com> #
|
|
28
|
+
# Copyright 2018 Benoit Latinier <benoit@latinier.fr> #
|
|
29
|
+
# Copyright 2018 Bruce Richardson <itsbruce@workshy.org> #
|
|
30
|
+
# Copyright 2018 Joshua Hoblitt <josh@hoblitt.com> #
|
|
31
|
+
# Copyright 2018 Maarten Fonville <mfonville@users.noreply.github.com> #
|
|
32
|
+
# Copyright 2018 Mike Miller <github@mikeage.net> #
|
|
33
|
+
# Copyright 2018 Shubham Singh <41840111+singh811@users.noreply.github.com> #
|
|
34
|
+
# Copyright 2018 Steve Kowalik <steven@wedontsleep.org> #
|
|
35
|
+
# Copyright 2018 Svend Sorensen <svend@svends.net> #
|
|
36
|
+
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
|
|
37
|
+
# Copyright 2018 Yossarian King <yggy@blackbirdinteractive.com> #
|
|
38
|
+
# Copyright 2018 h.shi <10385628+AnYeMoWang@users.noreply.github.com> #
|
|
39
|
+
# Copyright 2018 sfdye <tsfdye@gmail.com> #
|
|
40
|
+
# Copyright 2019 Adam Baratz <adam.baratz@gmail.com> #
|
|
41
|
+
# Copyright 2019 Caleb Sweeney <caleb.w.sweeney@gmail.com> #
|
|
42
|
+
# Copyright 2019 Hamel Husain <hamelsmu@github.com> #
|
|
43
|
+
# Copyright 2019 Isac Souza <isouza@daitan.com> #
|
|
44
|
+
# Copyright 2019 Jake Klingensmith <jklingen92@users.noreply.github.com> #
|
|
45
|
+
# Copyright 2019 Jake Wilkins <jakewilkins@github.com> #
|
|
46
|
+
# Copyright 2019 Rigas Papathanasopoulos <rigaspapas@gmail.com> #
|
|
47
|
+
# Copyright 2019 Steve Kowalik <steven@wedontsleep.org> #
|
|
48
|
+
# Copyright 2019 Tomas Tomecek <nereone@gmail.com> #
|
|
49
|
+
# Copyright 2019 Wan Liuyang <tsfdye@gmail.com> #
|
|
50
|
+
# Copyright 2019 chillipeper <miguel.tpy@gmail.com> #
|
|
51
|
+
# Copyright 2019 秋葉 <ambiguous404@gmail.com> #
|
|
52
|
+
# Copyright 2020 Alice GIRARD <bouhahah@gmail.com> #
|
|
53
|
+
# Copyright 2020 Denis Blanchette <dblanchette@coveo.com> #
|
|
54
|
+
# Copyright 2020 Florent Clarret <florent.clarret@gmail.com> #
|
|
55
|
+
# Copyright 2020 Mahesh Raju <coder@mahesh.net> #
|
|
56
|
+
# Copyright 2020 Nikolay Edigaryev <edigaryev@gmail.com> #
|
|
57
|
+
# Copyright 2020 Omar Brikaa <brikaaomar@gmail.com> #
|
|
58
|
+
# Copyright 2020 Steve Kowalik <steven@wedontsleep.org> #
|
|
59
|
+
# Copyright 2021 Amador Pahim <apahim@redhat.com> #
|
|
60
|
+
# Copyright 2021 Mark Walker <mark.walker@realbuzz.com> #
|
|
61
|
+
# Copyright 2021 Sachi King <nakato@nakato.io> #
|
|
62
|
+
# Copyright 2021 Steve Kowalik <steven@wedontsleep.org> #
|
|
63
|
+
# Copyright 2023 Denis Blanchette <dblanchette@coveo.com> #
|
|
64
|
+
# Copyright 2023 Enrico Minack <github@enrico.minack.dev> #
|
|
65
|
+
# Copyright 2023 Hemslo Wang <hemslo.wang@gmail.com> #
|
|
66
|
+
# Copyright 2023 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
|
|
67
|
+
# Copyright 2023 Jonathan Greg <31892308+jmgreg31@users.noreply.github.com> #
|
|
68
|
+
# Copyright 2023 Joseph Henrich <crimsonknave@gmail.com> #
|
|
69
|
+
# Copyright 2023 Mark Amery <markamery@btinternet.com> #
|
|
70
|
+
# Copyright 2023 Trim21 <trim21.me@gmail.com> #
|
|
71
|
+
# Copyright 2023 YugoHino <henom06@gmail.com> #
|
|
72
|
+
# Copyright 2023 chantra <chantra@users.noreply.github.com> #
|
|
73
|
+
# Copyright 2024 Enrico Minack <github@enrico.minack.dev> #
|
|
74
|
+
# Copyright 2024 Jirka Borovec <6035284+Borda@users.noreply.github.com> #
|
|
75
|
+
# Copyright 2024 Min RK <benjaminrk@gmail.com> #
|
|
76
|
+
# Copyright 2025 Aidan McNay <acm289@cornell.edu> #
|
|
77
|
+
# Copyright 2025 Enrico Minack <github@enrico.minack.dev> #
|
|
78
|
+
# Copyright 2025 blyedev <63808441+blyedev@users.noreply.github.com> #
|
|
79
|
+
# Copyright 2025 xmo-odoo <xmo@odoo.com> #
|
|
80
|
+
# Copyright 2026 Enrico Minack <github@enrico.minack.dev> #
|
|
81
|
+
# Copyright 2026 Mikhail f. Shiryaev <mr.felixoid@gmail.com> #
|
|
82
|
+
# Copyright 2026 xmo-odoo <xmo@odoo.com> #
|
|
83
|
+
# #
|
|
84
|
+
# This file is part of PyGithub. #
|
|
85
|
+
# http://pygithub.readthedocs.io/ #
|
|
86
|
+
# #
|
|
87
|
+
# PyGithub is free software: you can redistribute it and/or modify it under #
|
|
88
|
+
# the terms of the GNU Lesser General Public License as published by the Free #
|
|
89
|
+
# Software Foundation, either version 3 of the License, or (at your option) #
|
|
90
|
+
# any later version. #
|
|
91
|
+
# #
|
|
92
|
+
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
|
|
93
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
|
|
94
|
+
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
|
|
95
|
+
# details. #
|
|
96
|
+
# #
|
|
97
|
+
# You should have received a copy of the GNU Lesser General Public License #
|
|
98
|
+
# along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
|
|
99
|
+
# #
|
|
100
|
+
################################################################################
|
|
101
|
+
|
|
102
|
+
from __future__ import annotations
|
|
103
|
+
|
|
104
|
+
import pickle
|
|
105
|
+
import urllib.parse
|
|
106
|
+
import warnings
|
|
107
|
+
from datetime import datetime
|
|
108
|
+
from typing import TYPE_CHECKING, Any, BinaryIO, TypeVar, overload
|
|
109
|
+
|
|
110
|
+
import githubasyncio.ApplicationOAuth
|
|
111
|
+
import githubasyncio.Auth
|
|
112
|
+
import githubasyncio.AuthenticatedUser
|
|
113
|
+
import githubasyncio.Commit
|
|
114
|
+
import githubasyncio.ContentFile
|
|
115
|
+
import githubasyncio.Enterprise
|
|
116
|
+
import githubasyncio.Event
|
|
117
|
+
import githubasyncio.Gist
|
|
118
|
+
import githubasyncio.GithubApp
|
|
119
|
+
import githubasyncio.GithubIntegration
|
|
120
|
+
import githubasyncio.GithubObject
|
|
121
|
+
import githubasyncio.GithubRetry
|
|
122
|
+
import githubasyncio.GitignoreTemplate
|
|
123
|
+
import githubasyncio.GlobalAdvisory
|
|
124
|
+
import githubasyncio.HookDelivery
|
|
125
|
+
import githubasyncio.HookDescription
|
|
126
|
+
import githubasyncio.Issue
|
|
127
|
+
import githubasyncio.License
|
|
128
|
+
import githubasyncio.NamedUser
|
|
129
|
+
import githubasyncio.Organization
|
|
130
|
+
import githubasyncio.PaginatedList
|
|
131
|
+
import githubasyncio.Project
|
|
132
|
+
import githubasyncio.ProjectColumn
|
|
133
|
+
import githubasyncio.Repository
|
|
134
|
+
import githubasyncio.RepositoryDiscussion
|
|
135
|
+
import githubasyncio.Topic
|
|
136
|
+
from githubasyncio import Consts
|
|
137
|
+
from githubasyncio.compat import deprecated
|
|
138
|
+
from githubasyncio.GithubIntegration import GithubIntegration
|
|
139
|
+
from githubasyncio.GithubObject import (
|
|
140
|
+
CompletableGithubObject,
|
|
141
|
+
GithubObject,
|
|
142
|
+
NotSet,
|
|
143
|
+
Opt,
|
|
144
|
+
_NotSetType,
|
|
145
|
+
is_defined,
|
|
146
|
+
is_undefined,
|
|
147
|
+
)
|
|
148
|
+
from githubasyncio.GithubRetry import GithubRetry
|
|
149
|
+
from githubasyncio.PaginatedList import PaginatedList
|
|
150
|
+
from githubasyncio.Requester import Requester
|
|
151
|
+
from githubasyncio.requestlib import Retry
|
|
152
|
+
|
|
153
|
+
if TYPE_CHECKING:
|
|
154
|
+
from githubasyncio.AppAuthentication import AppAuthentication
|
|
155
|
+
from githubasyncio.ApplicationOAuth import ApplicationOAuth
|
|
156
|
+
from githubasyncio.Auth import Auth
|
|
157
|
+
from githubasyncio.AuthenticatedUser import AuthenticatedUser
|
|
158
|
+
from githubasyncio.Commit import CommitSearchResult
|
|
159
|
+
from githubasyncio.ContentFile import ContentFileSearchResult
|
|
160
|
+
from githubasyncio.Enterprise import Enterprise
|
|
161
|
+
from githubasyncio.Event import Event
|
|
162
|
+
from githubasyncio.Gist import Gist
|
|
163
|
+
from githubasyncio.GithubApp import GithubApp
|
|
164
|
+
from githubasyncio.GitignoreTemplate import GitignoreTemplate
|
|
165
|
+
from githubasyncio.GlobalAdvisory import GlobalAdvisory
|
|
166
|
+
from githubasyncio.HookDelivery import HookDelivery, HookDeliverySummary
|
|
167
|
+
from githubasyncio.HookDescription import HookDescription
|
|
168
|
+
from githubasyncio.Issue import IssueSearchResult
|
|
169
|
+
from githubasyncio.License import License
|
|
170
|
+
from githubasyncio.NamedUser import NamedUser, NamedUserSearchResult
|
|
171
|
+
from githubasyncio.Organization import Organization
|
|
172
|
+
from githubasyncio.Project import Project
|
|
173
|
+
from githubasyncio.ProjectColumn import ProjectColumn
|
|
174
|
+
from githubasyncio.RateLimitOverview import RateLimitOverview
|
|
175
|
+
from githubasyncio.Repository import Repository, RepositorySearchResult
|
|
176
|
+
from githubasyncio.RepositoryDiscussion import RepositoryDiscussion
|
|
177
|
+
from githubasyncio.Topic import Topic
|
|
178
|
+
|
|
179
|
+
TGithubObject = TypeVar("TGithubObject", bound=GithubObject)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
class Github:
|
|
183
|
+
"""
|
|
184
|
+
This is the main class you instantiate to access the Github API v3.
|
|
185
|
+
|
|
186
|
+
Optional parameters allow different authentication methods.
|
|
187
|
+
|
|
188
|
+
"""
|
|
189
|
+
|
|
190
|
+
__requester: Requester
|
|
191
|
+
|
|
192
|
+
default_retry = GithubRetry()
|
|
193
|
+
|
|
194
|
+
# keep non-deprecated arguments in-sync with Requester
|
|
195
|
+
# v3: remove login_or_token, password, jwt and app_auth
|
|
196
|
+
# v3: move auth to the front of arguments
|
|
197
|
+
# v3: add * before first argument so all arguments must be named,
|
|
198
|
+
# allows to reorder / add new arguments / remove deprecated arguments without breaking user code
|
|
199
|
+
def __init__(
|
|
200
|
+
self,
|
|
201
|
+
login_or_token: str | None = None,
|
|
202
|
+
password: str | None = None,
|
|
203
|
+
jwt: str | None = None,
|
|
204
|
+
app_auth: AppAuthentication | None = None,
|
|
205
|
+
base_url: str = Consts.DEFAULT_BASE_URL,
|
|
206
|
+
timeout: int = Consts.DEFAULT_TIMEOUT,
|
|
207
|
+
user_agent: str = Consts.DEFAULT_USER_AGENT,
|
|
208
|
+
per_page: int = Consts.DEFAULT_PER_PAGE,
|
|
209
|
+
verify: bool | str = True,
|
|
210
|
+
retry: int | Retry | None = default_retry,
|
|
211
|
+
pool_size: int | None = None,
|
|
212
|
+
seconds_between_requests: float | None = Consts.DEFAULT_SECONDS_BETWEEN_REQUESTS,
|
|
213
|
+
seconds_between_writes: float | None = Consts.DEFAULT_SECONDS_BETWEEN_WRITES,
|
|
214
|
+
auth: Auth | None = None,
|
|
215
|
+
# v3: set lazy = True as the default
|
|
216
|
+
lazy: bool = False,
|
|
217
|
+
api_version: str | None = None,
|
|
218
|
+
) -> None:
|
|
219
|
+
"""
|
|
220
|
+
:param login_or_token: string deprecated, use auth=githubasyncio.Auth.Login(...) or auth=githubasyncio.Auth.Token(...) instead
|
|
221
|
+
:param password: string deprecated, use auth=githubasyncio.Auth.Login(...) instead
|
|
222
|
+
:param jwt: string deprecated, use auth=githubasyncio.Auth.AppAuth(...) or auth=githubasyncio.Auth.AppAuthToken(...) instead
|
|
223
|
+
:param app_auth: github.AppAuthentication deprecated, use auth=githubasyncio.Auth.AppInstallationAuth(...) instead
|
|
224
|
+
:param base_url: string
|
|
225
|
+
:param timeout: integer
|
|
226
|
+
:param user_agent: string
|
|
227
|
+
:param per_page: int
|
|
228
|
+
:param verify: boolean or string
|
|
229
|
+
:param retry: int or urllib3.util.retry.Retry object,
|
|
230
|
+
defaults to github.Github.default_retry,
|
|
231
|
+
set to None to disable retries
|
|
232
|
+
:param pool_size: int
|
|
233
|
+
:param seconds_between_requests: float
|
|
234
|
+
:param seconds_between_writes: float
|
|
235
|
+
:param auth: authentication method
|
|
236
|
+
:param lazy: completable objects created from this instance are lazy,
|
|
237
|
+
as well as completable objects created from those, and so on
|
|
238
|
+
:param api_version: string, GitHub API version to use (see https://docs.github.com/en/rest/about-the-rest-api/api-versions).
|
|
239
|
+
Note that some PyGithub methods might downgrade this version if it is not supported by the implementation.
|
|
240
|
+
Set to None to not specify any version
|
|
241
|
+
"""
|
|
242
|
+
assert login_or_token is None or isinstance(login_or_token, str), login_or_token
|
|
243
|
+
assert password is None or isinstance(password, str), password
|
|
244
|
+
assert jwt is None or isinstance(jwt, str), jwt
|
|
245
|
+
assert isinstance(base_url, str), base_url
|
|
246
|
+
assert isinstance(timeout, int), timeout
|
|
247
|
+
assert user_agent is None or isinstance(user_agent, str), user_agent
|
|
248
|
+
assert isinstance(per_page, int), per_page
|
|
249
|
+
assert isinstance(verify, (bool, str)), verify
|
|
250
|
+
assert retry is None or isinstance(retry, int) or isinstance(retry, Retry), retry
|
|
251
|
+
assert pool_size is None or isinstance(pool_size, int), pool_size
|
|
252
|
+
assert seconds_between_requests is None or seconds_between_requests >= 0
|
|
253
|
+
assert seconds_between_writes is None or seconds_between_writes >= 0
|
|
254
|
+
assert auth is None or isinstance(auth, githubasyncio.Auth.Auth), auth
|
|
255
|
+
assert isinstance(lazy, bool), lazy
|
|
256
|
+
assert api_version is None or isinstance(api_version, str), api_version
|
|
257
|
+
|
|
258
|
+
if password is not None:
|
|
259
|
+
warnings.warn(
|
|
260
|
+
"Arguments login_or_token and password are deprecated, please use auth=githubasyncio.Auth.Login(...) instead",
|
|
261
|
+
category=DeprecationWarning,
|
|
262
|
+
stacklevel=2,
|
|
263
|
+
)
|
|
264
|
+
auth = githubasyncio.Auth.Login(login_or_token, password) # type: ignore
|
|
265
|
+
elif login_or_token is not None:
|
|
266
|
+
warnings.warn(
|
|
267
|
+
"Argument login_or_token is deprecated, please use auth=githubasyncio.Auth.Token(...) instead",
|
|
268
|
+
category=DeprecationWarning,
|
|
269
|
+
stacklevel=2,
|
|
270
|
+
)
|
|
271
|
+
auth = githubasyncio.Auth.Token(login_or_token)
|
|
272
|
+
elif jwt is not None:
|
|
273
|
+
warnings.warn(
|
|
274
|
+
"Argument jwt is deprecated, please use auth=githubasyncio.Auth.AppAuth(...) or auth=githubasyncio.Auth.AppAuthToken(...) instead",
|
|
275
|
+
category=DeprecationWarning,
|
|
276
|
+
stacklevel=2,
|
|
277
|
+
)
|
|
278
|
+
auth = githubasyncio.Auth.AppAuthToken(jwt)
|
|
279
|
+
elif app_auth is not None:
|
|
280
|
+
warnings.warn(
|
|
281
|
+
"Argument app_auth is deprecated, please use auth=githubasyncio.Auth.AppInstallationAuth(...) instead",
|
|
282
|
+
category=DeprecationWarning,
|
|
283
|
+
stacklevel=2,
|
|
284
|
+
)
|
|
285
|
+
auth = app_auth
|
|
286
|
+
|
|
287
|
+
self.__requester = Requester(
|
|
288
|
+
auth,
|
|
289
|
+
base_url,
|
|
290
|
+
timeout,
|
|
291
|
+
user_agent,
|
|
292
|
+
per_page,
|
|
293
|
+
verify,
|
|
294
|
+
retry,
|
|
295
|
+
pool_size,
|
|
296
|
+
seconds_between_requests,
|
|
297
|
+
seconds_between_writes,
|
|
298
|
+
lazy,
|
|
299
|
+
api_version,
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
def withLazy(self, lazy: bool) -> Github:
|
|
303
|
+
"""
|
|
304
|
+
Create a Github instance with identical configuration but the given lazy setting.
|
|
305
|
+
|
|
306
|
+
:param lazy: completable objects created from this instance are lazy, as well as completable objects created
|
|
307
|
+
from those, and so on
|
|
308
|
+
:return: new Github instance
|
|
309
|
+
|
|
310
|
+
"""
|
|
311
|
+
kwargs = self.__requester.kwargs
|
|
312
|
+
kwargs.update(lazy=lazy)
|
|
313
|
+
gh = Github(**kwargs)
|
|
314
|
+
gh.requester.useCurrentRateLimits(self.__requester)
|
|
315
|
+
return gh
|
|
316
|
+
|
|
317
|
+
async def close(self) -> None:
|
|
318
|
+
"""
|
|
319
|
+
Close connections to the server. Alternatively, use the Github
|
|
320
|
+
object as a context manager:
|
|
321
|
+
|
|
322
|
+
.. code-block:: python
|
|
323
|
+
|
|
324
|
+
with github.Github(...) as gh:
|
|
325
|
+
# do something
|
|
326
|
+
"""
|
|
327
|
+
await self.__requester.close()
|
|
328
|
+
|
|
329
|
+
async def __aenter__(self) -> Github:
|
|
330
|
+
return self
|
|
331
|
+
|
|
332
|
+
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
|
|
333
|
+
await self.close()
|
|
334
|
+
|
|
335
|
+
@property
|
|
336
|
+
def requester(self) -> Requester:
|
|
337
|
+
"""
|
|
338
|
+
Return my Requester object.
|
|
339
|
+
|
|
340
|
+
For example, to make requests to API endpoints not yet supported by PyGitHub.
|
|
341
|
+
|
|
342
|
+
"""
|
|
343
|
+
return self.__requester
|
|
344
|
+
|
|
345
|
+
@property
|
|
346
|
+
def FIX_REPO_GET_GIT_REF(self) -> bool:
|
|
347
|
+
return self.__requester.FIX_REPO_GET_GIT_REF
|
|
348
|
+
|
|
349
|
+
@FIX_REPO_GET_GIT_REF.setter
|
|
350
|
+
def FIX_REPO_GET_GIT_REF(self, value: bool) -> None:
|
|
351
|
+
self.__requester.FIX_REPO_GET_GIT_REF = value
|
|
352
|
+
|
|
353
|
+
# v3: Remove this property? Why should it be necessary to read/modify it after construction
|
|
354
|
+
@property
|
|
355
|
+
def per_page(self) -> int:
|
|
356
|
+
return self.__requester.per_page
|
|
357
|
+
|
|
358
|
+
@per_page.setter
|
|
359
|
+
def per_page(self, value: int) -> None:
|
|
360
|
+
self.__requester.per_page = value
|
|
361
|
+
|
|
362
|
+
# v3: Provide a unified way to access values of headers of last response
|
|
363
|
+
# v3: (and add/keep ad hoc properties for specific useful headers like rate limiting, oauth scopes, etc.)
|
|
364
|
+
# v3: Return an instance of a class: using a tuple did not allow to add a field "resettime"
|
|
365
|
+
@property
|
|
366
|
+
@deprecated("Use current_rate_limits instead")
|
|
367
|
+
async def rate_limiting(self) -> tuple[int, int]:
|
|
368
|
+
"""
|
|
369
|
+
First value is requests remaining, second value is request limit.
|
|
370
|
+
"""
|
|
371
|
+
remaining, limit = self.__requester.rate_limiting
|
|
372
|
+
if limit < 0:
|
|
373
|
+
await self.current_rate_limits.update()
|
|
374
|
+
return self.__requester.rate_limiting
|
|
375
|
+
|
|
376
|
+
@property
|
|
377
|
+
@deprecated("Use current_rate_limits instead")
|
|
378
|
+
async def rate_limiting_resettime(self) -> int:
|
|
379
|
+
"""
|
|
380
|
+
Unix timestamp indicating when rate limiting will reset.
|
|
381
|
+
"""
|
|
382
|
+
if self.__requester.rate_limiting_resettime == 0:
|
|
383
|
+
await self.current_rate_limits.update()
|
|
384
|
+
return self.__requester.rate_limiting_resettime
|
|
385
|
+
|
|
386
|
+
@property
|
|
387
|
+
def current_rate_limits(self) -> RateLimitOverview:
|
|
388
|
+
"""
|
|
389
|
+
Latest rate limits known to the requester of this instance, per resource. This does not send any request.
|
|
390
|
+
|
|
391
|
+
Values come from the response headers of requests made through the requester of this instance.
|
|
392
|
+
Attributes of ``resources`` are ``None`` until values for that resource are known or if the resource is unknown
|
|
393
|
+
to :class:`githubasyncio.RateLimit.RateLimit`. Use :meth:`githubasyncio.RateLimitOverview.RateLimitOverview.update` to fetch latest values.
|
|
394
|
+
|
|
395
|
+
"""
|
|
396
|
+
return self.__requester.current_rate_limits
|
|
397
|
+
|
|
398
|
+
@deprecated("Use current_rate_limits.update() instead")
|
|
399
|
+
async def get_rate_limit(self) -> RateLimitOverview:
|
|
400
|
+
"""
|
|
401
|
+
Deprecated by current_rate_limits.update().
|
|
402
|
+
"""
|
|
403
|
+
return await self.current_rate_limits.update()
|
|
404
|
+
|
|
405
|
+
@property
|
|
406
|
+
def oauth_scopes(self) -> list[str] | None:
|
|
407
|
+
"""
|
|
408
|
+
:type: list of string
|
|
409
|
+
"""
|
|
410
|
+
return self.__requester.oauth_scopes
|
|
411
|
+
|
|
412
|
+
async def get_license(self, key: Opt[str] = NotSet) -> License:
|
|
413
|
+
"""
|
|
414
|
+
:calls: `GET /license/{license} <https://docs.github.com/en/rest/reference/licenses#get-a-license>`_
|
|
415
|
+
"""
|
|
416
|
+
assert isinstance(key, str), key
|
|
417
|
+
key = urllib.parse.quote(key)
|
|
418
|
+
headers, data = await self.__requester.requestJsonAndCheck("GET", f"/licenses/{key}")
|
|
419
|
+
return githubasyncio.License.License(self.__requester, headers, data, completed=True)
|
|
420
|
+
|
|
421
|
+
def get_licenses(self) -> PaginatedList[License]:
|
|
422
|
+
"""
|
|
423
|
+
:calls: `GET /licenses <https://docs.github.com/en/rest/reference/licenses#get-all-commonly-used-licenses>`_
|
|
424
|
+
"""
|
|
425
|
+
url_parameters: dict[str, Any] = {}
|
|
426
|
+
|
|
427
|
+
return PaginatedList(githubasyncio.License.License, self.__requester, "/licenses", url_parameters)
|
|
428
|
+
|
|
429
|
+
def get_events(self) -> PaginatedList[Event]:
|
|
430
|
+
"""
|
|
431
|
+
:calls: `GET /events <https://docs.github.com/en/rest/reference/activity#list-public-events>`_
|
|
432
|
+
"""
|
|
433
|
+
return PaginatedList(githubasyncio.Event.Event, self.__requester, "/events", None)
|
|
434
|
+
|
|
435
|
+
@overload
|
|
436
|
+
async def get_user(self, login: _NotSetType = NotSet, lazy: Opt[bool] = NotSet) -> AuthenticatedUser: ...
|
|
437
|
+
|
|
438
|
+
@overload
|
|
439
|
+
async def get_user(self, login: str, lazy: Opt[bool] = NotSet) -> NamedUser: ...
|
|
440
|
+
|
|
441
|
+
# v3: remove lazy argument, laziness is fully controlled via requester
|
|
442
|
+
async def get_user(self, login: Opt[str] = NotSet, lazy: Opt[bool] = NotSet) -> NamedUser | AuthenticatedUser:
|
|
443
|
+
"""
|
|
444
|
+
:calls: `GET /users/{username} <https://docs.github.com/en/rest/reference/users>`_ or `GET /user <https://docs.github.com/en/rest/reference/users>`_
|
|
445
|
+
"""
|
|
446
|
+
requester = self.__requester.withLazy(lazy)
|
|
447
|
+
if is_undefined(login):
|
|
448
|
+
url = "/user"
|
|
449
|
+
# default is to return a lazy completable AuthenticatedUser
|
|
450
|
+
# v3: given Github(lazy=True) is now default, remove completed=False here
|
|
451
|
+
return githubasyncio.AuthenticatedUser.AuthenticatedUser(
|
|
452
|
+
requester, url=url, completed=False if is_undefined(lazy) else None
|
|
453
|
+
)
|
|
454
|
+
else:
|
|
455
|
+
assert isinstance(login, str), login
|
|
456
|
+
login = urllib.parse.quote(login)
|
|
457
|
+
url = f"/users/{login}"
|
|
458
|
+
# always return a completed NamedUser
|
|
459
|
+
# v3: remove complete() here and make this as lazy as Github is
|
|
460
|
+
user = githubasyncio.NamedUser.NamedUser(requester, url=url)
|
|
461
|
+
return await user.complete() if is_undefined(lazy) else user
|
|
462
|
+
|
|
463
|
+
def get_user_by_id(self, user_id: int) -> NamedUser:
|
|
464
|
+
"""
|
|
465
|
+
:calls: `GET /user/{account_id} <https://docs.github.com/en/rest/reference/users>`_
|
|
466
|
+
:param user_id: int
|
|
467
|
+
:rtype: :class:`githubasyncio.NamedUser.NamedUser`
|
|
468
|
+
"""
|
|
469
|
+
assert isinstance(user_id, int), user_id
|
|
470
|
+
url = f"/user/{user_id}"
|
|
471
|
+
return githubasyncio.NamedUser.NamedUser(self.__requester, url=url)
|
|
472
|
+
|
|
473
|
+
def get_users(self, since: Opt[int] = NotSet) -> PaginatedList[NamedUser]:
|
|
474
|
+
"""
|
|
475
|
+
:calls: `GET /users <https://docs.github.com/en/rest/reference/users>`_
|
|
476
|
+
"""
|
|
477
|
+
assert is_undefined(since) or isinstance(since, int), since
|
|
478
|
+
url_parameters = dict()
|
|
479
|
+
if is_defined(since):
|
|
480
|
+
url_parameters["since"] = since
|
|
481
|
+
return PaginatedList(githubasyncio.NamedUser.NamedUser, self.__requester, "/users", url_parameters)
|
|
482
|
+
|
|
483
|
+
def get_organization(self, org: str) -> Organization:
|
|
484
|
+
"""
|
|
485
|
+
:calls: `GET /orgs/{org} <https://docs.github.com/en/rest/reference/orgs>`_
|
|
486
|
+
"""
|
|
487
|
+
assert isinstance(org, str), org
|
|
488
|
+
org = urllib.parse.quote(org, safe="")
|
|
489
|
+
url = f"/orgs/{org}"
|
|
490
|
+
return githubasyncio.Organization.Organization(self.__requester, url=url)
|
|
491
|
+
|
|
492
|
+
def get_organizations(self, since: Opt[int] = NotSet) -> PaginatedList[Organization]:
|
|
493
|
+
"""
|
|
494
|
+
:calls: `GET /organizations <https://docs.github.com/en/rest/reference/orgs#list-organizations>`_
|
|
495
|
+
"""
|
|
496
|
+
assert is_undefined(since) or isinstance(since, int), since
|
|
497
|
+
url_parameters = dict()
|
|
498
|
+
if is_defined(since):
|
|
499
|
+
url_parameters["since"] = since
|
|
500
|
+
return PaginatedList(
|
|
501
|
+
githubasyncio.Organization.Organization,
|
|
502
|
+
self.__requester,
|
|
503
|
+
"/organizations",
|
|
504
|
+
url_parameters,
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
# v3: rename enterprise to slug
|
|
508
|
+
def get_enterprise(self, enterprise: str) -> Enterprise:
|
|
509
|
+
"""
|
|
510
|
+
:calls: `GET /enterprises/{enterprise} <https://docs.github.com/en/enterprise-cloud@latest/rest/enterprise-admin>`_
|
|
511
|
+
:param enterprise: string
|
|
512
|
+
:rtype: :class:`Enterprise`
|
|
513
|
+
"""
|
|
514
|
+
assert isinstance(enterprise, str), enterprise
|
|
515
|
+
# There is no native "/enterprises/{enterprise}" api, so this function is a hub for apis that start with "/enterprise/{enterprise}".
|
|
516
|
+
return githubasyncio.Enterprise.Enterprise.from_slug(self.__requester, enterprise)
|
|
517
|
+
|
|
518
|
+
# v3: remove lazy option
|
|
519
|
+
def get_repo(self, full_name_or_id: int | str, lazy: Opt[bool] = NotSet) -> Repository:
|
|
520
|
+
"""
|
|
521
|
+
:calls: `GET /repos/{owner}/{repo} <https://docs.github.com/en/rest/reference/repos>`_ or `GET /repositories/{repository_id} <https://docs.github.com/en/rest/reference/repos>`_
|
|
522
|
+
"""
|
|
523
|
+
if is_defined(lazy):
|
|
524
|
+
warnings.warn(
|
|
525
|
+
"Argument lazy is deprecated, please use Github(..., lazy=...).get_repo(...) instead",
|
|
526
|
+
category=DeprecationWarning,
|
|
527
|
+
stacklevel=2,
|
|
528
|
+
)
|
|
529
|
+
assert isinstance(full_name_or_id, (str, int)), full_name_or_id
|
|
530
|
+
url_base = "/repositories/" if isinstance(full_name_or_id, int) else "/repos/"
|
|
531
|
+
url = f"{url_base}{full_name_or_id}"
|
|
532
|
+
return githubasyncio.Repository.Repository(self.__requester.withLazy(lazy), url=url)
|
|
533
|
+
|
|
534
|
+
def get_repos(
|
|
535
|
+
self,
|
|
536
|
+
since: Opt[int] = NotSet,
|
|
537
|
+
visibility: Opt[str] = NotSet,
|
|
538
|
+
) -> PaginatedList[Repository]:
|
|
539
|
+
"""
|
|
540
|
+
:calls: `GET /repositories <https://docs.github.com/en/rest/reference/repos#list-public-repositories>`_
|
|
541
|
+
:param since: integer
|
|
542
|
+
:param visibility: string ('all','public')
|
|
543
|
+
"""
|
|
544
|
+
assert is_undefined(since) or isinstance(since, int), since
|
|
545
|
+
url_parameters: dict[str, Any] = {}
|
|
546
|
+
if is_defined(since):
|
|
547
|
+
url_parameters["since"] = since
|
|
548
|
+
if is_defined(visibility):
|
|
549
|
+
assert visibility in ("public", "all"), visibility
|
|
550
|
+
url_parameters["visibility"] = visibility
|
|
551
|
+
return PaginatedList(
|
|
552
|
+
githubasyncio.Repository.Repository,
|
|
553
|
+
self.__requester,
|
|
554
|
+
"/repositories",
|
|
555
|
+
url_parameters,
|
|
556
|
+
)
|
|
557
|
+
|
|
558
|
+
async def get_repository_discussion(self, node_id: str, discussion_graphql_schema: str) -> RepositoryDiscussion:
|
|
559
|
+
"""
|
|
560
|
+
:graphql: `query Query.node <https://docs.github.com/en/graphql/reference/meta#query-node>`_
|
|
561
|
+
"""
|
|
562
|
+
return await self.__requester.graphql_node_class(
|
|
563
|
+
node_id, discussion_graphql_schema, githubasyncio.RepositoryDiscussion.RepositoryDiscussion, "Discussion"
|
|
564
|
+
)
|
|
565
|
+
|
|
566
|
+
def get_project(self, id: int) -> Project:
|
|
567
|
+
"""
|
|
568
|
+
:calls: `GET /projects/{project_id} <https://docs.github.com/en/rest/reference/projects#get-a-project>`_
|
|
569
|
+
"""
|
|
570
|
+
url = f"/projects/{id:d}"
|
|
571
|
+
return githubasyncio.Project.Project(self.__requester, url=url, accept=Consts.mediaTypeProjectsPreview)
|
|
572
|
+
|
|
573
|
+
async def get_project_column(self, id: int) -> ProjectColumn:
|
|
574
|
+
"""
|
|
575
|
+
:calls: `GET /projects/columns/{column_id} <https://docs.github.com/en/rest/reference/projects#get-a-project-column>`_
|
|
576
|
+
"""
|
|
577
|
+
headers, data = await self.__requester.requestJsonAndCheck(
|
|
578
|
+
"GET",
|
|
579
|
+
f"/projects/columns/{id}",
|
|
580
|
+
headers={"Accept": Consts.mediaTypeProjectsPreview},
|
|
581
|
+
)
|
|
582
|
+
return githubasyncio.ProjectColumn.ProjectColumn(self.__requester, headers, data)
|
|
583
|
+
|
|
584
|
+
def get_gist(self, id: str) -> Gist:
|
|
585
|
+
"""
|
|
586
|
+
:calls: `GET /gists/{gist_id} <https://docs.github.com/en/rest/reference/gists>`_
|
|
587
|
+
"""
|
|
588
|
+
assert isinstance(id, str), id
|
|
589
|
+
url = f"/gists/{id}"
|
|
590
|
+
return githubasyncio.Gist.Gist(self.__requester, url=url)
|
|
591
|
+
|
|
592
|
+
def get_gists(self, since: Opt[datetime] = NotSet) -> PaginatedList[Gist]:
|
|
593
|
+
"""
|
|
594
|
+
:calls: `GET /gists/public <https://docs.github.com/en/rest/reference/gists>`_
|
|
595
|
+
"""
|
|
596
|
+
assert is_undefined(since) or isinstance(since, datetime), since
|
|
597
|
+
url_parameters = dict()
|
|
598
|
+
if is_defined(since):
|
|
599
|
+
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
600
|
+
return PaginatedList(githubasyncio.Gist.Gist, self.__requester, "/gists/public", url_parameters)
|
|
601
|
+
|
|
602
|
+
async def get_global_advisory(self, ghsa_id: str) -> GlobalAdvisory:
|
|
603
|
+
"""
|
|
604
|
+
:calls: `GET /advisories/{ghsa_id} <https://docs.github.com/en/rest/security-advisories/global-advisories>`_
|
|
605
|
+
:param ghsa_id: string
|
|
606
|
+
:rtype: :class:`githubasyncio.GlobalAdvisory.GlobalAdvisory`
|
|
607
|
+
"""
|
|
608
|
+
assert isinstance(ghsa_id, str), ghsa_id
|
|
609
|
+
ghsa_id = urllib.parse.quote(ghsa_id)
|
|
610
|
+
headers, data = await self.__requester.requestJsonAndCheck("GET", f"/advisories/{ghsa_id}")
|
|
611
|
+
return githubasyncio.GlobalAdvisory.GlobalAdvisory(self.__requester, headers, data)
|
|
612
|
+
|
|
613
|
+
def get_global_advisories(
|
|
614
|
+
self,
|
|
615
|
+
type: Opt[str] = NotSet,
|
|
616
|
+
ghsa_id: Opt[str] = NotSet,
|
|
617
|
+
cve_id: Opt[str] = NotSet,
|
|
618
|
+
ecosystem: Opt[str] = NotSet,
|
|
619
|
+
severity: Opt[str] = NotSet,
|
|
620
|
+
cwes: list[str | int] | Opt[str] = NotSet,
|
|
621
|
+
is_withdrawn: Opt[bool] = NotSet,
|
|
622
|
+
affects: list[str] | Opt[str] = NotSet,
|
|
623
|
+
published: Opt[str] = NotSet,
|
|
624
|
+
updated: Opt[str] = NotSet,
|
|
625
|
+
modified: Opt[str] = NotSet,
|
|
626
|
+
keywords: Opt[str] = NotSet,
|
|
627
|
+
before: Opt[str] = NotSet,
|
|
628
|
+
after: Opt[str] = NotSet,
|
|
629
|
+
per_page: Opt[str] = NotSet,
|
|
630
|
+
sort: Opt[str] = NotSet,
|
|
631
|
+
direction: Opt[str] = NotSet,
|
|
632
|
+
) -> PaginatedList[GlobalAdvisory]:
|
|
633
|
+
"""
|
|
634
|
+
:calls: `GET /advisories <https://docs.github.com/en/rest/security-advisories/global-advisories>`
|
|
635
|
+
:param type: Optional string
|
|
636
|
+
:param ghsa_id: Optional string
|
|
637
|
+
:param cve_id: Optional string
|
|
638
|
+
:param ecosystem: Optional string
|
|
639
|
+
:param severity: Optional string
|
|
640
|
+
:param cwes: Optional comma separated string or list of integer or string
|
|
641
|
+
:param is_withdrawn: Optional bool
|
|
642
|
+
:param affects: Optional comma separated string or list of string
|
|
643
|
+
:param published: Optional string
|
|
644
|
+
:param updated: Optional string
|
|
645
|
+
:param modified: Optional string
|
|
646
|
+
:param before: Optional string
|
|
647
|
+
:param after: Optional string
|
|
648
|
+
:param sort: Optional string
|
|
649
|
+
:param direction: Optional string
|
|
650
|
+
:rtype: :class:`githubasyncio.PaginatedList.PaginatedList` of :class:`githubasyncio.GlobalAdvisory.GlobalAdvisory`
|
|
651
|
+
"""
|
|
652
|
+
assert type is githubasyncio.GithubObject.NotSet or isinstance(type, str), type
|
|
653
|
+
assert ghsa_id is githubasyncio.GithubObject.NotSet or isinstance(ghsa_id, str)
|
|
654
|
+
assert cve_id is githubasyncio.GithubObject.NotSet or isinstance(cve_id, str), cve_id
|
|
655
|
+
assert ecosystem is githubasyncio.GithubObject.NotSet or isinstance(ecosystem, str), ecosystem
|
|
656
|
+
assert severity is githubasyncio.GithubObject.NotSet or isinstance(severity, str), severity
|
|
657
|
+
assert cwes is githubasyncio.GithubObject.NotSet or isinstance(cwes, list) or isinstance(cwes, str), cwes
|
|
658
|
+
assert is_withdrawn is githubasyncio.GithubObject.NotSet or isinstance(is_withdrawn, bool), is_withdrawn
|
|
659
|
+
assert affects is githubasyncio.GithubObject.NotSet or isinstance(affects, list) or isinstance(affects, str), (
|
|
660
|
+
affects
|
|
661
|
+
)
|
|
662
|
+
assert published is githubasyncio.GithubObject.NotSet or isinstance(published, str), published
|
|
663
|
+
assert updated is githubasyncio.GithubObject.NotSet or isinstance(updated, str), updated
|
|
664
|
+
assert modified is githubasyncio.GithubObject.NotSet or isinstance(modified, str), modified
|
|
665
|
+
assert before is githubasyncio.GithubObject.NotSet or isinstance(before, str), before
|
|
666
|
+
assert after is githubasyncio.GithubObject.NotSet or isinstance(after, str), after
|
|
667
|
+
assert sort is githubasyncio.GithubObject.NotSet or isinstance(sort, str), sort
|
|
668
|
+
assert direction is githubasyncio.GithubObject.NotSet or isinstance(direction, str), direction
|
|
669
|
+
|
|
670
|
+
url_parameters: dict[str, Opt[str | bool]] = dict()
|
|
671
|
+
if type is not githubasyncio.GithubObject.NotSet: # pragma no branch (Should be covered)
|
|
672
|
+
assert type in ("reviewed", "unreviewed", "malware"), type
|
|
673
|
+
url_parameters["type"] = type
|
|
674
|
+
if ghsa_id is not githubasyncio.GithubObject.NotSet:
|
|
675
|
+
url_parameters["ghsa_id"] = ghsa_id
|
|
676
|
+
if cve_id is not githubasyncio.GithubObject.NotSet:
|
|
677
|
+
url_parameters["cve_id"] = cve_id
|
|
678
|
+
# Can be one of: actions, composer, erlang, go, maven, npm, nuget, other, pip, pub, rubygems, rust
|
|
679
|
+
# Not asserting in that list so that the package doesn't need to be updated when a new ecosystem is added
|
|
680
|
+
if ecosystem is not githubasyncio.GithubObject.NotSet:
|
|
681
|
+
url_parameters["ecosystem"] = ecosystem
|
|
682
|
+
if severity is not githubasyncio.GithubObject.NotSet:
|
|
683
|
+
assert severity in ("null", "low", "medium", "high", "critical"), severity
|
|
684
|
+
url_parameters["severity"] = severity
|
|
685
|
+
if cwes is not githubasyncio.GithubObject.NotSet:
|
|
686
|
+
if isinstance(cwes, list):
|
|
687
|
+
cwes = ",".join([str(cwe) for cwe in cwes])
|
|
688
|
+
url_parameters["cwes"] = cwes
|
|
689
|
+
if is_withdrawn is not githubasyncio.GithubObject.NotSet:
|
|
690
|
+
url_parameters["is_withdrawn"] = is_withdrawn
|
|
691
|
+
if affects is not githubasyncio.GithubObject.NotSet:
|
|
692
|
+
if isinstance(affects, list):
|
|
693
|
+
affects = ",".join(affects)
|
|
694
|
+
url_parameters["affects"] = affects
|
|
695
|
+
if published is not githubasyncio.GithubObject.NotSet:
|
|
696
|
+
url_parameters["published"] = published
|
|
697
|
+
if updated is not githubasyncio.GithubObject.NotSet:
|
|
698
|
+
url_parameters["updated"] = updated
|
|
699
|
+
if modified is not githubasyncio.GithubObject.NotSet:
|
|
700
|
+
url_parameters["modified"] = modified
|
|
701
|
+
if before is not githubasyncio.GithubObject.NotSet:
|
|
702
|
+
url_parameters["before"] = before
|
|
703
|
+
if after is not githubasyncio.GithubObject.NotSet:
|
|
704
|
+
url_parameters["after"] = after
|
|
705
|
+
if sort is not githubasyncio.GithubObject.NotSet:
|
|
706
|
+
assert sort in ("published", "updated"), sort
|
|
707
|
+
url_parameters["sort"] = sort
|
|
708
|
+
if direction is not githubasyncio.GithubObject.NotSet:
|
|
709
|
+
assert direction in ("asc", "desc"), direction
|
|
710
|
+
url_parameters["direction"] = direction
|
|
711
|
+
return githubasyncio.PaginatedList.PaginatedList(
|
|
712
|
+
githubasyncio.GlobalAdvisory.GlobalAdvisory,
|
|
713
|
+
self.__requester,
|
|
714
|
+
"/advisories",
|
|
715
|
+
url_parameters,
|
|
716
|
+
)
|
|
717
|
+
|
|
718
|
+
def search_repositories(
|
|
719
|
+
self,
|
|
720
|
+
query: str,
|
|
721
|
+
sort: Opt[str] = NotSet,
|
|
722
|
+
order: Opt[str] = NotSet,
|
|
723
|
+
**qualifiers: Any,
|
|
724
|
+
) -> PaginatedList[RepositorySearchResult]:
|
|
725
|
+
"""
|
|
726
|
+
:calls: `GET /search/repositories <https://docs.github.com/en/rest/reference/search>`_
|
|
727
|
+
:param query: string
|
|
728
|
+
:param sort: string ('stars', 'forks', 'updated')
|
|
729
|
+
:param order: string ('asc', 'desc')
|
|
730
|
+
:param qualifiers: keyword dict query qualifiers
|
|
731
|
+
:rtype: :class:`PaginatedList` of :class:`githubasyncio.Repository.RepositorySearchResult`
|
|
732
|
+
|
|
733
|
+
You can check if GitHub search returned `incomplete results <https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#timeouts-and-incomplete-results>`_::
|
|
734
|
+
|
|
735
|
+
results = gh.search_repositories("query")
|
|
736
|
+
if results.incomplete_results:
|
|
737
|
+
print(f"Not sure if {results.totalCount} results are actually all results")
|
|
738
|
+
"""
|
|
739
|
+
assert isinstance(query, str), query
|
|
740
|
+
url_parameters = dict()
|
|
741
|
+
if is_defined(sort): # pragma no branch (Should be covered)
|
|
742
|
+
assert sort in ("stars", "forks", "updated"), sort
|
|
743
|
+
url_parameters["sort"] = sort
|
|
744
|
+
if is_defined(order): # pragma no branch (Should be covered)
|
|
745
|
+
assert order in ("asc", "desc"), order
|
|
746
|
+
url_parameters["order"] = order
|
|
747
|
+
|
|
748
|
+
query_chunks = []
|
|
749
|
+
if query: # pragma no branch (Should be covered)
|
|
750
|
+
query_chunks.append(query)
|
|
751
|
+
|
|
752
|
+
for qualifier, value in qualifiers.items():
|
|
753
|
+
query_chunks.append(f"{qualifier}:{value}")
|
|
754
|
+
|
|
755
|
+
url_parameters["q"] = " ".join(query_chunks)
|
|
756
|
+
assert url_parameters["q"], "need at least one qualifier"
|
|
757
|
+
|
|
758
|
+
return PaginatedList(
|
|
759
|
+
githubasyncio.Repository.RepositorySearchResult,
|
|
760
|
+
self.__requester,
|
|
761
|
+
"/search/repositories",
|
|
762
|
+
url_parameters,
|
|
763
|
+
)
|
|
764
|
+
|
|
765
|
+
def search_users(
|
|
766
|
+
self,
|
|
767
|
+
query: str,
|
|
768
|
+
sort: Opt[str] = NotSet,
|
|
769
|
+
order: Opt[str] = NotSet,
|
|
770
|
+
**qualifiers: Any,
|
|
771
|
+
) -> PaginatedList[NamedUserSearchResult]:
|
|
772
|
+
"""
|
|
773
|
+
:calls: `GET /search/users <https://docs.github.com/en/rest/reference/search>`_
|
|
774
|
+
:param query: string
|
|
775
|
+
:param sort: string ('followers', 'repositories', 'joined')
|
|
776
|
+
:param order: string ('asc', 'desc')
|
|
777
|
+
:param qualifiers: keyword dict query qualifiers
|
|
778
|
+
:rtype: :class:`PaginatedList` of :class:`githubasyncio.NamedUser.NamedUserSearchResult`
|
|
779
|
+
|
|
780
|
+
You can check if GitHub search returned `incomplete results <https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#timeouts-and-incomplete-results>`_::
|
|
781
|
+
|
|
782
|
+
results = gh.search_users("query")
|
|
783
|
+
if results.incomplete_results:
|
|
784
|
+
print(f"Not sure if {results.totalCount} results are actually all results")
|
|
785
|
+
"""
|
|
786
|
+
assert isinstance(query, str), query
|
|
787
|
+
url_parameters = dict()
|
|
788
|
+
if is_defined(sort):
|
|
789
|
+
assert sort in ("followers", "repositories", "joined"), sort
|
|
790
|
+
url_parameters["sort"] = sort
|
|
791
|
+
if is_defined(order):
|
|
792
|
+
assert order in ("asc", "desc"), order
|
|
793
|
+
url_parameters["order"] = order
|
|
794
|
+
|
|
795
|
+
query_chunks = []
|
|
796
|
+
if query:
|
|
797
|
+
query_chunks.append(query)
|
|
798
|
+
|
|
799
|
+
for qualifier, value in qualifiers.items():
|
|
800
|
+
query_chunks.append(f"{qualifier}:{value}")
|
|
801
|
+
|
|
802
|
+
url_parameters["q"] = " ".join(query_chunks)
|
|
803
|
+
assert url_parameters["q"], "need at least one qualifier"
|
|
804
|
+
|
|
805
|
+
return PaginatedList(
|
|
806
|
+
githubasyncio.NamedUser.NamedUserSearchResult,
|
|
807
|
+
self.__requester,
|
|
808
|
+
"/search/users",
|
|
809
|
+
url_parameters,
|
|
810
|
+
)
|
|
811
|
+
|
|
812
|
+
def search_issues(
|
|
813
|
+
self,
|
|
814
|
+
query: str,
|
|
815
|
+
sort: Opt[str] = NotSet,
|
|
816
|
+
order: Opt[str] = NotSet,
|
|
817
|
+
**qualifiers: Any,
|
|
818
|
+
) -> PaginatedList[IssueSearchResult]:
|
|
819
|
+
"""
|
|
820
|
+
:calls: `GET /search/issues <https://docs.github.com/en/rest/reference/search>`_
|
|
821
|
+
:param query: string
|
|
822
|
+
:param sort: string ('comments', 'created', 'updated')
|
|
823
|
+
:param order: string ('asc', 'desc')
|
|
824
|
+
:param qualifiers: keyword dict query qualifiers
|
|
825
|
+
:rtype: :class:`PaginatedList` of :class:`githubasyncio.Issue.IssueSearchResult`
|
|
826
|
+
|
|
827
|
+
You can check if GitHub search returned `incomplete results <https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#timeouts-and-incomplete-results>`_::
|
|
828
|
+
|
|
829
|
+
results = gh.search_issues("query")
|
|
830
|
+
if results.incomplete_results:
|
|
831
|
+
print(f"Not sure if {results.totalCount} results are actually all results")
|
|
832
|
+
"""
|
|
833
|
+
assert isinstance(query, str), query
|
|
834
|
+
url_parameters = dict()
|
|
835
|
+
if is_defined(sort):
|
|
836
|
+
assert sort in ("comments", "created", "updated"), sort
|
|
837
|
+
url_parameters["sort"] = sort
|
|
838
|
+
if is_defined(order):
|
|
839
|
+
assert order in ("asc", "desc"), order
|
|
840
|
+
url_parameters["order"] = order
|
|
841
|
+
|
|
842
|
+
query_chunks = []
|
|
843
|
+
if query: # pragma no branch (Should be covered)
|
|
844
|
+
query_chunks.append(query)
|
|
845
|
+
|
|
846
|
+
for qualifier, value in qualifiers.items():
|
|
847
|
+
query_chunks.append(f"{qualifier}:{value}")
|
|
848
|
+
|
|
849
|
+
url_parameters["q"] = " ".join(query_chunks)
|
|
850
|
+
assert url_parameters["q"], "need at least one qualifier"
|
|
851
|
+
|
|
852
|
+
return PaginatedList(githubasyncio.Issue.IssueSearchResult, self.__requester, "/search/issues", url_parameters)
|
|
853
|
+
|
|
854
|
+
def search_code(
|
|
855
|
+
self,
|
|
856
|
+
query: str,
|
|
857
|
+
sort: Opt[str] = NotSet,
|
|
858
|
+
order: Opt[str] = NotSet,
|
|
859
|
+
highlight: bool = False,
|
|
860
|
+
**qualifiers: Any,
|
|
861
|
+
) -> PaginatedList[ContentFileSearchResult]:
|
|
862
|
+
"""
|
|
863
|
+
:calls: `GET /search/code <https://docs.github.com/en/rest/reference/search>`_
|
|
864
|
+
:param query: string
|
|
865
|
+
:param sort: string ('indexed')
|
|
866
|
+
:param order: string ('asc', 'desc')
|
|
867
|
+
:param highlight: boolean (True, False)
|
|
868
|
+
:param qualifiers: keyword dict query qualifiers
|
|
869
|
+
:rtype: :class:`PaginatedList` of :class:`githubasyncio.ContentFile.ContentFileSearchResult`
|
|
870
|
+
|
|
871
|
+
You can check if GitHub search returned `incomplete results <https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#timeouts-and-incomplete-results>`_::
|
|
872
|
+
|
|
873
|
+
results = gh.search_code("query")
|
|
874
|
+
if results.incomplete_results:
|
|
875
|
+
print(f"Not sure if {results.totalCount} results are actually all results")
|
|
876
|
+
"""
|
|
877
|
+
assert isinstance(query, str), query
|
|
878
|
+
url_parameters = dict()
|
|
879
|
+
if is_defined(sort): # pragma no branch (Should be covered)
|
|
880
|
+
assert sort in ("indexed",), sort
|
|
881
|
+
url_parameters["sort"] = sort
|
|
882
|
+
if is_defined(order): # pragma no branch (Should be covered)
|
|
883
|
+
assert order in ("asc", "desc"), order
|
|
884
|
+
url_parameters["order"] = order
|
|
885
|
+
|
|
886
|
+
query_chunks = []
|
|
887
|
+
if query: # pragma no branch (Should be covered)
|
|
888
|
+
query_chunks.append(query)
|
|
889
|
+
|
|
890
|
+
for qualifier, value in qualifiers.items():
|
|
891
|
+
query_chunks.append(f"{qualifier}:{value}")
|
|
892
|
+
|
|
893
|
+
url_parameters["q"] = " ".join(query_chunks)
|
|
894
|
+
assert url_parameters["q"], "need at least one qualifier"
|
|
895
|
+
|
|
896
|
+
headers = {"Accept": Consts.highLightSearchPreview} if highlight else None
|
|
897
|
+
|
|
898
|
+
return PaginatedList(
|
|
899
|
+
githubasyncio.ContentFile.ContentFileSearchResult,
|
|
900
|
+
self.__requester,
|
|
901
|
+
"/search/code",
|
|
902
|
+
url_parameters,
|
|
903
|
+
headers=headers,
|
|
904
|
+
)
|
|
905
|
+
|
|
906
|
+
def search_commits(
|
|
907
|
+
self,
|
|
908
|
+
query: str,
|
|
909
|
+
sort: Opt[str] = NotSet,
|
|
910
|
+
order: Opt[str] = NotSet,
|
|
911
|
+
**qualifiers: Any,
|
|
912
|
+
) -> PaginatedList[CommitSearchResult]:
|
|
913
|
+
"""
|
|
914
|
+
:calls: `GET /search/commits <https://docs.github.com/en/rest/reference/search>`_
|
|
915
|
+
:param query: string
|
|
916
|
+
:param sort: string ('author-date', 'committer-date')
|
|
917
|
+
:param order: string ('asc', 'desc')
|
|
918
|
+
:param qualifiers: keyword dict query qualifiers
|
|
919
|
+
:rtype: :class:`PaginatedList` of :class:`githubasyncio.Commit.CommitSearchResult`
|
|
920
|
+
|
|
921
|
+
You can check if GitHub search returned `incomplete results <https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#timeouts-and-incomplete-results>`_::
|
|
922
|
+
|
|
923
|
+
results = gh.search_commits("query")
|
|
924
|
+
if results.incomplete_results:
|
|
925
|
+
print(f"Not sure if {results.totalCount} results are actually all results")
|
|
926
|
+
"""
|
|
927
|
+
assert isinstance(query, str), query
|
|
928
|
+
url_parameters = dict()
|
|
929
|
+
if is_defined(sort):
|
|
930
|
+
assert sort in ("author-date", "committer-date"), sort
|
|
931
|
+
url_parameters["sort"] = sort
|
|
932
|
+
if is_defined(order):
|
|
933
|
+
assert order in ("asc", "desc"), order
|
|
934
|
+
url_parameters["order"] = order
|
|
935
|
+
|
|
936
|
+
query_chunks = []
|
|
937
|
+
if query:
|
|
938
|
+
query_chunks.append(query)
|
|
939
|
+
|
|
940
|
+
for qualifier, value in qualifiers.items():
|
|
941
|
+
query_chunks.append(f"{qualifier}:{value}")
|
|
942
|
+
|
|
943
|
+
url_parameters["q"] = " ".join(query_chunks)
|
|
944
|
+
assert url_parameters["q"], "need at least one qualifier"
|
|
945
|
+
|
|
946
|
+
return PaginatedList(
|
|
947
|
+
githubasyncio.Commit.CommitSearchResult,
|
|
948
|
+
self.__requester,
|
|
949
|
+
"/search/commits",
|
|
950
|
+
url_parameters,
|
|
951
|
+
headers={"Accept": Consts.mediaTypeCommitSearchPreview},
|
|
952
|
+
)
|
|
953
|
+
|
|
954
|
+
def search_topics(self, query: str, **qualifiers: Any) -> PaginatedList[Topic]:
|
|
955
|
+
"""
|
|
956
|
+
:calls: `GET /search/topics <https://docs.github.com/en/rest/reference/search>`_
|
|
957
|
+
:param query: string
|
|
958
|
+
:param qualifiers: keyword dict query qualifiers
|
|
959
|
+
:rtype: :class:`PaginatedList` of :class:`githubasyncio.Topic.Topic`
|
|
960
|
+
|
|
961
|
+
You can check if GitHub search returned `incomplete results <https://docs.github.com/en/rest/search/search?apiVersion=2022-11-28#timeouts-and-incomplete-results>`_::
|
|
962
|
+
|
|
963
|
+
results = gh.search_topics("query")
|
|
964
|
+
if results.incomplete_results:
|
|
965
|
+
print(f"Not sure if {results.totalCount} results are actually all results")
|
|
966
|
+
"""
|
|
967
|
+
assert isinstance(query, str), query
|
|
968
|
+
url_parameters = dict()
|
|
969
|
+
|
|
970
|
+
query_chunks = []
|
|
971
|
+
if query: # pragma no branch (Should be covered)
|
|
972
|
+
query_chunks.append(query)
|
|
973
|
+
|
|
974
|
+
for qualifier, value in qualifiers.items():
|
|
975
|
+
query_chunks.append(f"{qualifier}:{value}")
|
|
976
|
+
|
|
977
|
+
url_parameters["q"] = " ".join(query_chunks)
|
|
978
|
+
assert url_parameters["q"], "need at least one qualifier"
|
|
979
|
+
|
|
980
|
+
return PaginatedList(
|
|
981
|
+
githubasyncio.Topic.Topic,
|
|
982
|
+
self.__requester,
|
|
983
|
+
"/search/topics",
|
|
984
|
+
url_parameters,
|
|
985
|
+
headers={"Accept": Consts.mediaTypeTopicsPreview},
|
|
986
|
+
)
|
|
987
|
+
|
|
988
|
+
async def render_markdown(self, text: str, context: Opt[Repository] = NotSet) -> str:
|
|
989
|
+
"""
|
|
990
|
+
:calls: `POST /markdown <https://docs.github.com/en/rest/reference/markdown>`_
|
|
991
|
+
:param text: string
|
|
992
|
+
:param context: :class:`githubasyncio.Repository.Repository`
|
|
993
|
+
:rtype: string
|
|
994
|
+
"""
|
|
995
|
+
assert isinstance(text, str), text
|
|
996
|
+
assert is_undefined(context) or isinstance(context, githubasyncio.Repository.Repository), context
|
|
997
|
+
post_parameters = {"text": text}
|
|
998
|
+
if is_defined(context):
|
|
999
|
+
post_parameters["mode"] = "gfm"
|
|
1000
|
+
post_parameters["context"] = await context._identity
|
|
1001
|
+
status, headers, data = await self.__requester.requestJson("POST", "/markdown", input=post_parameters)
|
|
1002
|
+
return data
|
|
1003
|
+
|
|
1004
|
+
async def get_hook(self, name: str) -> HookDescription:
|
|
1005
|
+
"""
|
|
1006
|
+
:calls: `GET /hooks/{name} <https://docs.github.com/en/rest/reference/repos#webhooks>`_
|
|
1007
|
+
"""
|
|
1008
|
+
assert isinstance(name, str), name
|
|
1009
|
+
name = urllib.parse.quote(name, safe="")
|
|
1010
|
+
headers, attributes = await self.__requester.requestJsonAndCheck("GET", f"/hooks/{name}")
|
|
1011
|
+
return githubasyncio.HookDescription.HookDescription(self.__requester, headers, attributes)
|
|
1012
|
+
|
|
1013
|
+
async def get_hooks(self) -> list[HookDescription]:
|
|
1014
|
+
"""
|
|
1015
|
+
:calls: `GET /hooks <https://docs.github.com/en/rest/reference/repos#webhooks>`_
|
|
1016
|
+
:rtype: list of :class:`githubasyncio.HookDescription.HookDescription`
|
|
1017
|
+
"""
|
|
1018
|
+
headers, data = await self.__requester.requestJsonAndCheck("GET", "/hooks")
|
|
1019
|
+
return [
|
|
1020
|
+
githubasyncio.HookDescription.HookDescription(self.__requester, headers, attributes) for attributes in data
|
|
1021
|
+
]
|
|
1022
|
+
|
|
1023
|
+
async def get_hook_delivery(self, hook_id: int, delivery_id: int) -> HookDelivery:
|
|
1024
|
+
"""
|
|
1025
|
+
:calls: `GET /hooks/{hook_id}/deliveries/{delivery_id} <https://docs.github.com/en/rest/reference/repos#webhooks>`_
|
|
1026
|
+
:param hook_id: integer
|
|
1027
|
+
:param delivery_id: integer
|
|
1028
|
+
:rtype: :class:`HookDelivery`
|
|
1029
|
+
"""
|
|
1030
|
+
assert isinstance(hook_id, int), hook_id
|
|
1031
|
+
assert isinstance(delivery_id, int), delivery_id
|
|
1032
|
+
headers, attributes = await self.__requester.requestJsonAndCheck(
|
|
1033
|
+
"GET", f"/hooks/{hook_id}/deliveries/{delivery_id}"
|
|
1034
|
+
)
|
|
1035
|
+
return githubasyncio.HookDelivery.HookDelivery(self.__requester, headers, attributes)
|
|
1036
|
+
|
|
1037
|
+
async def get_hook_deliveries(self, hook_id: int) -> list[HookDeliverySummary]:
|
|
1038
|
+
"""
|
|
1039
|
+
:calls: `GET /hooks/{hook_id}/deliveries <https://docs.github.com/en/rest/reference/repos#webhooks>`_
|
|
1040
|
+
:param hook_id: integer
|
|
1041
|
+
:rtype: list of :class:`HookDeliverySummary`
|
|
1042
|
+
"""
|
|
1043
|
+
assert isinstance(hook_id, int), hook_id
|
|
1044
|
+
headers, data = await self.__requester.requestJsonAndCheck("GET", f"/hooks/{hook_id}/deliveries")
|
|
1045
|
+
return [
|
|
1046
|
+
githubasyncio.HookDelivery.HookDeliverySummary(self.__requester, headers, attributes) for attributes in data
|
|
1047
|
+
]
|
|
1048
|
+
|
|
1049
|
+
async def get_gitignore_templates(self) -> list[str]:
|
|
1050
|
+
"""
|
|
1051
|
+
:calls: `GET /gitignore/templates <https://docs.github.com/en/rest/reference/gitignore>`_
|
|
1052
|
+
"""
|
|
1053
|
+
headers, data = await self.__requester.requestJsonAndCheck("GET", "/gitignore/templates")
|
|
1054
|
+
return data
|
|
1055
|
+
|
|
1056
|
+
async def get_gitignore_template(self, name: str) -> GitignoreTemplate:
|
|
1057
|
+
"""
|
|
1058
|
+
:calls: `GET /gitignore/templates/{name} <https://docs.github.com/en/rest/reference/gitignore>`_
|
|
1059
|
+
"""
|
|
1060
|
+
assert isinstance(name, str), name
|
|
1061
|
+
name = urllib.parse.quote(name)
|
|
1062
|
+
headers, attributes = await self.__requester.requestJsonAndCheck("GET", f"/gitignore/templates/{name}")
|
|
1063
|
+
return githubasyncio.GitignoreTemplate.GitignoreTemplate(self.__requester, headers, attributes)
|
|
1064
|
+
|
|
1065
|
+
async def get_emojis(self) -> dict[str, str]:
|
|
1066
|
+
"""
|
|
1067
|
+
:calls: `GET /emojis <https://docs.github.com/en/rest/reference/emojis>`_
|
|
1068
|
+
:rtype: dictionary of type => url for emoji`
|
|
1069
|
+
"""
|
|
1070
|
+
headers, attributes = await self.__requester.requestJsonAndCheck("GET", "/emojis")
|
|
1071
|
+
return attributes
|
|
1072
|
+
|
|
1073
|
+
def create_from_raw_data(
|
|
1074
|
+
self, klass: type[TGithubObject], raw_data: dict[str, Any], headers: dict[str, str | int] | None = None
|
|
1075
|
+
) -> TGithubObject:
|
|
1076
|
+
"""
|
|
1077
|
+
Creates an object from raw_data previously obtained by :attr:`GithubObject.raw_data`, and optionally headers
|
|
1078
|
+
previously obtained by :attr:`GithubObject.raw_headers`.
|
|
1079
|
+
|
|
1080
|
+
:param klass: the class of the object to create
|
|
1081
|
+
:param raw_data: dict
|
|
1082
|
+
:param headers: dict
|
|
1083
|
+
:rtype: instance of class ``klass``
|
|
1084
|
+
|
|
1085
|
+
"""
|
|
1086
|
+
if headers is None:
|
|
1087
|
+
headers = {}
|
|
1088
|
+
|
|
1089
|
+
if issubclass(klass, CompletableGithubObject):
|
|
1090
|
+
return klass(self.__requester, headers, raw_data, completed=True) # type: ignore
|
|
1091
|
+
return klass(self.__requester, headers, raw_data)
|
|
1092
|
+
|
|
1093
|
+
async def dump(self, obj: GithubObject, file: BinaryIO, protocol: int = 0) -> None:
|
|
1094
|
+
"""
|
|
1095
|
+
Dumps (pickles) a PyGithub object to a file-like object. Some effort is made to not pickle sensitive
|
|
1096
|
+
information like the Github credentials used in the :class:`Github` instance. But NO EFFORT is made to remove
|
|
1097
|
+
sensitive information from the object's attributes.
|
|
1098
|
+
|
|
1099
|
+
:param obj: the object to pickle
|
|
1100
|
+
:param file: the file-like object to pickle to
|
|
1101
|
+
:param protocol: the `pickling protocol <https://python.readthedocs.io/en/latest/library/pickle.html#data-
|
|
1102
|
+
stream-format>`_
|
|
1103
|
+
|
|
1104
|
+
"""
|
|
1105
|
+
pickle.dump((obj.__class__, (await obj.raw_data), (await obj.raw_headers)), file, protocol)
|
|
1106
|
+
|
|
1107
|
+
def load(self, f: BinaryIO) -> Any:
|
|
1108
|
+
"""
|
|
1109
|
+
Loads (unpickles) a PyGithub object from a file-like object.
|
|
1110
|
+
|
|
1111
|
+
:param f: the file-like object to unpickle from
|
|
1112
|
+
:return: the unpickled object
|
|
1113
|
+
|
|
1114
|
+
"""
|
|
1115
|
+
return self.create_from_raw_data(*pickle.load(f))
|
|
1116
|
+
|
|
1117
|
+
def get_oauth_application(self, client_id: str, client_secret: str) -> ApplicationOAuth:
|
|
1118
|
+
return githubasyncio.ApplicationOAuth.ApplicationOAuth(
|
|
1119
|
+
self.__requester,
|
|
1120
|
+
headers={},
|
|
1121
|
+
attributes={"client_id": client_id, "client_secret": client_secret},
|
|
1122
|
+
)
|
|
1123
|
+
|
|
1124
|
+
async def get_app(self, slug: Opt[str] = NotSet) -> GithubApp:
|
|
1125
|
+
"""
|
|
1126
|
+
:calls: `GET /apps/{app_slug} <https://docs.github.com/en/rest/reference/apps>`_ or `GET /app <https://docs.github.com/en/rest/reference/apps>`_
|
|
1127
|
+
"""
|
|
1128
|
+
if is_undefined(slug):
|
|
1129
|
+
# with no slug given, calling /app returns the authenticated app,
|
|
1130
|
+
# including the actual /apps/{slug}
|
|
1131
|
+
warnings.warn(
|
|
1132
|
+
"Argument slug is mandatory, calling this method without the slug argument is deprecated, please use "
|
|
1133
|
+
"githubasyncio.GithubIntegration.GithubIntegration(auth=githubasyncio.Auth.AppAuth(...)).get_app() instead",
|
|
1134
|
+
category=DeprecationWarning,
|
|
1135
|
+
stacklevel=2,
|
|
1136
|
+
)
|
|
1137
|
+
return await GithubIntegration(**self.__requester.kwargs).get_app()
|
|
1138
|
+
else:
|
|
1139
|
+
assert isinstance(slug, str), slug
|
|
1140
|
+
# with a slug given, we can lazily load the GithubApp
|
|
1141
|
+
slug = urllib.parse.quote(slug, safe="")
|
|
1142
|
+
return githubasyncio.GithubApp.GithubApp(self.__requester, {}, {"url": f"/apps/{slug}"}, completed=False)
|