python-gitlab 5.3.1__py3-none-any.whl → 5.5.0__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.
@@ -11,7 +11,9 @@ from typing import (
11
11
  Callable,
12
12
  cast,
13
13
  Iterator,
14
+ Literal,
14
15
  Optional,
16
+ overload,
15
17
  TYPE_CHECKING,
16
18
  Union,
17
19
  )
@@ -122,6 +124,48 @@ class GenericPackageManager(RESTManager):
122
124
  attrs.update(server_data)
123
125
  return self._obj_cls(self, attrs=attrs)
124
126
 
127
+ @overload
128
+ def download(
129
+ self,
130
+ package_name: str,
131
+ package_version: str,
132
+ file_name: str,
133
+ streamed: Literal[False] = False,
134
+ action: None = None,
135
+ chunk_size: int = 1024,
136
+ *,
137
+ iterator: Literal[False] = False,
138
+ **kwargs: Any,
139
+ ) -> bytes: ...
140
+
141
+ @overload
142
+ def download(
143
+ self,
144
+ package_name: str,
145
+ package_version: str,
146
+ file_name: str,
147
+ streamed: bool = False,
148
+ action: None = None,
149
+ chunk_size: int = 1024,
150
+ *,
151
+ iterator: Literal[True] = True,
152
+ **kwargs: Any,
153
+ ) -> Iterator[Any]: ...
154
+
155
+ @overload
156
+ def download(
157
+ self,
158
+ package_name: str,
159
+ package_version: str,
160
+ file_name: str,
161
+ streamed: Literal[True] = True,
162
+ action: Optional[Callable[[bytes], Any]] = None,
163
+ chunk_size: int = 1024,
164
+ *,
165
+ iterator: Literal[False] = False,
166
+ **kwargs: Any,
167
+ ) -> None: ...
168
+
125
169
  @cli.register_custom_action(
126
170
  cls_names="GenericPackageManager",
127
171
  required=("package_name", "package_version", "file_name"),
@@ -133,7 +177,7 @@ class GenericPackageManager(RESTManager):
133
177
  package_version: str,
134
178
  file_name: str,
135
179
  streamed: bool = False,
136
- action: Optional[Callable[[bytes], None]] = None,
180
+ action: Optional[Callable[[bytes], Any]] = None,
137
181
  chunk_size: int = 1024,
138
182
  *,
139
183
  iterator: bool = False,
@@ -11,7 +11,9 @@ from typing import (
11
11
  Dict,
12
12
  Iterator,
13
13
  List,
14
+ Literal,
14
15
  Optional,
16
+ overload,
15
17
  TYPE_CHECKING,
16
18
  Union,
17
19
  )
@@ -102,6 +104,7 @@ from .statistics import ( # noqa: F401
102
104
  ProjectAdditionalStatisticsManager,
103
105
  ProjectIssuesStatisticsManager,
104
106
  )
107
+ from .status_checks import ProjectExternalStatusCheckManager # noqa: F401
105
108
  from .tags import ProjectProtectedTagManager, ProjectTagManager # noqa: F401
106
109
  from .templates import ( # noqa: F401
107
110
  ProjectDockerfileTemplateManager,
@@ -125,6 +128,8 @@ __all__ = [
125
128
  "ProjectForkManager",
126
129
  "ProjectRemoteMirror",
127
130
  "ProjectRemoteMirrorManager",
131
+ "ProjectPullMirror",
132
+ "ProjectPullMirrorManager",
128
133
  "ProjectStorage",
129
134
  "ProjectStorageManager",
130
135
  "SharedProject",
@@ -246,11 +251,13 @@ class Project(
246
251
  releases: ProjectReleaseManager
247
252
  resource_groups: ProjectResourceGroupManager
248
253
  remote_mirrors: "ProjectRemoteMirrorManager"
254
+ pull_mirror: "ProjectPullMirrorManager"
249
255
  repositories: ProjectRegistryRepositoryManager
250
256
  runners: ProjectRunnerManager
251
257
  secure_files: ProjectSecureFileManager
252
258
  services: ProjectServiceManager
253
259
  snippets: ProjectSnippetManager
260
+ external_status_checks: ProjectExternalStatusCheckManager
254
261
  storage: "ProjectStorageManager"
255
262
  tags: ProjectTagManager
256
263
  triggers: ProjectTriggerManager
@@ -487,13 +494,49 @@ class Project(
487
494
  path = f"/projects/{self.encoded_id}/restore"
488
495
  self.manager.gitlab.http_post(path, **kwargs)
489
496
 
497
+ @overload
498
+ def snapshot(
499
+ self,
500
+ wiki: bool = False,
501
+ streamed: Literal[False] = False,
502
+ action: None = None,
503
+ chunk_size: int = 1024,
504
+ *,
505
+ iterator: Literal[False] = False,
506
+ **kwargs: Any,
507
+ ) -> bytes: ...
508
+
509
+ @overload
510
+ def snapshot(
511
+ self,
512
+ wiki: bool = False,
513
+ streamed: bool = False,
514
+ action: None = None,
515
+ chunk_size: int = 1024,
516
+ *,
517
+ iterator: Literal[True] = True,
518
+ **kwargs: Any,
519
+ ) -> Iterator[Any]: ...
520
+
521
+ @overload
522
+ def snapshot(
523
+ self,
524
+ wiki: bool = False,
525
+ streamed: Literal[True] = True,
526
+ action: Optional[Callable[[bytes], Any]] = None,
527
+ chunk_size: int = 1024,
528
+ *,
529
+ iterator: Literal[False] = False,
530
+ **kwargs: Any,
531
+ ) -> None: ...
532
+
490
533
  @cli.register_custom_action(cls_names="Project", optional=("wiki",))
491
534
  @exc.on_http_error(exc.GitlabGetError)
492
535
  def snapshot(
493
536
  self,
494
537
  wiki: bool = False,
495
538
  streamed: bool = False,
496
- action: Optional[Callable[[bytes], None]] = None,
539
+ action: Optional[Callable[[bytes], Any]] = None,
497
540
  chunk_size: int = 1024,
498
541
  *,
499
542
  iterator: bool = False,
@@ -565,6 +608,13 @@ class Project(
565
608
  GitlabAuthenticationError: If authentication is not correct
566
609
  GitlabCreateError: If the server failed to perform the request
567
610
  """
611
+ utils.warn(
612
+ message=(
613
+ "project.mirror_pull() is deprecated and will be removed in a "
614
+ "future major version. Use project.pull_mirror.start() instead."
615
+ ),
616
+ category=DeprecationWarning,
617
+ )
568
618
  path = f"/projects/{self.encoded_id}/mirror/pull"
569
619
  self.manager.gitlab.http_post(path, **kwargs)
570
620
 
@@ -585,6 +635,13 @@ class Project(
585
635
  Returns:
586
636
  dict of the parsed json returned by the server
587
637
  """
638
+ utils.warn(
639
+ message=(
640
+ "project.mirror_pull_details() is deprecated and will be removed in a "
641
+ "future major version. Use project.pull_mirror.get() instead."
642
+ ),
643
+ category=DeprecationWarning,
644
+ )
588
645
  path = f"/projects/{self.encoded_id}/mirror/pull"
589
646
  result = self.manager.gitlab.http_get(path, **kwargs)
590
647
  if TYPE_CHECKING:
@@ -1200,6 +1257,65 @@ class ProjectRemoteMirrorManager(
1200
1257
  _update_attrs = RequiredOptional(optional=("enabled", "only_protected_branches"))
1201
1258
 
1202
1259
 
1260
+ class ProjectPullMirror(SaveMixin, RESTObject):
1261
+ _id_attr = None
1262
+
1263
+
1264
+ class ProjectPullMirrorManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
1265
+ _path = "/projects/{project_id}/mirror/pull"
1266
+ _obj_cls = ProjectPullMirror
1267
+ _from_parent_attrs = {"project_id": "id"}
1268
+ _update_attrs = RequiredOptional(optional=("url",))
1269
+
1270
+ def get(self, **kwargs: Any) -> ProjectPullMirror:
1271
+ return cast(ProjectPullMirror, super().get(**kwargs))
1272
+
1273
+ @exc.on_http_error(exc.GitlabCreateError)
1274
+ def create(self, data: Dict[str, Any], **kwargs: Any) -> ProjectPullMirror:
1275
+ """Create a new object.
1276
+
1277
+ Args:
1278
+ data: parameters to send to the server to create the
1279
+ resource
1280
+ **kwargs: Extra options to send to the server (e.g. sudo)
1281
+
1282
+ Returns:
1283
+ A new instance of the managed object class built with
1284
+ the data sent by the server
1285
+
1286
+ Raises:
1287
+ GitlabAuthenticationError: If authentication is not correct
1288
+ GitlabCreateError: If the server cannot perform the request
1289
+ """
1290
+ if TYPE_CHECKING:
1291
+ assert data is not None
1292
+ self._create_attrs.validate_attrs(data=data)
1293
+
1294
+ if TYPE_CHECKING:
1295
+ assert self.path is not None
1296
+ server_data = self.gitlab.http_put(self.path, post_data=data, **kwargs)
1297
+
1298
+ if TYPE_CHECKING:
1299
+ assert not isinstance(server_data, requests.Response)
1300
+ return self._obj_cls(self, server_data)
1301
+
1302
+ @cli.register_custom_action(cls_names="ProjectPullMirrorManager")
1303
+ @exc.on_http_error(exc.GitlabCreateError)
1304
+ def start(self, **kwargs: Any) -> None:
1305
+ """Start the pull mirroring process for the project.
1306
+
1307
+ Args:
1308
+ **kwargs: Extra options to send to the server (e.g. sudo)
1309
+
1310
+ Raises:
1311
+ GitlabAuthenticationError: If authentication is not correct
1312
+ GitlabCreateError: If the server failed to perform the request
1313
+ """
1314
+ if TYPE_CHECKING:
1315
+ assert self.path is not None
1316
+ self.gitlab.http_post(self.path, **kwargs)
1317
+
1318
+
1203
1319
  class ProjectStorage(RefreshMixin, RESTObject):
1204
1320
  pass
1205
1321
 
@@ -4,7 +4,18 @@ GitLab API: https://docs.gitlab.com/ee/api/repositories.html
4
4
  Currently this module only contains repository-related methods for projects.
5
5
  """
6
6
 
7
- from typing import Any, Callable, Dict, Iterator, List, Optional, TYPE_CHECKING, Union
7
+ from typing import (
8
+ Any,
9
+ Callable,
10
+ Dict,
11
+ Iterator,
12
+ List,
13
+ Literal,
14
+ Optional,
15
+ overload,
16
+ TYPE_CHECKING,
17
+ Union,
18
+ )
8
19
 
9
20
  import requests
10
21
 
@@ -106,6 +117,42 @@ class RepositoryMixin(_RestObjectBase):
106
117
  path = f"/projects/{self.encoded_id}/repository/blobs/{sha}"
107
118
  return self.manager.gitlab.http_get(path, **kwargs)
108
119
 
120
+ @overload
121
+ def repository_raw_blob(
122
+ self,
123
+ sha: str,
124
+ streamed: Literal[False] = False,
125
+ action: None = None,
126
+ chunk_size: int = 1024,
127
+ *,
128
+ iterator: Literal[False] = False,
129
+ **kwargs: Any,
130
+ ) -> bytes: ...
131
+
132
+ @overload
133
+ def repository_raw_blob(
134
+ self,
135
+ sha: str,
136
+ streamed: bool = False,
137
+ action: None = None,
138
+ chunk_size: int = 1024,
139
+ *,
140
+ iterator: Literal[True] = True,
141
+ **kwargs: Any,
142
+ ) -> Iterator[Any]: ...
143
+
144
+ @overload
145
+ def repository_raw_blob(
146
+ self,
147
+ sha: str,
148
+ streamed: Literal[True] = True,
149
+ action: Optional[Callable[[bytes], Any]] = None,
150
+ chunk_size: int = 1024,
151
+ *,
152
+ iterator: Literal[False] = False,
153
+ **kwargs: Any,
154
+ ) -> None: ...
155
+
109
156
  @cli.register_custom_action(cls_names="Project", required=("sha",))
110
157
  @exc.on_http_error(exc.GitlabGetError)
111
158
  def repository_raw_blob(
@@ -197,6 +244,42 @@ class RepositoryMixin(_RestObjectBase):
197
244
  path = f"/projects/{self.encoded_id}/repository/contributors"
198
245
  return self.manager.gitlab.http_list(path, **kwargs)
199
246
 
247
+ @overload
248
+ def repository_archive(
249
+ self,
250
+ sha: Optional[str] = None,
251
+ streamed: Literal[False] = False,
252
+ action: None = None,
253
+ chunk_size: int = 1024,
254
+ *,
255
+ iterator: Literal[False] = False,
256
+ **kwargs: Any,
257
+ ) -> bytes: ...
258
+
259
+ @overload
260
+ def repository_archive(
261
+ self,
262
+ sha: Optional[str] = None,
263
+ streamed: bool = False,
264
+ action: None = None,
265
+ chunk_size: int = 1024,
266
+ *,
267
+ iterator: Literal[True] = True,
268
+ **kwargs: Any,
269
+ ) -> Iterator[Any]: ...
270
+
271
+ @overload
272
+ def repository_archive(
273
+ self,
274
+ sha: Optional[str] = None,
275
+ streamed: Literal[True] = True,
276
+ action: Optional[Callable[[bytes], Any]] = None,
277
+ chunk_size: int = 1024,
278
+ *,
279
+ iterator: Literal[False] = False,
280
+ **kwargs: Any,
281
+ ) -> None: ...
282
+
200
283
  @cli.register_custom_action(cls_names="Project", optional=("sha", "format"))
201
284
  @exc.on_http_error(exc.GitlabListError)
202
285
  def repository_archive(
@@ -3,7 +3,17 @@ GitLab API:
3
3
  https://docs.gitlab.com/ee/api/secure_files.html
4
4
  """
5
5
 
6
- from typing import Any, Callable, cast, Iterator, Optional, TYPE_CHECKING, Union
6
+ from typing import (
7
+ Any,
8
+ Callable,
9
+ cast,
10
+ Iterator,
11
+ Literal,
12
+ Optional,
13
+ overload,
14
+ TYPE_CHECKING,
15
+ Union,
16
+ )
7
17
 
8
18
  import requests
9
19
 
@@ -18,12 +28,45 @@ __all__ = ["ProjectSecureFile", "ProjectSecureFileManager"]
18
28
 
19
29
 
20
30
  class ProjectSecureFile(ObjectDeleteMixin, RESTObject):
31
+ @overload
32
+ def download(
33
+ self,
34
+ streamed: Literal[False] = False,
35
+ action: None = None,
36
+ chunk_size: int = 1024,
37
+ *,
38
+ iterator: Literal[False] = False,
39
+ **kwargs: Any,
40
+ ) -> bytes: ...
41
+
42
+ @overload
43
+ def download(
44
+ self,
45
+ streamed: bool = False,
46
+ action: None = None,
47
+ chunk_size: int = 1024,
48
+ *,
49
+ iterator: Literal[True] = True,
50
+ **kwargs: Any,
51
+ ) -> Iterator[Any]: ...
52
+
53
+ @overload
54
+ def download(
55
+ self,
56
+ streamed: Literal[True] = True,
57
+ action: Optional[Callable[[bytes], Any]] = None,
58
+ chunk_size: int = 1024,
59
+ *,
60
+ iterator: Literal[False] = False,
61
+ **kwargs: Any,
62
+ ) -> None: ...
63
+
21
64
  @cli.register_custom_action(cls_names="ProjectSecureFile")
22
65
  @exc.on_http_error(exc.GitlabGetError)
23
66
  def download(
24
67
  self,
25
68
  streamed: bool = False,
26
- action: Optional[Callable[[bytes], None]] = None,
69
+ action: Optional[Callable[[bytes], Any]] = None,
27
70
  chunk_size: int = 1024,
28
71
  *,
29
72
  iterator: bool = False,
@@ -1,4 +1,15 @@
1
- from typing import Any, Callable, cast, Iterator, List, Optional, TYPE_CHECKING, Union
1
+ from typing import (
2
+ Any,
3
+ Callable,
4
+ cast,
5
+ Iterator,
6
+ List,
7
+ Literal,
8
+ Optional,
9
+ overload,
10
+ TYPE_CHECKING,
11
+ Union,
12
+ )
2
13
 
3
14
  import requests
4
15
 
@@ -24,6 +35,39 @@ __all__ = [
24
35
  class Snippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
25
36
  _repr_attr = "title"
26
37
 
38
+ @overload
39
+ def content(
40
+ self,
41
+ streamed: Literal[False] = False,
42
+ action: None = None,
43
+ chunk_size: int = 1024,
44
+ *,
45
+ iterator: Literal[False] = False,
46
+ **kwargs: Any,
47
+ ) -> bytes: ...
48
+
49
+ @overload
50
+ def content(
51
+ self,
52
+ streamed: bool = False,
53
+ action: None = None,
54
+ chunk_size: int = 1024,
55
+ *,
56
+ iterator: Literal[True] = True,
57
+ **kwargs: Any,
58
+ ) -> Iterator[Any]: ...
59
+
60
+ @overload
61
+ def content(
62
+ self,
63
+ streamed: Literal[True] = True,
64
+ action: Optional[Callable[[bytes], Any]] = None,
65
+ chunk_size: int = 1024,
66
+ *,
67
+ iterator: Literal[False] = False,
68
+ **kwargs: Any,
69
+ ) -> None: ...
70
+
27
71
  @cli.register_custom_action(cls_names="Snippet")
28
72
  @exc.on_http_error(exc.GitlabGetError)
29
73
  def content(
@@ -148,7 +192,7 @@ class SnippetManager(CRUDMixin, RESTManager):
148
192
  """
149
193
  utils.warn(
150
194
  message=(
151
- "Gitlab.snippets.public() is deprecated and will be removed in a"
195
+ "Gitlab.snippets.public() is deprecated and will be removed in a "
152
196
  "future major version. Use Gitlab.snippets.list_public() instead."
153
197
  ),
154
198
  category=DeprecationWarning,
@@ -167,6 +211,39 @@ class ProjectSnippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, RESTObj
167
211
  discussions: ProjectSnippetDiscussionManager
168
212
  notes: ProjectSnippetNoteManager
169
213
 
214
+ @overload
215
+ def content(
216
+ self,
217
+ streamed: Literal[False] = False,
218
+ action: None = None,
219
+ chunk_size: int = 1024,
220
+ *,
221
+ iterator: Literal[False] = False,
222
+ **kwargs: Any,
223
+ ) -> bytes: ...
224
+
225
+ @overload
226
+ def content(
227
+ self,
228
+ streamed: bool = False,
229
+ action: None = None,
230
+ chunk_size: int = 1024,
231
+ *,
232
+ iterator: Literal[True] = True,
233
+ **kwargs: Any,
234
+ ) -> Iterator[Any]: ...
235
+
236
+ @overload
237
+ def content(
238
+ self,
239
+ streamed: Literal[True] = True,
240
+ action: Optional[Callable[[bytes], Any]] = None,
241
+ chunk_size: int = 1024,
242
+ *,
243
+ iterator: Literal[False] = False,
244
+ **kwargs: Any,
245
+ ) -> None: ...
246
+
170
247
  @cli.register_custom_action(cls_names="ProjectSnippet")
171
248
  @exc.on_http_error(exc.GitlabGetError)
172
249
  def content(
@@ -0,0 +1,52 @@
1
+ from gitlab.base import RESTManager, RESTObject
2
+ from gitlab.mixins import (
3
+ CreateMixin,
4
+ DeleteMixin,
5
+ ListMixin,
6
+ ObjectDeleteMixin,
7
+ SaveMixin,
8
+ UpdateMethod,
9
+ UpdateMixin,
10
+ )
11
+ from gitlab.types import ArrayAttribute, RequiredOptional
12
+
13
+ __all__ = [
14
+ "ProjectExternalStatusCheck",
15
+ "ProjectExternalStatusCheckManager",
16
+ "ProjectMergeRequestStatusCheck",
17
+ "ProjectMergeRequestStatusCheckManager",
18
+ ]
19
+
20
+
21
+ class ProjectExternalStatusCheck(SaveMixin, ObjectDeleteMixin, RESTObject):
22
+ pass
23
+
24
+
25
+ class ProjectExternalStatusCheckManager(
26
+ ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
27
+ ):
28
+ _path = "/projects/{project_id}/external_status_checks"
29
+ _obj_cls = ProjectExternalStatusCheck
30
+ _from_parent_attrs = {"project_id": "id"}
31
+ _create_attrs = RequiredOptional(
32
+ required=("name", "external_url"),
33
+ optional=("shared_secret", "protected_branch_ids"),
34
+ )
35
+ _update_attrs = RequiredOptional(
36
+ optional=("name", "external_url", "shared_secret", "protected_branch_ids")
37
+ )
38
+ _types = {"protected_branch_ids": ArrayAttribute}
39
+
40
+
41
+ class ProjectMergeRequestStatusCheck(SaveMixin, RESTObject):
42
+ pass
43
+
44
+
45
+ class ProjectMergeRequestStatusCheckManager(ListMixin, RESTManager):
46
+ _path = "/projects/{project_id}/merge_requests/{merge_request_iid}/status_checks"
47
+ _obj_cls = ProjectMergeRequestStatusCheck
48
+ _from_parent_attrs = {"project_id": "project_id", "merge_request_iid": "iid"}
49
+ _update_attrs = RequiredOptional(
50
+ required=("sha", "external_status_check_id", "status")
51
+ )
52
+ _update_method = UpdateMethod.POST
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: python-gitlab
3
- Version: 5.3.1
3
+ Version: 5.5.0
4
4
  Summary: The python wrapper for the GitLab REST and GraphQL APIs.
5
5
  Author-email: Gauvain Pocentek <gauvain@pocentek.net>
6
6
  Maintainer-email: John Villalovos <john@sodarock.com>, Max Wittig <max.wittig@siemens.com>, Nejc Habjan <nejc.habjan@siemens.com>, Roger Meier <r.meier@siemens.com>