Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite5afb55

Browse files
authored
Merge pull request#1034 from filipowm/feat/api-oauth-applications
feat(api): add support for GitLab OAuth Applications using Applications API
2 parentsfbcc820 +4e12356 commite5afb55

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

‎docs/api-objects.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ API examples
77

88
gl_objects/access_requests
99
gl_objects/appearance
10+
gl_objects/applications
1011
gl_objects/emojis
1112
gl_objects/badges
1213
gl_objects/branches

‎docs/gl_objects/applications.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
############
2+
Applications
3+
############
4+
5+
Reference
6+
---------
7+
8+
* v4 API:
9+
10+
+:class:`gitlab.v4.objects.Applications`
11+
+:class:`gitlab.v4.objects.ApplicationManager`
12+
+:attr:`gitlab.Gitlab.applications`
13+
14+
* GitLab API: https://docs.gitlab.com/ce/api/applications.html
15+
16+
Examples
17+
--------
18+
19+
List all OAuth applications::
20+
21+
applications = gl.applications.list()
22+
23+
Create an application::
24+
25+
gl.applications.create({'name': 'your_app', 'redirect_uri': 'http://application.url', 'scopes': ['api']})
26+
27+
Delete an applications::
28+
29+
gl.applications.delete(app_id)
30+
# or
31+
application.delete()

‎gitlab/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def __init__(
144144
self.features=objects.FeatureManager(self)
145145
self.pagesdomains=objects.PagesDomainManager(self)
146146
self.user_activities=objects.UserActivitiesManager(self)
147+
self.applications=objects.ApplicationManager(self)
147148

148149
def__enter__(self):
149150
returnself

‎gitlab/tests/test_gitlab.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,33 @@ def resp_import_github(url, request):
964964
self.assertEqual(ret["full_path"],"/".join((base_path,name)))
965965
self.assertTrue(ret["full_name"].endswith(name))
966966

967+
deftest_applications(self):
968+
content='{"name": "test_app", "redirect_uri": "http://localhost:8080", "scopes": ["api", "email"]}'
969+
json_content=json.loads(content)
970+
971+
@urlmatch(
972+
scheme="http",
973+
netloc="localhost",
974+
path="/api/v4/applications",
975+
method="post",
976+
)
977+
defresp_application_create(url,request):
978+
headers= {"content-type":"application/json"}
979+
returnresponse(200,json_content,headers,None,5,request)
980+
981+
withHTTMock(resp_application_create):
982+
application=self.gl.applications.create(
983+
{
984+
"name":"test_app",
985+
"redirect_uri":"http://localhost:8080",
986+
"scopes": ["api","email"],
987+
"confidential":False,
988+
}
989+
)
990+
self.assertEqual(application.name,"test_app")
991+
self.assertEqual(application.redirect_uri,"http://localhost:8080")
992+
self.assertEqual(application.scopes, ["api","email"])
993+
967994
def_default_config(self):
968995
fd,temp_path=tempfile.mkstemp()
969996
os.write(fd,valid_config)

‎gitlab/v4/objects.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5141,3 +5141,14 @@ def current_failures(self, **kwargs):
51415141
list: The list of failures
51425142
"""
51435143
returnself.gitlab.http_list("/geo_nodes/current/failures",**kwargs)
5144+
5145+
5146+
classApplication(ObjectDeleteMixin,RESTObject):
5147+
_url="/applications"
5148+
_short_print_attr="name"
5149+
5150+
5151+
classApplicationManager(ListMixin,CreateMixin,DeleteMixin,RESTManager):
5152+
_path="/applications"
5153+
_obj_cls=Application
5154+
_create_attrs= (("name","redirect_uri","scopes"), ("confidential",))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp