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

Commita5a48ad

Browse files
committed
refactor(v4): split objects and managers per API resource
1 parent9d6c188 commita5a48ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6167
-5850
lines changed

‎gitlab/v4/objects/__init__.py

Lines changed: 57 additions & 5850 deletions
Large diffs are not rendered by default.

‎gitlab/v4/objects/access_requests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fromgitlab.baseimport*# noqa
2+
fromgitlab.mixinsimport*# noqa
3+
4+
5+
classGroupAccessRequest(AccessRequestMixin,ObjectDeleteMixin,RESTObject):
6+
pass
7+
8+
9+
classGroupAccessRequestManager(ListMixin,CreateMixin,DeleteMixin,RESTManager):
10+
_path="/groups/%(group_id)s/access_requests"
11+
_obj_cls=GroupAccessRequest
12+
_from_parent_attrs= {"group_id":"id"}
13+
14+
15+
classProjectAccessRequest(AccessRequestMixin,ObjectDeleteMixin,RESTObject):
16+
pass
17+
18+
19+
classProjectAccessRequestManager(ListMixin,CreateMixin,DeleteMixin,RESTManager):
20+
_path="/projects/%(project_id)s/access_requests"
21+
_obj_cls=ProjectAccessRequest
22+
_from_parent_attrs= {"project_id":"id"}

‎gitlab/v4/objects/appearance.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
fromgitlabimportexceptionsasexc
2+
fromgitlab.baseimport*# noqa
3+
fromgitlab.mixinsimport*# noqa
4+
5+
6+
classApplicationAppearance(SaveMixin,RESTObject):
7+
_id_attr=None
8+
9+
10+
classApplicationAppearanceManager(GetWithoutIdMixin,UpdateMixin,RESTManager):
11+
_path="/application/appearance"
12+
_obj_cls=ApplicationAppearance
13+
_update_attrs= (
14+
tuple(),
15+
(
16+
"title",
17+
"description",
18+
"logo",
19+
"header_logo",
20+
"favicon",
21+
"new_project_guidelines",
22+
"header_message",
23+
"footer_message",
24+
"message_background_color",
25+
"message_font_color",
26+
"email_header_and_footer_enabled",
27+
),
28+
)
29+
30+
@exc.on_http_error(exc.GitlabUpdateError)
31+
defupdate(self,id=None,new_data=None,**kwargs):
32+
"""Update an object on the server.
33+
34+
Args:
35+
id: ID of the object to update (can be None if not required)
36+
new_data: the update data for the object
37+
**kwargs: Extra options to send to the server (e.g. sudo)
38+
39+
Returns:
40+
dict: The new object data (*not* a RESTObject)
41+
42+
Raises:
43+
GitlabAuthenticationError: If authentication is not correct
44+
GitlabUpdateError: If the server cannot perform the request
45+
"""
46+
new_data=new_dataor {}
47+
data=new_data.copy()
48+
super(ApplicationAppearanceManager,self).update(id,data,**kwargs)

‎gitlab/v4/objects/applications.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
fromgitlab.baseimport*# noqa
2+
fromgitlab.mixinsimport*# noqa
3+
4+
5+
classApplication(ObjectDeleteMixin,RESTObject):
6+
_url="/applications"
7+
_short_print_attr="name"
8+
9+
10+
classApplicationManager(ListMixin,CreateMixin,DeleteMixin,RESTManager):
11+
_path="/applications"
12+
_obj_cls=Application
13+
_create_attrs= (("name","redirect_uri","scopes"), ("confidential",))

‎gitlab/v4/objects/award_emojis.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
fromgitlab.baseimport*# noqa
2+
fromgitlab.mixinsimport*# noqa
3+
4+
5+
classProjectIssueAwardEmoji(ObjectDeleteMixin,RESTObject):
6+
pass
7+
8+
9+
classProjectIssueAwardEmojiManager(NoUpdateMixin,RESTManager):
10+
_path="/projects/%(project_id)s/issues/%(issue_iid)s/award_emoji"
11+
_obj_cls=ProjectIssueAwardEmoji
12+
_from_parent_attrs= {"project_id":"project_id","issue_iid":"iid"}
13+
_create_attrs= (("name",),tuple())
14+
15+
16+
classProjectIssueNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
17+
pass
18+
19+
20+
classProjectIssueNoteAwardEmojiManager(NoUpdateMixin,RESTManager):
21+
_path= (
22+
"/projects/%(project_id)s/issues/%(issue_iid)s""/notes/%(note_id)s/award_emoji"
23+
)
24+
_obj_cls=ProjectIssueNoteAwardEmoji
25+
_from_parent_attrs= {
26+
"project_id":"project_id",
27+
"issue_iid":"issue_iid",
28+
"note_id":"id",
29+
}
30+
_create_attrs= (("name",),tuple())
31+
32+
33+
classProjectMergeRequestAwardEmoji(ObjectDeleteMixin,RESTObject):
34+
pass
35+
36+
37+
classProjectMergeRequestAwardEmojiManager(NoUpdateMixin,RESTManager):
38+
_path="/projects/%(project_id)s/merge_requests/%(mr_iid)s/award_emoji"
39+
_obj_cls=ProjectMergeRequestAwardEmoji
40+
_from_parent_attrs= {"project_id":"project_id","mr_iid":"iid"}
41+
_create_attrs= (("name",),tuple())
42+
43+
44+
classProjectMergeRequestNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
45+
pass
46+
47+
48+
classProjectMergeRequestNoteAwardEmojiManager(NoUpdateMixin,RESTManager):
49+
_path= (
50+
"/projects/%(project_id)s/merge_requests/%(mr_iid)s"
51+
"/notes/%(note_id)s/award_emoji"
52+
)
53+
_obj_cls=ProjectMergeRequestNoteAwardEmoji
54+
_from_parent_attrs= {
55+
"project_id":"project_id",
56+
"mr_iid":"mr_iid",
57+
"note_id":"id",
58+
}
59+
_create_attrs= (("name",),tuple())
60+
61+
62+
classProjectSnippetAwardEmoji(ObjectDeleteMixin,RESTObject):
63+
pass
64+
65+
66+
classProjectSnippetAwardEmojiManager(NoUpdateMixin,RESTManager):
67+
_path="/projects/%(project_id)s/snippets/%(snippet_id)s/award_emoji"
68+
_obj_cls=ProjectSnippetAwardEmoji
69+
_from_parent_attrs= {"project_id":"project_id","snippet_id":"id"}
70+
_create_attrs= (("name",),tuple())
71+
72+
73+
classProjectSnippetNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
74+
pass
75+
76+
77+
classProjectSnippetNoteAwardEmojiManager(NoUpdateMixin,RESTManager):
78+
_path= (
79+
"/projects/%(project_id)s/snippets/%(snippet_id)s"
80+
"/notes/%(note_id)s/award_emoji"
81+
)
82+
_obj_cls=ProjectSnippetNoteAwardEmoji
83+
_from_parent_attrs= {
84+
"project_id":"project_id",
85+
"snippet_id":"snippet_id",
86+
"note_id":"id",
87+
}
88+
_create_attrs= (("name",),tuple())

‎gitlab/v4/objects/badges.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
fromgitlab.baseimport*# noqa
2+
fromgitlab.mixinsimport*# noqa
3+
4+
5+
classGroupBadge(SaveMixin,ObjectDeleteMixin,RESTObject):
6+
pass
7+
8+
9+
classGroupBadgeManager(BadgeRenderMixin,CRUDMixin,RESTManager):
10+
_path="/groups/%(group_id)s/badges"
11+
_obj_cls=GroupBadge
12+
_from_parent_attrs= {"group_id":"id"}
13+
_create_attrs= (("link_url","image_url"),tuple())
14+
_update_attrs= (tuple(), ("link_url","image_url"))
15+
16+
17+
classProjectBadge(SaveMixin,ObjectDeleteMixin,RESTObject):
18+
pass
19+
20+
21+
classProjectBadgeManager(BadgeRenderMixin,CRUDMixin,RESTManager):
22+
_path="/projects/%(project_id)s/badges"
23+
_obj_cls=ProjectBadge
24+
_from_parent_attrs= {"project_id":"id"}
25+
_create_attrs= (("link_url","image_url"),tuple())
26+
_update_attrs= (tuple(), ("link_url","image_url"))

‎gitlab/v4/objects/boards.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
fromgitlab.baseimport*# noqa
2+
fromgitlab.mixinsimport*# noqa
3+
4+
5+
classGroupBoardList(SaveMixin,ObjectDeleteMixin,RESTObject):
6+
pass
7+
8+
9+
classGroupBoardListManager(CRUDMixin,RESTManager):
10+
_path="/groups/%(group_id)s/boards/%(board_id)s/lists"
11+
_obj_cls=GroupBoardList
12+
_from_parent_attrs= {"group_id":"group_id","board_id":"id"}
13+
_create_attrs= (("label_id",),tuple())
14+
_update_attrs= (("position",),tuple())
15+
16+
17+
classGroupBoard(SaveMixin,ObjectDeleteMixin,RESTObject):
18+
_managers= (("lists","GroupBoardListManager"),)
19+
20+
21+
classGroupBoardManager(CRUDMixin,RESTManager):
22+
_path="/groups/%(group_id)s/boards"
23+
_obj_cls=GroupBoard
24+
_from_parent_attrs= {"group_id":"id"}
25+
_create_attrs= (("name",),tuple())
26+
27+
28+
classProjectBoardList(SaveMixin,ObjectDeleteMixin,RESTObject):
29+
pass
30+
31+
32+
classProjectBoardListManager(CRUDMixin,RESTManager):
33+
_path="/projects/%(project_id)s/boards/%(board_id)s/lists"
34+
_obj_cls=ProjectBoardList
35+
_from_parent_attrs= {"project_id":"project_id","board_id":"id"}
36+
_create_attrs= (("label_id",),tuple())
37+
_update_attrs= (("position",),tuple())
38+
39+
40+
classProjectBoard(SaveMixin,ObjectDeleteMixin,RESTObject):
41+
_managers= (("lists","ProjectBoardListManager"),)
42+
43+
44+
classProjectBoardManager(CRUDMixin,RESTManager):
45+
_path="/projects/%(project_id)s/boards"
46+
_obj_cls=ProjectBoard
47+
_from_parent_attrs= {"project_id":"id"}
48+
_create_attrs= (("name",),tuple())

‎gitlab/v4/objects/branches.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
fromgitlabimportcli
2+
fromgitlabimportexceptionsasexc
3+
fromgitlab.baseimport*# noqa
4+
fromgitlab.mixinsimport*# noqa
5+
6+
7+
classProjectBranch(ObjectDeleteMixin,RESTObject):
8+
_id_attr="name"
9+
10+
@cli.register_custom_action(
11+
"ProjectBranch",tuple(), ("developers_can_push","developers_can_merge")
12+
)
13+
@exc.on_http_error(exc.GitlabProtectError)
14+
defprotect(self,developers_can_push=False,developers_can_merge=False,**kwargs):
15+
"""Protect the branch.
16+
17+
Args:
18+
developers_can_push (bool): Set to True if developers are allowed
19+
to push to the branch
20+
developers_can_merge (bool): Set to True if developers are allowed
21+
to merge to the branch
22+
**kwargs: Extra options to send to the server (e.g. sudo)
23+
24+
Raises:
25+
GitlabAuthenticationError: If authentication is not correct
26+
GitlabProtectError: If the branch could not be protected
27+
"""
28+
id=self.get_id().replace("/","%2F")
29+
path="%s/%s/protect"% (self.manager.path,id)
30+
post_data= {
31+
"developers_can_push":developers_can_push,
32+
"developers_can_merge":developers_can_merge,
33+
}
34+
self.manager.gitlab.http_put(path,post_data=post_data,**kwargs)
35+
self._attrs["protected"]=True
36+
37+
@cli.register_custom_action("ProjectBranch")
38+
@exc.on_http_error(exc.GitlabProtectError)
39+
defunprotect(self,**kwargs):
40+
"""Unprotect the branch.
41+
42+
Args:
43+
**kwargs: Extra options to send to the server (e.g. sudo)
44+
45+
Raises:
46+
GitlabAuthenticationError: If authentication is not correct
47+
GitlabProtectError: If the branch could not be unprotected
48+
"""
49+
id=self.get_id().replace("/","%2F")
50+
path="%s/%s/unprotect"% (self.manager.path,id)
51+
self.manager.gitlab.http_put(path,**kwargs)
52+
self._attrs["protected"]=False
53+
54+
55+
classProjectBranchManager(NoUpdateMixin,RESTManager):
56+
_path="/projects/%(project_id)s/repository/branches"
57+
_obj_cls=ProjectBranch
58+
_from_parent_attrs= {"project_id":"id"}
59+
_create_attrs= (("branch","ref"),tuple())
60+
61+
62+
classProjectProtectedBranch(ObjectDeleteMixin,RESTObject):
63+
_id_attr="name"
64+
65+
66+
classProjectProtectedBranchManager(NoUpdateMixin,RESTManager):
67+
_path="/projects/%(project_id)s/protected_branches"
68+
_obj_cls=ProjectProtectedBranch
69+
_from_parent_attrs= {"project_id":"id"}
70+
_create_attrs= (
71+
("name",),
72+
(
73+
"push_access_level",
74+
"merge_access_level",
75+
"unprotect_access_level",
76+
"allowed_to_push",
77+
"allowed_to_merge",
78+
"allowed_to_unprotect",
79+
),
80+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
fromgitlab.baseimport*# noqa
2+
fromgitlab.mixinsimport*# noqa
3+
4+
5+
classBroadcastMessage(SaveMixin,ObjectDeleteMixin,RESTObject):
6+
pass
7+
8+
9+
classBroadcastMessageManager(CRUDMixin,RESTManager):
10+
_path="/broadcast_messages"
11+
_obj_cls=BroadcastMessage
12+
13+
_create_attrs= (("message",), ("starts_at","ends_at","color","font"))
14+
_update_attrs= (tuple(), ("message","starts_at","ends_at","color","font"))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp