@@ -59,9 +59,21 @@ class GitHub(models.GitHubCore):
59
59
call the GitHub object with authentication parameters.
60
60
"""
61
61
62
- def __init__ (self , username = "" , password = "" , token = "" , session = None ):
63
- """Create a new GitHub instance to talk to the API."""
62
+ def __init__ (
63
+ self , username = "" , password = "" , token = "" , session = None , api_version = ""
64
+ ):
65
+ """Create a new GitHub instance to talk to the API.
66
+
67
+ :param str api_version:
68
+ API version to send with X-GitHub-Api-Version header.
69
+ See https://docs.github.com/en/rest/overview/api-versions
70
+ for details about API versions.
71
+ """
64
72
super ().__init__ ({}, session or self .new_session ())
73
+
74
+ if api_version :
75
+ self .session .headers .update ({"X-GitHub-Api-Version" : api_version })
76
+
65
77
if token :
66
78
self .login (username , token = token )
67
79
elif username and password :
@@ -2596,17 +2608,6 @@ def set_client_id(self, id, secret):
2596
2608
"""
2597
2609
self .session .params = {"client_id" : id , "client_secret" : secret }
2598
2610
2599
- def set_api_version (self , api_version ):
2600
- """Allow to set a specific API version.
2601
-
2602
- :param str api_version:
2603
- API version to send with X-GitHub-Api-Version header.
2604
- See https://docs.github.com/en/rest/overview/api-versions?apiVersion=2022-11-28 for details on API versions.
2605
- """ # noqa: E501
2606
- if not api_version :
2607
- return
2608
- self .session .headers .update ({"X-GitHub-Api-Version" : api_version })
2609
-
2610
2611
def set_user_agent (self , user_agent ):
2611
2612
"""Allow the user to set their own user agent string.
2612
2613
0 commit comments