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.
Files changed (34) hide show
  1. {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/METADATA +1 -1
  2. {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/RECORD +34 -34
  3. clearskies_gitlab/defaults/gitlab_default_auth.py +33 -2
  4. clearskies_gitlab/defaults/gitlab_default_host.py +31 -2
  5. clearskies_gitlab/rest/backends/gitlab_rest_backend.py +98 -80
  6. clearskies_gitlab/rest/gitlab_branch_rule.py +74 -1
  7. clearskies_gitlab/rest/gitlab_cicd_variable.py +78 -1
  8. clearskies_gitlab/rest/gitlab_member.py +80 -1
  9. clearskies_gitlab/rest/models/gitlab_rest_advanced_search.py +67 -1
  10. clearskies_gitlab/rest/models/gitlab_rest_advanced_search_blob.py +72 -1
  11. clearskies_gitlab/rest/models/gitlab_rest_current_user.py +134 -1
  12. clearskies_gitlab/rest/models/gitlab_rest_group.py +60 -1
  13. clearskies_gitlab/rest/models/gitlab_rest_group_access_token.py +102 -1
  14. clearskies_gitlab/rest/models/gitlab_rest_group_base.py +305 -1
  15. clearskies_gitlab/rest/models/gitlab_rest_group_member.py +64 -1
  16. clearskies_gitlab/rest/models/gitlab_rest_group_project.py +27 -1
  17. clearskies_gitlab/rest/models/gitlab_rest_group_search.py +30 -1
  18. clearskies_gitlab/rest/models/gitlab_rest_group_search_blob.py +27 -1
  19. clearskies_gitlab/rest/models/gitlab_rest_group_subgroup.py +54 -17
  20. clearskies_gitlab/rest/models/gitlab_rest_group_variable.py +44 -1
  21. clearskies_gitlab/rest/models/gitlab_rest_namespace.py +178 -1
  22. clearskies_gitlab/rest/models/gitlab_rest_project.py +501 -3
  23. clearskies_gitlab/rest/models/gitlab_rest_project_approval_config.py +90 -2
  24. clearskies_gitlab/rest/models/gitlab_rest_project_approval_rule.py +92 -1
  25. clearskies_gitlab/rest/models/gitlab_rest_project_member.py +62 -1
  26. clearskies_gitlab/rest/models/gitlab_rest_project_protected_branch.py +132 -1
  27. clearskies_gitlab/rest/models/gitlab_rest_project_repository_commit.py +144 -2
  28. clearskies_gitlab/rest/models/gitlab_rest_project_repository_commit_diff.py +89 -2
  29. clearskies_gitlab/rest/models/gitlab_rest_project_repository_contributor.py +68 -2
  30. clearskies_gitlab/rest/models/gitlab_rest_project_repository_file.py +90 -1
  31. clearskies_gitlab/rest/models/gitlab_rest_project_repository_file_raw.py +57 -3
  32. clearskies_gitlab/rest/models/gitlab_rest_project_variable.py +46 -1
  33. {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/WHEEL +0 -0
  34. {clear_skies_gitlab-2.0.4.dist-info → clear_skies_gitlab-2.0.6.dist-info}/licenses/LICENSE +0 -0
@@ -5,17 +5,96 @@ from clearskies.columns import Datetime, Email, Integer, Json, String
5
5
 
6
6
 
7
7
  class GitlabMember(Model):
8
- """Base model for group or project members."""
8
+ """
9
+ Base model representing a GitLab group or project member.
10
+
11
+ Members in GitLab represent users who have been granted access to a group
12
+ or project with a specific access level. This model maps to the GitLab
13
+ REST API response for membership endpoints.
14
+
15
+ Access levels in GitLab are represented as integers:
16
+ - 10: Guest
17
+ - 20: Reporter
18
+ - 30: Developer
19
+ - 40: Maintainer
20
+ - 50: Owner
21
+
22
+ ```python
23
+ from clearskies_gitlab.rest import GitlabMember
24
+ from clearskies_gitlab.rest.backends import GitlabRestBackend
25
+
26
+
27
+ class ProjectMember(GitlabMember):
28
+ backend = GitlabRestBackend()
29
+ table_name = "projects/{project_id}/members"
30
+
31
+
32
+ # Fetch all members of a project
33
+ members = ProjectMember.where(project_id="my-project").all()
34
+ for member in members:
35
+ print(f"User: {member.username}, Access Level: {member.access_level}")
36
+ ```
37
+ """
9
38
 
10
39
  id_column_name = "id"
11
40
 
41
+ """
42
+ The unique identifier for the member (user ID).
43
+ """
12
44
  id = Integer()
45
+
46
+ """
47
+ The username of the member.
48
+ """
13
49
  username = String()
50
+
51
+ """
52
+ The display name of the member.
53
+ """
14
54
  name = String()
55
+
56
+ """
57
+ The current state of the user account.
58
+
59
+ Common values include `active`, `blocked`, or `deactivated`.
60
+ """
15
61
  state = String()
62
+
63
+ """
64
+ URL to the member's avatar image.
65
+ """
16
66
  avatar_url = String()
67
+
68
+ """
69
+ The access level granted to the member.
70
+
71
+ Integer values correspond to GitLab access levels:
72
+ 10 (Guest), 20 (Reporter), 30 (Developer), 40 (Maintainer), 50 (Owner).
73
+ """
17
74
  access_level = Integer()
75
+
76
+ """
77
+ The timestamp when the member was added.
78
+ """
18
79
  created_at = Datetime()
80
+
81
+ """
82
+ JSON object containing information about who added this member.
83
+
84
+ Includes details like the user ID and username of the person who
85
+ granted membership.
86
+ """
19
87
  created_by = Json()
88
+
89
+ """
90
+ The email address of the member.
91
+ """
20
92
  email = Email()
93
+
94
+ """
95
+ JSON object containing SAML identity information for the member.
96
+
97
+ Only populated when SAML SSO is configured for the group.
98
+ Contains the extern_uid and provider information.
99
+ """
21
100
  group_saml_identity = Json()
@@ -9,7 +9,33 @@ from clearskies_gitlab.rest.backends import GitlabRestBackend
9
9
 
10
10
 
11
11
  class GitlabRestAdvancedSearch(Model):
12
- """Model for advanced search."""
12
+ """
13
+ Model for GitLab Advanced Search.
14
+
15
+ This model provides access to GitLab's Advanced Search API, which allows searching across
16
+ the entire GitLab instance for various types of content including projects, issues,
17
+ merge requests, milestones, snippets, users, wiki content, commits, blobs, and notes.
18
+
19
+ Advanced Search requires Elasticsearch to be configured on the GitLab instance.
20
+
21
+ See https://docs.gitlab.com/api/search/ for more details.
22
+
23
+ Example usage:
24
+
25
+ ```python
26
+ from clearskies_gitlab.rest.models import GitlabRestAdvancedSearch
27
+
28
+
29
+ def my_function(search: GitlabRestAdvancedSearch):
30
+ # Search for projects matching a query
31
+ for result in search.where("scope=projects").where("search=my-project"):
32
+ print(f"Found: {result.fields}")
33
+
34
+ # Search for blobs (code) containing specific text
35
+ for result in search.where("scope=blobs").where("search=def my_function"):
36
+ print(f"Found code match: {result.fields}")
37
+ ```
38
+ """
13
39
 
14
40
  backend = GitlabRestBackend()
15
41
 
@@ -18,6 +44,21 @@ class GitlabRestAdvancedSearch(Model):
18
44
  """Return the slug of the api endpoint for this model."""
19
45
  return "search"
20
46
 
47
+ """
48
+ The scope of the search.
49
+
50
+ Determines what type of content to search for. Available values:
51
+ - `projects`: Search for projects
52
+ - `issues`: Search for issues
53
+ - `merge_requests`: Search for merge requests
54
+ - `milestones`: Search for milestones
55
+ - `snippet_titles`: Search for snippet titles
56
+ - `users`: Search for users
57
+ - `wiki_blobs`: Search for wiki content
58
+ - `commits`: Search for commits
59
+ - `blobs`: Search for code/file content
60
+ - `notes`: Search for comments/notes
61
+ """
21
62
  scope = Select(
22
63
  allowed_values=[
23
64
  "projects",
@@ -32,7 +73,32 @@ class GitlabRestAdvancedSearch(Model):
32
73
  "notes",
33
74
  ]
34
75
  )
76
+
77
+ """
78
+ The search query string.
79
+
80
+ The text to search for across the selected scope.
81
+ """
35
82
  search = String()
83
+
84
+ """
85
+ Filter for confidential issues.
86
+
87
+ When searching issues, set to `True` to only return confidential issues,
88
+ or `False` to only return non-confidential issues.
89
+ """
36
90
  confidential = Boolean()
91
+
92
+ """
93
+ Filter by state.
94
+
95
+ When searching issues or merge requests, filter by their state (e.g., "opened", "closed").
96
+ """
37
97
  state = String()
98
+
99
+ """
100
+ Additional fields returned in the search results.
101
+
102
+ Contains extra data specific to the search scope, returned as a JSON object.
103
+ """
38
104
  fields = Json()
@@ -8,16 +8,87 @@ from clearskies_gitlab.rest.models import gitlab_rest_advanced_search, gitlab_re
8
8
  class GitlabRestAdvancedSearchBlob(
9
9
  gitlab_rest_advanced_search.GitlabRestAdvancedSearch,
10
10
  ):
11
- """Model for advanced searching blobs."""
11
+ """
12
+ Model for GitLab Advanced Search blob results.
12
13
 
14
+ This model extends GitlabRestAdvancedSearch to provide specific fields for blob (code/file)
15
+ search results. When searching with `scope="blobs"`, the results include file content
16
+ and location information.
17
+
18
+ See https://docs.gitlab.com/api/search/ for more details.
19
+
20
+ Example usage:
21
+
22
+ ```python
23
+ from clearskies_gitlab.rest.models import GitlabRestAdvancedSearchBlob
24
+
25
+
26
+ def my_function(blob_search: GitlabRestAdvancedSearchBlob):
27
+ # Search for code containing a specific function
28
+ for blob in blob_search.where("scope=blobs").where("search=def authenticate"):
29
+ print(f"Found in {blob.path} at line {blob.startline}")
30
+ print(f"Project ID: {blob.project_id}")
31
+ ```
32
+ """
33
+
34
+ """
35
+ The base filename without the directory path.
36
+
37
+ For example, if the full path is "src/utils/helpers.py", the basename would be "helpers.py".
38
+ """
13
39
  basename = String()
40
+
41
+ """
42
+ The matching content from the file.
43
+
44
+ Contains the actual code or text that matched the search query, typically with
45
+ surrounding context.
46
+ """
14
47
  data = String()
48
+
49
+ """
50
+ The full path to the file within the repository.
51
+
52
+ For example: "src/utils/helpers.py".
53
+ """
15
54
  path = String()
55
+
56
+ """
57
+ The filename of the matched file.
58
+
59
+ Similar to basename, contains the name of the file.
60
+ """
16
61
  filename = String()
62
+
63
+ """
64
+ The unique identifier for this search result.
65
+ """
17
66
  id = Integer()
67
+
68
+ """
69
+ The Git reference (branch or tag) where the match was found.
70
+
71
+ For example: "main", "develop", or "v1.0.0".
72
+ """
18
73
  ref = String()
74
+
75
+ """
76
+ The starting line number of the matched content.
77
+
78
+ Indicates where in the file the matching content begins.
79
+ """
19
80
  startline = Integer()
81
+
82
+ """
83
+ The ID of the project containing the matched file.
84
+ """
20
85
  project_id = BelongsToId(
21
86
  gitlab_rest_project.GitlabRestProject,
22
87
  )
88
+
89
+ """
90
+ The project model containing the matched file.
91
+
92
+ Provides access to the full project object via the relationship.
93
+ """
23
94
  project = BelongsToModel("project_id")
@@ -11,7 +11,30 @@ from clearskies_gitlab.rest.backends import GitlabRestBackend
11
11
  class GitlabRestCurrentUser(
12
12
  Model,
13
13
  ):
14
- """Model for current user."""
14
+ """
15
+ Model for the current authenticated GitLab user.
16
+
17
+ This model provides access to the GitLab User API for retrieving information about
18
+ the currently authenticated user. It returns detailed profile information including
19
+ identity, settings, and capabilities.
20
+
21
+ See https://docs.gitlab.com/api/users/#for-normal-users for more details.
22
+
23
+ Example usage:
24
+
25
+ ```python
26
+ from clearskies_gitlab.rest.models import GitlabRestCurrentUser
27
+
28
+
29
+ def my_function(current_user: GitlabRestCurrentUser):
30
+ # Get the current user's information
31
+ user = current_user.first()
32
+ if user:
33
+ print(f"Logged in as: {user.username}")
34
+ print(f"Email: {user.email}")
35
+ print(f"Can create projects: {user.can_create_project}")
36
+ ```
37
+ """
15
38
 
16
39
  id_column_name = "id"
17
40
  backend = GitlabRestBackend()
@@ -21,26 +44,136 @@ class GitlabRestCurrentUser(
21
44
  """Return the slug of the api endpoint for this model."""
22
45
  return "user"
23
46
 
47
+ """
48
+ The unique identifier for the user.
49
+ """
24
50
  id = Integer()
51
+
52
+ """
53
+ The username of the user.
54
+
55
+ This is the unique handle used for login and mentions (e.g., @username).
56
+ """
25
57
  username = String()
58
+
59
+ """
60
+ The primary email address of the user.
61
+ """
26
62
  email = Email()
63
+
64
+ """
65
+ The display name of the user.
66
+ """
27
67
  name = String()
68
+
69
+ """
70
+ The current state of the user account.
71
+
72
+ Common values include "active", "blocked", "deactivated".
73
+ """
28
74
  state = String()
75
+
76
+ """
77
+ Whether the user account is locked.
78
+
79
+ A locked account cannot sign in until unlocked by an administrator.
80
+ """
29
81
  locked = Boolean()
82
+
83
+ """
84
+ URL to the user's avatar image.
85
+ """
30
86
  avatar_url = String()
87
+
88
+ """
89
+ URL to the user's GitLab profile page.
90
+ """
31
91
  web_url = String()
92
+
93
+ """
94
+ The date and time when the user account was created.
95
+ """
32
96
  created_at = Datetime()
97
+
98
+ """
99
+ The user's biography/description.
100
+
101
+ A short text that appears on the user's profile page.
102
+ """
33
103
  bio = String()
104
+
105
+ """
106
+ The user's public email address.
107
+
108
+ This email is visible to other users on the profile page.
109
+ """
34
110
  public_email = Email()
111
+
112
+ """
113
+ The organization the user belongs to.
114
+ """
35
115
  organization = String()
116
+
117
+ """
118
+ Whether this user is a bot account.
119
+
120
+ Bot accounts are typically used for automation and CI/CD.
121
+ """
36
122
  bot = Boolean()
123
+
124
+ """
125
+ The date and time of the user's last sign in.
126
+ """
37
127
  last_sign_in_at = Datetime()
128
+
129
+ """
130
+ The date and time when the user's email was confirmed.
131
+ """
38
132
  confirmed_at = Datetime()
133
+
134
+ """
135
+ The date of the user's last activity.
136
+ """
39
137
  last_activity_on = Datetime()
138
+
139
+ """
140
+ Array of identity provider information.
141
+
142
+ Contains details about external identity providers (LDAP, SAML, etc.)
143
+ linked to this account.
144
+ """
40
145
  identities = Json()
146
+
147
+ """
148
+ Whether the user can create new groups.
149
+ """
41
150
  can_create_group = Boolean()
151
+
152
+ """
153
+ Whether the user can create new projects.
154
+ """
42
155
  can_create_project = Boolean()
156
+
157
+ """
158
+ Whether two-factor authentication is enabled for this user.
159
+ """
43
160
  two_factor_enabled = Boolean()
161
+
162
+ """
163
+ Whether this is an external user.
164
+
165
+ External users have limited access to internal projects.
166
+ """
44
167
  external = Boolean()
168
+
169
+ """
170
+ Whether the user has a private profile.
171
+
172
+ Private profiles hide activity and contribution information.
173
+ """
45
174
  private_profile = Boolean()
175
+
176
+ """
177
+ The email address used for Git commits.
178
+ """
46
179
  commit_email = Email()
@@ -19,29 +19,88 @@ from clearskies_gitlab.rest.models import (
19
19
  class GitlabRestGroup(
20
20
  gitlab_rest_group_base.GitlabRestGroupBase,
21
21
  ):
22
- """Model for groups."""
22
+ """
23
+ Model for GitLab groups.
24
+
25
+ This model provides access to the GitLab Groups API for managing groups and their
26
+ associated resources. Groups are used to organize projects and manage permissions
27
+ for teams of users.
28
+
29
+ See https://docs.gitlab.com/api/groups/ for more details.
30
+
31
+ Example usage:
32
+
33
+ ```python
34
+ from clearskies_gitlab.rest.models import GitlabRestGroup
35
+
36
+
37
+ def my_function(groups: GitlabRestGroup):
38
+ # List all groups
39
+ for group in groups:
40
+ print(f"Group: {group.name} ({group.full_path})")
41
+
42
+ # Find a specific group
43
+ my_group = groups.find("path=my-team")
44
+ if my_group:
45
+ # Access related resources
46
+ for project in my_group.projects:
47
+ print(f"Project: {project.name}")
48
+
49
+ for member in my_group.members:
50
+ print(f"Member: {member.username}")
51
+ ```
52
+ """
23
53
 
24
54
  @classmethod
25
55
  def destination_name(cls: type[Self]) -> str:
26
56
  """Return the slug of the api endpoint for this model."""
27
57
  return "groups"
28
58
 
59
+ """
60
+ Projects belonging to this group.
61
+
62
+ Provides access to all projects within the group.
63
+ """
29
64
  projects = HasMany(
30
65
  gitlab_rest_group_project_reference.GitlabRestGroupProjectReference,
31
66
  foreign_column_name="group_id",
32
67
  )
68
+
69
+ """
70
+ Access tokens for this group.
71
+
72
+ Group access tokens can be used for API authentication with group-level permissions.
73
+ """
33
74
  access_tokens = HasMany(
34
75
  gitlab_rest_group_access_token_reference.GitlabRestGroupAccessTokenReference,
35
76
  foreign_column_name="group_id",
36
77
  )
78
+
79
+ """
80
+ CI/CD variables defined for this group.
81
+
82
+ These variables are available to all projects within the group.
83
+ """
37
84
  variables = HasMany(
38
85
  gitlab_rest_group_variable_reference.GitlabRestGroupVariableReference,
39
86
  foreign_column_name="group_id",
40
87
  )
88
+
89
+ """
90
+ Subgroups within this group.
91
+
92
+ Groups can be nested to create a hierarchy of teams and projects.
93
+ """
41
94
  subgroups = HasMany(
42
95
  gitlab_rest_group_subgroup_reference.GitlabRestGroupSubgroupReference,
43
96
  foreign_column_name="group_id",
44
97
  )
98
+
99
+ """
100
+ Members of this group.
101
+
102
+ Users who have been granted access to the group and its resources.
103
+ """
45
104
  members = HasMany(
46
105
  gitlab_rest_group_member_reference.GitlabRestGroupMemberReference,
47
106
  foreign_column_name="group_id",
@@ -11,7 +11,40 @@ from clearskies_gitlab.rest.backends import GitlabRestBackend
11
11
  class GitlabRestGroupAccessToken(
12
12
  Model,
13
13
  ):
14
- """Model for groups access tokens."""
14
+ """
15
+ Model for GitLab group access tokens.
16
+
17
+ This model provides access to the GitLab Group Access Tokens API for managing
18
+ access tokens at the group level. Group access tokens can be used for API
19
+ authentication with permissions scoped to a specific group.
20
+
21
+ See https://docs.gitlab.com/api/group_access_tokens/ for more details.
22
+
23
+ Example usage:
24
+
25
+ ```python
26
+ from clearskies_gitlab.rest.models import GitlabRestGroupAccessToken
27
+
28
+
29
+ def my_function(access_tokens: GitlabRestGroupAccessToken):
30
+ # List all access tokens for a group
31
+ for token in access_tokens.where("group_id=123"):
32
+ print(f"Token: {token.name}, Active: {token.active}")
33
+ print(f"Expires: {token.expires_at}")
34
+
35
+ # Create a new access token
36
+ new_token = access_tokens.create(
37
+ {
38
+ "group_id": "123",
39
+ "name": "CI Token",
40
+ "scopes": ["read_api", "read_repository"],
41
+ "expires_at": "2025-12-31",
42
+ "access_level": 30,
43
+ }
44
+ )
45
+ print(f"New token: {new_token.token}")
46
+ ```
47
+ """
15
48
 
16
49
  id_column_name = "id"
17
50
  backend = GitlabRestBackend()
@@ -21,14 +54,82 @@ class GitlabRestGroupAccessToken(
21
54
  """Return the slug of the api endpoint for this model."""
22
55
  return "groups/:group_id/access_tokens"
23
56
 
57
+ """
58
+ The ID of the group this token belongs to.
59
+
60
+ Used to scope API requests to a specific group.
61
+ """
24
62
  group_id = String()
63
+
64
+ """
65
+ The unique identifier for the access token.
66
+ """
25
67
  id = Integer()
68
+
69
+ """
70
+ The user ID associated with this token.
71
+
72
+ Each access token is associated with a bot user account.
73
+ """
26
74
  user_id = Integer()
75
+
76
+ """
77
+ The name/description of the access token.
78
+
79
+ A human-readable identifier for the token's purpose.
80
+ """
27
81
  name = String()
82
+
83
+ """
84
+ The date and time when the token was created.
85
+ """
28
86
  created_at = Datetime()
87
+
88
+ """
89
+ The expiration date of the token.
90
+
91
+ After this date, the token will no longer be valid for authentication.
92
+ Format: YYYY-MM-DD
93
+ """
29
94
  expires_at = Datetime(date_format="%Y-%m-%d")
95
+
96
+ """
97
+ Whether the token is currently active.
98
+
99
+ Inactive tokens cannot be used for authentication.
100
+ """
30
101
  active = Boolean()
102
+
103
+ """
104
+ Whether the token has been revoked.
105
+
106
+ Revoked tokens are permanently disabled.
107
+ """
31
108
  revoked = Boolean()
109
+
110
+ """
111
+ The access level granted by this token.
112
+
113
+ Common values:
114
+ - 10: Guest
115
+ - 20: Reporter
116
+ - 30: Developer
117
+ - 40: Maintainer
118
+ - 50: Owner
119
+ """
32
120
  access_level = Integer()
121
+
122
+ """
123
+ The actual token value.
124
+
125
+ This is only returned when creating a new token and should be stored securely.
126
+ It cannot be retrieved again after creation.
127
+ """
33
128
  token = String()
129
+
130
+ """
131
+ The scopes/permissions granted to this token.
132
+
133
+ Array of scope strings like "api", "read_api", "read_repository", etc.
134
+ """
34
135
  scopes = Json()