| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ API examples | |||
| 7 | 7 | ||
| 8 | 8 | gl_objects/access_requests | |
| 9 | 9 | gl_objects/appearance | |
| 10 | + gl_objects/applications | ||
| 10 | 11 | gl_objects/emojis | |
| 11 | 12 | gl_objects/badges | |
| 12 | 13 | gl_objects/branches | |
| Original file line number | Diff line number | Diff 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() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -144,6 +144,7 @@ def __init__( | |||
| 144 | 144 | self.features = objects.FeatureManager(self) | |
| 145 | 145 | self.pagesdomains = objects.PagesDomainManager(self) | |
| 146 | 146 | self.user_activities = objects.UserActivitiesManager(self) | |
| 147 | + self.applications = objects.ApplicationManager(self) | ||
| 147 | 148 | ||
| 148 | 149 | def __enter__(self): | |
| 149 | 150 | return self | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -964,6 +964,33 @@ def resp_import_github(url, request): | |||
| 964 | 964 | self.assertEqual(ret["full_path"], "/".join((base_path, name))) | |
| 965 | 965 | self.assertTrue(ret["full_name"].endswith(name)) | |
| 966 | 966 | ||
| 967 | + def test_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 | + def resp_application_create(url, request): | ||
| 978 | + headers = {"content-type": "application/json"} | ||
| 979 | + return response(200, json_content, headers, None, 5, request) | ||
| 980 | + | ||
| 981 | + with HTTMock(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 | + | ||
| 967 | 994 | def _default_config(self): | |
| 968 | 995 | fd, temp_path = tempfile.mkstemp() | |
| 969 | 996 | os.write(fd, valid_config) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5141,3 +5141,14 @@ def current_failures(self, **kwargs): | |||
| 5141 | 5141 | list: The list of failures | |
| 5142 | 5142 | """ | |
| 5143 | 5143 | return self.gitlab.http_list("/geo_nodes/current/failures", **kwargs) | |
| 5144 | + | ||
| 5145 | + | ||
| 5146 | + class Application(ObjectDeleteMixin, RESTObject): | ||
| 5147 | + _url = "/applications" | ||
| 5148 | + _short_print_attr = "name" | ||
| 5149 | + | ||
| 5150 | + | ||
| 5151 | + class ApplicationManager(ListMixin, CreateMixin, DeleteMixin, RESTManager): | ||
| 5152 | + _path = "/applications" | ||
| 5153 | + _obj_cls = Application | ||
| 5154 | + _create_attrs = (("name", "redirect_uri", "scopes"), ("confidential",)) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments