clear-skies-gitlab 2.0.4__py3-none-any.whl → 2.0.6__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.
- {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/METADATA +1 -1
- {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/RECORD +34 -34
- clearskies_gitlab/defaults/gitlab_default_auth.py +33 -2
- clearskies_gitlab/defaults/gitlab_default_host.py +31 -2
- clearskies_gitlab/rest/backends/gitlab_rest_backend.py +98 -80
- clearskies_gitlab/rest/gitlab_branch_rule.py +74 -1
- clearskies_gitlab/rest/gitlab_cicd_variable.py +78 -1
- clearskies_gitlab/rest/gitlab_member.py +80 -1
- clearskies_gitlab/rest/models/gitlab_rest_advanced_search.py +67 -1
- clearskies_gitlab/rest/models/gitlab_rest_advanced_search_blob.py +72 -1
- clearskies_gitlab/rest/models/gitlab_rest_current_user.py +134 -1
- clearskies_gitlab/rest/models/gitlab_rest_group.py +60 -1
- clearskies_gitlab/rest/models/gitlab_rest_group_access_token.py +102 -1
- clearskies_gitlab/rest/models/gitlab_rest_group_base.py +305 -1
- clearskies_gitlab/rest/models/gitlab_rest_group_member.py +64 -1
- clearskies_gitlab/rest/models/gitlab_rest_group_project.py +27 -1
- clearskies_gitlab/rest/models/gitlab_rest_group_search.py +30 -1
- clearskies_gitlab/rest/models/gitlab_rest_group_search_blob.py +27 -1
- clearskies_gitlab/rest/models/gitlab_rest_group_subgroup.py +54 -17
- clearskies_gitlab/rest/models/gitlab_rest_group_variable.py +44 -1
- clearskies_gitlab/rest/models/gitlab_rest_namespace.py +178 -1
- clearskies_gitlab/rest/models/gitlab_rest_project.py +501 -3
- clearskies_gitlab/rest/models/gitlab_rest_project_approval_config.py +90 -2
- clearskies_gitlab/rest/models/gitlab_rest_project_approval_rule.py +92 -1
- clearskies_gitlab/rest/models/gitlab_rest_project_member.py +62 -1
- clearskies_gitlab/rest/models/gitlab_rest_project_protected_branch.py +132 -1
- clearskies_gitlab/rest/models/gitlab_rest_project_repository_commit.py +144 -2
- clearskies_gitlab/rest/models/gitlab_rest_project_repository_commit_diff.py +89 -2
- clearskies_gitlab/rest/models/gitlab_rest_project_repository_contributor.py +68 -2
- clearskies_gitlab/rest/models/gitlab_rest_project_repository_file.py +90 -1
- clearskies_gitlab/rest/models/gitlab_rest_project_repository_file_raw.py +57 -3
- clearskies_gitlab/rest/models/gitlab_rest_project_variable.py +46 -1
- {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/WHEEL +0 -0
- {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/licenses/LICENSE +0 -0
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from typing import Self
|
|
4
4
|
|
|
5
5
|
from clearskies import Model
|
|
6
|
-
from clearskies.columns import BelongsToId, BelongsToModel, Boolean
|
|
6
|
+
from clearskies.columns import BelongsToId, BelongsToModel, Boolean, Integer
|
|
7
7
|
|
|
8
8
|
from clearskies_gitlab.rest.backends import GitlabRestBackend
|
|
9
9
|
from clearskies_gitlab.rest.models import gitlab_rest_project_reference
|
|
@@ -12,7 +12,32 @@ from clearskies_gitlab.rest.models import gitlab_rest_project_reference
|
|
|
12
12
|
class GitlabRestProjectApprovalConfig(
|
|
13
13
|
Model,
|
|
14
14
|
):
|
|
15
|
-
"""
|
|
15
|
+
"""
|
|
16
|
+
Model for GitLab project approval configuration.
|
|
17
|
+
|
|
18
|
+
This model provides access to the GitLab Merge Request Approvals API for
|
|
19
|
+
configuring project-level approval settings. These settings control how
|
|
20
|
+
merge request approvals work across the entire project.
|
|
21
|
+
|
|
22
|
+
See https://docs.gitlab.com/api/merge_request_approvals/#get-configuration for more details.
|
|
23
|
+
|
|
24
|
+
Example usage:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from clearskies_gitlab.rest.models import GitlabRestProjectApprovalConfig
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def my_function(approval_configs: GitlabRestProjectApprovalConfig):
|
|
31
|
+
# Get approval config for a specific project
|
|
32
|
+
config = approval_configs.find("project_id=123")
|
|
33
|
+
if config:
|
|
34
|
+
print(f"Reset approvals on push: {config.reset_approvals_on_push}")
|
|
35
|
+
print(f"Author can approve: {config.merge_requests_author_approval}")
|
|
36
|
+
|
|
37
|
+
# Update approval settings
|
|
38
|
+
config.save({"reset_approvals_on_push": True, "merge_requests_author_approval": False})
|
|
39
|
+
```
|
|
40
|
+
"""
|
|
16
41
|
|
|
17
42
|
backend = GitlabRestBackend()
|
|
18
43
|
|
|
@@ -21,14 +46,77 @@ class GitlabRestProjectApprovalConfig(
|
|
|
21
46
|
"""Return the slug of the api endpoint for this model."""
|
|
22
47
|
return "projects/:project_id/approvals"
|
|
23
48
|
|
|
49
|
+
"""
|
|
50
|
+
The ID of the project this configuration belongs to.
|
|
51
|
+
"""
|
|
24
52
|
project_id = BelongsToId(gitlab_rest_project_reference.GitlabRestProjectReference)
|
|
53
|
+
|
|
54
|
+
"""
|
|
55
|
+
The project model this configuration belongs to.
|
|
56
|
+
"""
|
|
25
57
|
project = BelongsToModel("project_id")
|
|
26
58
|
|
|
27
59
|
id_column_name = "project_id"
|
|
28
60
|
|
|
61
|
+
"""
|
|
62
|
+
Whether to reset approvals when new commits are pushed.
|
|
63
|
+
|
|
64
|
+
When enabled, any existing approvals are removed when new commits
|
|
65
|
+
are pushed to the merge request.
|
|
66
|
+
"""
|
|
29
67
|
reset_approvals_on_push = Boolean()
|
|
68
|
+
|
|
69
|
+
"""
|
|
70
|
+
Whether users must enter their password to approve.
|
|
71
|
+
|
|
72
|
+
Adds an extra layer of security by requiring password confirmation.
|
|
73
|
+
"""
|
|
30
74
|
require_user_password_for_approval = Boolean()
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
Whether to prevent overriding approvers per merge request.
|
|
78
|
+
|
|
79
|
+
When enabled, the project-level approval rules cannot be modified
|
|
80
|
+
on individual merge requests.
|
|
81
|
+
"""
|
|
31
82
|
disable_overriding_approvers_per_merge_request = Boolean()
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
Whether merge request authors can approve their own requests.
|
|
86
|
+
|
|
87
|
+
When enabled, the author of a merge request can also approve it.
|
|
88
|
+
"""
|
|
32
89
|
merge_requests_author_approval = Boolean()
|
|
90
|
+
|
|
91
|
+
"""
|
|
92
|
+
Whether committers are prevented from approving.
|
|
93
|
+
|
|
94
|
+
When enabled, users who have committed to the merge request
|
|
95
|
+
cannot approve it.
|
|
96
|
+
"""
|
|
33
97
|
merge_requests_disable_committers_approval = Boolean()
|
|
98
|
+
|
|
99
|
+
"""
|
|
100
|
+
Whether reauthentication is required to approve.
|
|
101
|
+
|
|
102
|
+
When enabled, users must reauthenticate before they can approve
|
|
103
|
+
a merge request.
|
|
104
|
+
"""
|
|
34
105
|
require_reauthentication_to_approve = Boolean()
|
|
106
|
+
|
|
107
|
+
"""
|
|
108
|
+
Whether to reset approvals from Code Owners if their files change.
|
|
109
|
+
|
|
110
|
+
When enabled, approvals from Code Owners are reset when files they
|
|
111
|
+
own are modified. Note: To use this field, reset_approvals_on_push
|
|
112
|
+
must be False.
|
|
113
|
+
"""
|
|
114
|
+
selective_code_owner_removals = Boolean()
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
The number of required approvals before a merge request can merge.
|
|
118
|
+
|
|
119
|
+
Deprecated in GitLab 12.3. Use Approval Rules instead.
|
|
120
|
+
This field is still returned by the API for backwards compatibility.
|
|
121
|
+
"""
|
|
122
|
+
approvals_before_merge = Integer()
|
|
@@ -15,7 +15,34 @@ from clearskies_gitlab.rest.models import gitlab_rest_project_reference
|
|
|
15
15
|
class GitlabRestProjectApprovalRule(
|
|
16
16
|
Model,
|
|
17
17
|
):
|
|
18
|
-
"""
|
|
18
|
+
"""
|
|
19
|
+
Model for GitLab project approval rules.
|
|
20
|
+
|
|
21
|
+
This model provides access to the GitLab Merge Request Approval Rules API
|
|
22
|
+
for managing project-level approval rules. Approval rules define who must
|
|
23
|
+
approve merge requests and how many approvals are required.
|
|
24
|
+
|
|
25
|
+
See https://docs.gitlab.com/api/merge_request_approvals/#get-project-level-rules for more details.
|
|
26
|
+
|
|
27
|
+
Example usage:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from clearskies_gitlab.rest.models import GitlabRestProjectApprovalRule
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def my_function(approval_rules: GitlabRestProjectApprovalRule):
|
|
34
|
+
# List all approval rules for a project
|
|
35
|
+
for rule in approval_rules.where("project_id=123"):
|
|
36
|
+
print(f"Rule: {rule.name}")
|
|
37
|
+
print(f"Approvals required: {rule.approvals_required}")
|
|
38
|
+
print(f"Type: {rule.type}")
|
|
39
|
+
|
|
40
|
+
# Find a specific rule
|
|
41
|
+
code_owner_rule = approval_rules.find("project_id=123&type=code_owner")
|
|
42
|
+
if code_owner_rule:
|
|
43
|
+
print(f"Code owner approvers: {code_owner_rule.eligible_approvers}")
|
|
44
|
+
```
|
|
45
|
+
"""
|
|
19
46
|
|
|
20
47
|
backend = GitlabRestBackend()
|
|
21
48
|
|
|
@@ -26,17 +53,81 @@ class GitlabRestProjectApprovalRule(
|
|
|
26
53
|
|
|
27
54
|
id_column_name = "id"
|
|
28
55
|
|
|
56
|
+
"""
|
|
57
|
+
The display name of the approval rule.
|
|
58
|
+
"""
|
|
29
59
|
name = String()
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
The unique identifier for the approval rule.
|
|
63
|
+
"""
|
|
30
64
|
id = Integer()
|
|
65
|
+
|
|
66
|
+
"""
|
|
67
|
+
The type of approval rule.
|
|
68
|
+
|
|
69
|
+
Values:
|
|
70
|
+
- "regular": A standard approval rule
|
|
71
|
+
- "code_owner": Automatically created from CODEOWNERS file
|
|
72
|
+
- "report_approver": Created from security/compliance reports
|
|
73
|
+
"""
|
|
31
74
|
type = Select(allowed_values=["regular", "code_owner", "report_approver"])
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
The number of approvals required for this rule.
|
|
78
|
+
"""
|
|
32
79
|
approvals_required = Integer()
|
|
80
|
+
|
|
81
|
+
"""
|
|
82
|
+
Whether this rule applies to all protected branches.
|
|
83
|
+
|
|
84
|
+
When true, the rule is enforced on all protected branches.
|
|
85
|
+
When false, it only applies to specific protected branches.
|
|
86
|
+
"""
|
|
33
87
|
applies_to_all_protected_branches = Boolean()
|
|
34
88
|
|
|
89
|
+
"""
|
|
90
|
+
The ID of the project this rule belongs to.
|
|
91
|
+
"""
|
|
35
92
|
project_id = BelongsToId(gitlab_rest_project_reference.GitlabRestProjectReference)
|
|
93
|
+
|
|
94
|
+
"""
|
|
95
|
+
The project model this rule belongs to.
|
|
96
|
+
"""
|
|
36
97
|
project = BelongsToModel("project_id")
|
|
37
98
|
|
|
99
|
+
"""
|
|
100
|
+
List of users who can approve merge requests under this rule.
|
|
101
|
+
|
|
102
|
+
Contains user objects with id, name, username, etc.
|
|
103
|
+
"""
|
|
38
104
|
eligible_approvers = Json()
|
|
105
|
+
|
|
106
|
+
"""
|
|
107
|
+
List of users assigned to this approval rule.
|
|
108
|
+
|
|
109
|
+
Contains user objects with id, name, username, etc.
|
|
110
|
+
"""
|
|
39
111
|
users = Json()
|
|
112
|
+
|
|
113
|
+
"""
|
|
114
|
+
List of groups assigned to this approval rule.
|
|
115
|
+
|
|
116
|
+
Contains group objects with id, name, path, etc.
|
|
117
|
+
"""
|
|
40
118
|
groups = Json()
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
List of protected branches this rule applies to.
|
|
122
|
+
|
|
123
|
+
Only populated when applies_to_all_protected_branches is false.
|
|
124
|
+
Contains branch objects with id, name, etc.
|
|
125
|
+
"""
|
|
41
126
|
protected_branches = Json()
|
|
127
|
+
|
|
128
|
+
"""
|
|
129
|
+
Whether this rule contains hidden groups.
|
|
130
|
+
|
|
131
|
+
Hidden groups are groups the current user doesn't have access to view.
|
|
132
|
+
"""
|
|
42
133
|
contains_hidden_groups = Boolean()
|
|
@@ -11,7 +11,41 @@ from clearskies_gitlab.rest.backends import GitlabRestBackend
|
|
|
11
11
|
class GitlabRestProjectMember(
|
|
12
12
|
gitlab_member.GitlabMember,
|
|
13
13
|
):
|
|
14
|
-
"""
|
|
14
|
+
"""
|
|
15
|
+
Model for GitLab project members.
|
|
16
|
+
|
|
17
|
+
This model provides access to the GitLab Project Members API for managing
|
|
18
|
+
project membership. It extends the base GitlabMember class with project-specific
|
|
19
|
+
functionality.
|
|
20
|
+
|
|
21
|
+
See https://docs.gitlab.com/api/members/ for more details.
|
|
22
|
+
|
|
23
|
+
Example usage:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from clearskies_gitlab.rest.models import GitlabRestProjectMember
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def my_function(members: GitlabRestProjectMember):
|
|
30
|
+
# List all members of a project
|
|
31
|
+
for member in members.where("project_id=123"):
|
|
32
|
+
print(f"Member: {member.username}")
|
|
33
|
+
print(f"Access level: {member.access_level}")
|
|
34
|
+
|
|
35
|
+
# Search for specific members
|
|
36
|
+
for member in members.where("project_id=123&query=john"):
|
|
37
|
+
print(f"Found: {member.name}")
|
|
38
|
+
|
|
39
|
+
# Add a new member
|
|
40
|
+
members.create(
|
|
41
|
+
{
|
|
42
|
+
"project_id": 123,
|
|
43
|
+
"user_id": 456,
|
|
44
|
+
"access_level": 30, # Developer
|
|
45
|
+
}
|
|
46
|
+
)
|
|
47
|
+
```
|
|
48
|
+
"""
|
|
15
49
|
|
|
16
50
|
backend = GitlabRestBackend()
|
|
17
51
|
id_column_name = "id"
|
|
@@ -21,9 +55,36 @@ class GitlabRestProjectMember(
|
|
|
21
55
|
"""Return the slug of the api endpoint for this model."""
|
|
22
56
|
return "projects/:project_id/members"
|
|
23
57
|
|
|
58
|
+
"""
|
|
59
|
+
The ID of the project to query members for.
|
|
60
|
+
"""
|
|
24
61
|
project_id = String()
|
|
62
|
+
|
|
63
|
+
"""
|
|
64
|
+
Search query to filter members by name or username.
|
|
65
|
+
"""
|
|
25
66
|
query = String()
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
List of user IDs to filter results.
|
|
70
|
+
"""
|
|
26
71
|
user_ids = Json()
|
|
72
|
+
|
|
73
|
+
"""
|
|
74
|
+
List of user IDs to exclude from results.
|
|
75
|
+
"""
|
|
27
76
|
skip_users = Json()
|
|
77
|
+
|
|
78
|
+
"""
|
|
79
|
+
Whether to include seat information in the response.
|
|
80
|
+
|
|
81
|
+
Only available for groups with a paid plan.
|
|
82
|
+
"""
|
|
28
83
|
show_seat_info = Boolean()
|
|
84
|
+
|
|
85
|
+
"""
|
|
86
|
+
Whether to include inherited members.
|
|
87
|
+
|
|
88
|
+
When true, includes members inherited from parent groups.
|
|
89
|
+
"""
|
|
29
90
|
all = Boolean()
|
|
@@ -12,7 +12,33 @@ from clearskies_gitlab.rest.models import gitlab_rest_project_reference
|
|
|
12
12
|
class GitlabRestProjectProtectedBranch(
|
|
13
13
|
Model,
|
|
14
14
|
):
|
|
15
|
-
"""
|
|
15
|
+
"""
|
|
16
|
+
Model for GitLab project protected branches.
|
|
17
|
+
|
|
18
|
+
This model represents a protected branch in a GitLab project. Protected branches are used to
|
|
19
|
+
prevent unauthorized changes to important branches and enforce code review policies.
|
|
20
|
+
|
|
21
|
+
See https://docs.gitlab.com/api/protected_branches/ for more details.
|
|
22
|
+
|
|
23
|
+
Example usage:
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from clearskies_gitlab.rest.models import GitlabRestProjectProtectedBranch
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def my_function(protected_branches: GitlabRestProjectProtectedBranch):
|
|
30
|
+
# List all protected branches for a project
|
|
31
|
+
for branch in protected_branches.where("project_id=123"):
|
|
32
|
+
print(f"Branch: {branch.name}, Force push allowed: {branch.allow_force_push}")
|
|
33
|
+
|
|
34
|
+
# Find a specific protected branch
|
|
35
|
+
main_branch = protected_branches.find("name=main")
|
|
36
|
+
if main_branch:
|
|
37
|
+
print(
|
|
38
|
+
f"Main branch requires code owner approval: {main_branch.code_owner_approval_required}"
|
|
39
|
+
)
|
|
40
|
+
```
|
|
41
|
+
"""
|
|
16
42
|
|
|
17
43
|
@classmethod
|
|
18
44
|
def destination_name(cls: type[Self]) -> str:
|
|
@@ -23,13 +49,118 @@ class GitlabRestProjectProtectedBranch(
|
|
|
23
49
|
|
|
24
50
|
backend = GitlabRestBackend()
|
|
25
51
|
|
|
52
|
+
"""
|
|
53
|
+
The ID of the protected branch.
|
|
54
|
+
"""
|
|
26
55
|
id = Integer()
|
|
56
|
+
|
|
57
|
+
"""
|
|
58
|
+
The name of the protected branch or wildcard pattern.
|
|
59
|
+
|
|
60
|
+
Can be an exact branch name (e.g., "main") or a wildcard pattern (e.g., "release/*").
|
|
61
|
+
"""
|
|
27
62
|
name = String()
|
|
63
|
+
|
|
64
|
+
"""
|
|
65
|
+
Whether force push is allowed on this protected branch.
|
|
66
|
+
|
|
67
|
+
If `True`, users with push access can force push to this branch.
|
|
68
|
+
"""
|
|
28
69
|
allow_force_push = Boolean()
|
|
70
|
+
|
|
71
|
+
"""
|
|
72
|
+
Whether code owner approval is required for pushes to this branch.
|
|
73
|
+
|
|
74
|
+
If `True`, code owners must approve changes before they can be merged.
|
|
75
|
+
This feature is available in GitLab Premium and Ultimate.
|
|
76
|
+
"""
|
|
29
77
|
code_owner_approval_required = Boolean()
|
|
78
|
+
|
|
79
|
+
"""
|
|
80
|
+
Whether the protection settings are inherited from the parent group.
|
|
81
|
+
|
|
82
|
+
If `True`, the protection settings were inherited from the project's parent group.
|
|
83
|
+
This field is only available in GitLab Premium and Ultimate.
|
|
84
|
+
"""
|
|
85
|
+
inherited = Boolean()
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
Array of merge access level configurations.
|
|
89
|
+
|
|
90
|
+
Each entry in the array contains:
|
|
91
|
+
- `id`: ID of the merge access level configuration
|
|
92
|
+
- `access_level`: Access level for merging (e.g., 40 for Maintainers)
|
|
93
|
+
- `access_level_description`: Human-readable description of the access level
|
|
94
|
+
- `user_id`: ID of the user with merge access (Premium and Ultimate only)
|
|
95
|
+
- `group_id`: ID of the group with merge access (Premium and Ultimate only)
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
```json
|
|
99
|
+
[
|
|
100
|
+
{
|
|
101
|
+
"id": 2001,
|
|
102
|
+
"access_level": 40,
|
|
103
|
+
"access_level_description": "Maintainers"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
```
|
|
107
|
+
"""
|
|
30
108
|
merge_access_levels = Json()
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
Array of push access level configurations.
|
|
112
|
+
|
|
113
|
+
Each entry in the array contains:
|
|
114
|
+
- `id`: ID of the push access level configuration
|
|
115
|
+
- `access_level`: Access level for pushing (e.g., 40 for Maintainers)
|
|
116
|
+
- `access_level_description`: Human-readable description of the access level
|
|
117
|
+
- `user_id`: ID of the user with push access (Premium and Ultimate only)
|
|
118
|
+
- `group_id`: ID of the group with push access (Premium and Ultimate only)
|
|
119
|
+
- `deploy_key_id`: ID of the deploy key with push access
|
|
120
|
+
|
|
121
|
+
Example:
|
|
122
|
+
```json
|
|
123
|
+
[
|
|
124
|
+
{
|
|
125
|
+
"id": 1001,
|
|
126
|
+
"access_level": 40,
|
|
127
|
+
"access_level_description": "Maintainers"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"id": 1002,
|
|
131
|
+
"access_level": 40,
|
|
132
|
+
"access_level_description": "Deploy key",
|
|
133
|
+
"deploy_key_id": 1
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
```
|
|
137
|
+
"""
|
|
31
138
|
push_access_levels = Json()
|
|
139
|
+
|
|
140
|
+
"""
|
|
141
|
+
Array of unprotect access level configurations.
|
|
142
|
+
|
|
143
|
+
Each entry in the array contains:
|
|
144
|
+
- `id`: ID of the unprotect access level configuration
|
|
145
|
+
- `access_level`: Access level for unprotecting (e.g., 40 for Maintainers)
|
|
146
|
+
- `access_level_description`: Human-readable description of the access level
|
|
147
|
+
- `user_id`: ID of the user with unprotect access (Premium and Ultimate only)
|
|
148
|
+
- `group_id`: ID of the group with unprotect access (Premium and Ultimate only)
|
|
149
|
+
|
|
150
|
+
This defines who can unprotect the branch.
|
|
151
|
+
"""
|
|
32
152
|
unprotect_access_levels = Json()
|
|
33
153
|
|
|
154
|
+
"""
|
|
155
|
+
The ID of the project this protected branch belongs to.
|
|
156
|
+
|
|
157
|
+
This is used to scope the API requests to a specific project.
|
|
158
|
+
"""
|
|
34
159
|
project_id = BelongsToId(gitlab_rest_project_reference.GitlabRestProjectReference)
|
|
160
|
+
|
|
161
|
+
"""
|
|
162
|
+
The project model this protected branch belongs to.
|
|
163
|
+
|
|
164
|
+
Provides access to the full project object via the relationship.
|
|
165
|
+
"""
|
|
35
166
|
project = BelongsToModel("project_id")
|
|
@@ -12,7 +12,40 @@ from clearskies_gitlab.rest.models import gitlab_rest_project_repository_commit_
|
|
|
12
12
|
class GitlabRestProjectRepositoryCommit(
|
|
13
13
|
Model,
|
|
14
14
|
):
|
|
15
|
-
"""
|
|
15
|
+
"""
|
|
16
|
+
Model for GitLab project repository commits.
|
|
17
|
+
|
|
18
|
+
This model provides access to the GitLab Commits API for retrieving
|
|
19
|
+
commit information from a project's repository. Commits represent
|
|
20
|
+
individual changes to the repository.
|
|
21
|
+
|
|
22
|
+
See https://docs.gitlab.com/api/commits/ for more details.
|
|
23
|
+
|
|
24
|
+
Example usage:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from clearskies_gitlab.rest.models import GitlabRestProjectRepositoryCommit
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def my_function(commits: GitlabRestProjectRepositoryCommit):
|
|
31
|
+
# List commits for a project
|
|
32
|
+
for commit in commits.where("project_id=123"):
|
|
33
|
+
print(f"Commit: {commit.short_id}")
|
|
34
|
+
print(f"Author: {commit.author_name}")
|
|
35
|
+
print(f"Title: {commit.title}")
|
|
36
|
+
|
|
37
|
+
# Get commits for a specific branch
|
|
38
|
+
for commit in commits.where("project_id=123&ref_name=main"):
|
|
39
|
+
print(f"{commit.short_id}: {commit.title}")
|
|
40
|
+
|
|
41
|
+
# Get commits with stats
|
|
42
|
+
for commit in commits.where("project_id=123&with_stats=true"):
|
|
43
|
+
print(f"Commit: {commit.short_id}")
|
|
44
|
+
# Access the diff
|
|
45
|
+
if commit.diff:
|
|
46
|
+
print(f"Diff: {commit.diff.diff}")
|
|
47
|
+
```
|
|
48
|
+
"""
|
|
16
49
|
|
|
17
50
|
backend = GitlabRestBackend()
|
|
18
51
|
id_column_name = "id"
|
|
@@ -22,33 +55,142 @@ class GitlabRestProjectRepositoryCommit(
|
|
|
22
55
|
"""Return the slug of the api endpoint for this model."""
|
|
23
56
|
return "projects/:project_id/repository/commits"
|
|
24
57
|
|
|
58
|
+
"""
|
|
59
|
+
The diff associated with this commit.
|
|
60
|
+
|
|
61
|
+
Provides access to the file changes in this commit.
|
|
62
|
+
"""
|
|
25
63
|
diff = HasOne(
|
|
26
64
|
gitlab_rest_project_repository_commit_diff.GitlabRestProjectRepositoryCommitDiff,
|
|
27
65
|
foreign_column_name="commit_id",
|
|
28
66
|
where=lambda model, parent: model.where(f"gitlab_project_id={parent.id}"),
|
|
29
67
|
)
|
|
30
68
|
|
|
69
|
+
"""
|
|
70
|
+
The full commit SHA hash.
|
|
71
|
+
|
|
72
|
+
This is the unique identifier for the commit.
|
|
73
|
+
"""
|
|
31
74
|
id = String()
|
|
75
|
+
|
|
76
|
+
"""
|
|
77
|
+
The shortened commit SHA hash.
|
|
78
|
+
|
|
79
|
+
Typically the first 8 characters of the full SHA.
|
|
80
|
+
"""
|
|
32
81
|
short_id = String()
|
|
82
|
+
|
|
83
|
+
"""
|
|
84
|
+
The commit title (first line of the commit message).
|
|
85
|
+
"""
|
|
33
86
|
title = String()
|
|
87
|
+
|
|
88
|
+
"""
|
|
89
|
+
The name of the commit author.
|
|
90
|
+
"""
|
|
34
91
|
author_name = String()
|
|
92
|
+
|
|
93
|
+
"""
|
|
94
|
+
The email address of the commit author.
|
|
95
|
+
"""
|
|
35
96
|
author_email = Email()
|
|
97
|
+
|
|
98
|
+
"""
|
|
99
|
+
The date and time when the commit was authored.
|
|
100
|
+
"""
|
|
36
101
|
authored_date = Datetime()
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
The name of the committer.
|
|
105
|
+
|
|
106
|
+
May differ from author if the commit was applied by someone else.
|
|
107
|
+
"""
|
|
37
108
|
committer_name = String()
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
The email address of the committer.
|
|
112
|
+
"""
|
|
38
113
|
committer_email = Email()
|
|
114
|
+
|
|
115
|
+
"""
|
|
116
|
+
The date and time when the commit was committed.
|
|
117
|
+
"""
|
|
39
118
|
committed_date = Datetime()
|
|
119
|
+
|
|
120
|
+
"""
|
|
121
|
+
The date and time when the commit was created in GitLab.
|
|
122
|
+
"""
|
|
40
123
|
created_at = Datetime()
|
|
124
|
+
|
|
125
|
+
"""
|
|
126
|
+
The full commit message.
|
|
127
|
+
"""
|
|
41
128
|
messsage = String()
|
|
129
|
+
|
|
130
|
+
"""
|
|
131
|
+
List of parent commit SHA hashes.
|
|
132
|
+
|
|
133
|
+
Most commits have one parent. Merge commits have two.
|
|
134
|
+
"""
|
|
42
135
|
parent_ids = Json()
|
|
136
|
+
|
|
137
|
+
"""
|
|
138
|
+
URL to view the commit in GitLab.
|
|
139
|
+
"""
|
|
43
140
|
web_url = String()
|
|
141
|
+
|
|
142
|
+
"""
|
|
143
|
+
Extended trailer information from the commit message.
|
|
144
|
+
|
|
145
|
+
Git trailers are key-value pairs at the end of commit messages.
|
|
146
|
+
"""
|
|
44
147
|
extended_trailers = Json()
|
|
45
|
-
|
|
148
|
+
|
|
149
|
+
### Search params
|
|
150
|
+
|
|
151
|
+
"""
|
|
152
|
+
The ID of the project to query commits for.
|
|
153
|
+
"""
|
|
46
154
|
project_id = Integer()
|
|
155
|
+
|
|
156
|
+
"""
|
|
157
|
+
The branch, tag, or commit SHA to list commits from.
|
|
158
|
+
"""
|
|
47
159
|
ref_name = String()
|
|
160
|
+
|
|
161
|
+
"""
|
|
162
|
+
Filter commits after this date.
|
|
163
|
+
"""
|
|
48
164
|
since = Datetime()
|
|
165
|
+
|
|
166
|
+
"""
|
|
167
|
+
Filter commits before this date.
|
|
168
|
+
"""
|
|
49
169
|
until = Datetime()
|
|
170
|
+
|
|
171
|
+
"""
|
|
172
|
+
Filter commits affecting this file path.
|
|
173
|
+
"""
|
|
50
174
|
path = String()
|
|
175
|
+
|
|
176
|
+
"""
|
|
177
|
+
Whether to retrieve commits from all branches.
|
|
178
|
+
"""
|
|
51
179
|
all = Boolean()
|
|
180
|
+
|
|
181
|
+
"""
|
|
182
|
+
Whether to include commit statistics (additions, deletions).
|
|
183
|
+
"""
|
|
52
184
|
with_stats = Boolean()
|
|
185
|
+
|
|
186
|
+
"""
|
|
187
|
+
Whether to follow only the first parent on merge commits.
|
|
188
|
+
|
|
189
|
+
Useful for getting a linear history.
|
|
190
|
+
"""
|
|
53
191
|
first_parent = Boolean()
|
|
192
|
+
|
|
193
|
+
"""
|
|
194
|
+
Whether to include Git trailers in the response.
|
|
195
|
+
"""
|
|
54
196
|
trailers = Boolean()
|