python-gitlab 4.1.1__py3-none-any.whl → 4.2.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.
- gitlab/_version.py +1 -1
- gitlab/const.py +15 -0
- gitlab/mixins.py +70 -0
- gitlab/v4/objects/projects.py +5 -54
- gitlab/v4/objects/wikis.py +5 -3
- {python_gitlab-4.1.1.dist-info → python_gitlab-4.2.0.dist-info}/METADATA +1 -1
- {python_gitlab-4.1.1.dist-info → python_gitlab-4.2.0.dist-info}/RECORD +12 -12
- {python_gitlab-4.1.1.dist-info → python_gitlab-4.2.0.dist-info}/WHEEL +1 -1
- {python_gitlab-4.1.1.dist-info → python_gitlab-4.2.0.dist-info}/AUTHORS +0 -0
- {python_gitlab-4.1.1.dist-info → python_gitlab-4.2.0.dist-info}/COPYING +0 -0
- {python_gitlab-4.1.1.dist-info → python_gitlab-4.2.0.dist-info}/entry_points.txt +0 -0
- {python_gitlab-4.1.1.dist-info → python_gitlab-4.2.0.dist-info}/top_level.txt +0 -0
gitlab/_version.py
CHANGED
gitlab/const.py
CHANGED
@@ -72,6 +72,21 @@ class DetailedMergeStatus(GitlabEnum):
|
|
72
72
|
POLICIES_DENIED: str = "policies_denied"
|
73
73
|
|
74
74
|
|
75
|
+
# https://docs.gitlab.com/ee/api/pipelines.html
|
76
|
+
class PipelineStatus(GitlabEnum):
|
77
|
+
CREATED: str = "created"
|
78
|
+
WAITING_FOR_RESOURCE: str = "waiting_for_resource"
|
79
|
+
PREPARING: str = "preparing"
|
80
|
+
PENDING: str = "pending"
|
81
|
+
RUNNING: str = "running"
|
82
|
+
SUCCESS: str = "success"
|
83
|
+
FAILED: str = "failed"
|
84
|
+
CANCELED: str = "canceled"
|
85
|
+
SKIPPED: str = "skipped"
|
86
|
+
MANUAL: str = "manual"
|
87
|
+
SCHEDULED: str = "scheduled"
|
88
|
+
|
89
|
+
|
75
90
|
DEFAULT_URL: str = "https://gitlab.com"
|
76
91
|
|
77
92
|
NO_ACCESS = AccessLevel.NO_ACCESS.value
|
gitlab/mixins.py
CHANGED
@@ -944,3 +944,73 @@ class PromoteMixin(_RestObjectBase):
|
|
944
944
|
if TYPE_CHECKING:
|
945
945
|
assert not isinstance(result, requests.Response)
|
946
946
|
return result
|
947
|
+
|
948
|
+
|
949
|
+
class UploadMixin(_RestObjectBase):
|
950
|
+
_id_attr: Optional[str]
|
951
|
+
_attrs: Dict[str, Any]
|
952
|
+
_module: ModuleType
|
953
|
+
_parent_attrs: Dict[str, Any]
|
954
|
+
_updated_attrs: Dict[str, Any]
|
955
|
+
_upload_path: str
|
956
|
+
manager: base.RESTManager
|
957
|
+
|
958
|
+
def _get_upload_path(self) -> str:
|
959
|
+
"""Formats _upload_path with object attributes.
|
960
|
+
|
961
|
+
Returns:
|
962
|
+
The upload path
|
963
|
+
"""
|
964
|
+
if TYPE_CHECKING:
|
965
|
+
assert isinstance(self._upload_path, str)
|
966
|
+
data = self.attributes
|
967
|
+
return self._upload_path.format(**data)
|
968
|
+
|
969
|
+
@cli.register_custom_action(("Project", "ProjectWiki"), ("filename", "filepath"))
|
970
|
+
@exc.on_http_error(exc.GitlabUploadError)
|
971
|
+
def upload(
|
972
|
+
self,
|
973
|
+
filename: str,
|
974
|
+
filedata: Optional[bytes] = None,
|
975
|
+
filepath: Optional[str] = None,
|
976
|
+
**kwargs: Any,
|
977
|
+
) -> Dict[str, Any]:
|
978
|
+
"""Upload the specified file.
|
979
|
+
|
980
|
+
.. note::
|
981
|
+
|
982
|
+
Either ``filedata`` or ``filepath`` *MUST* be specified.
|
983
|
+
|
984
|
+
Args:
|
985
|
+
filename: The name of the file being uploaded
|
986
|
+
filedata: The raw data of the file being uploaded
|
987
|
+
filepath: The path to a local file to upload (optional)
|
988
|
+
|
989
|
+
Raises:
|
990
|
+
GitlabAuthenticationError: If authentication is not correct
|
991
|
+
GitlabUploadError: If the file upload fails
|
992
|
+
GitlabUploadError: If ``filedata`` and ``filepath`` are not
|
993
|
+
specified
|
994
|
+
GitlabUploadError: If both ``filedata`` and ``filepath`` are
|
995
|
+
specified
|
996
|
+
|
997
|
+
Returns:
|
998
|
+
A ``dict`` with info on the uploaded file
|
999
|
+
"""
|
1000
|
+
if filepath is None and filedata is None:
|
1001
|
+
raise exc.GitlabUploadError("No file contents or path specified")
|
1002
|
+
|
1003
|
+
if filedata is not None and filepath is not None:
|
1004
|
+
raise exc.GitlabUploadError("File contents and file path specified")
|
1005
|
+
|
1006
|
+
if filepath is not None:
|
1007
|
+
with open(filepath, "rb") as f:
|
1008
|
+
filedata = f.read()
|
1009
|
+
|
1010
|
+
file_info = {"file": (filename, filedata)}
|
1011
|
+
path = self._get_upload_path()
|
1012
|
+
server_data = self.manager.gitlab.http_post(path, files=file_info, **kwargs)
|
1013
|
+
|
1014
|
+
if TYPE_CHECKING:
|
1015
|
+
assert isinstance(server_data, dict)
|
1016
|
+
return server_data
|
gitlab/v4/objects/projects.py
CHANGED
@@ -30,6 +30,7 @@ from gitlab.mixins import (
|
|
30
30
|
RefreshMixin,
|
31
31
|
SaveMixin,
|
32
32
|
UpdateMixin,
|
33
|
+
UploadMixin,
|
33
34
|
)
|
34
35
|
from gitlab.types import RequiredOptional
|
35
36
|
|
@@ -158,8 +159,11 @@ class ProjectGroupManager(ListMixin, RESTManager):
|
|
158
159
|
_types = {"skip_groups": types.ArrayAttribute}
|
159
160
|
|
160
161
|
|
161
|
-
class Project(
|
162
|
+
class Project(
|
163
|
+
RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, UploadMixin, RESTObject
|
164
|
+
):
|
162
165
|
_repr_attr = "path_with_namespace"
|
166
|
+
_upload_path = "/projects/{id}/uploads"
|
163
167
|
|
164
168
|
access_tokens: ProjectAccessTokenManager
|
165
169
|
accessrequests: ProjectAccessRequestManager
|
@@ -437,59 +441,6 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
|
|
437
441
|
path = f"/projects/{self.encoded_id}/housekeeping"
|
438
442
|
self.manager.gitlab.http_post(path, **kwargs)
|
439
443
|
|
440
|
-
# see #56 - add file attachment features
|
441
|
-
@cli.register_custom_action("Project", ("filename", "filepath"))
|
442
|
-
@exc.on_http_error(exc.GitlabUploadError)
|
443
|
-
def upload(
|
444
|
-
self,
|
445
|
-
filename: str,
|
446
|
-
filedata: Optional[bytes] = None,
|
447
|
-
filepath: Optional[str] = None,
|
448
|
-
**kwargs: Any,
|
449
|
-
) -> Dict[str, Any]:
|
450
|
-
"""Upload the specified file into the project.
|
451
|
-
|
452
|
-
.. note::
|
453
|
-
|
454
|
-
Either ``filedata`` or ``filepath`` *MUST* be specified.
|
455
|
-
|
456
|
-
Args:
|
457
|
-
filename: The name of the file being uploaded
|
458
|
-
filedata: The raw data of the file being uploaded
|
459
|
-
filepath: The path to a local file to upload (optional)
|
460
|
-
|
461
|
-
Raises:
|
462
|
-
GitlabConnectionError: If the server cannot be reached
|
463
|
-
GitlabUploadError: If the file upload fails
|
464
|
-
GitlabUploadError: If ``filedata`` and ``filepath`` are not
|
465
|
-
specified
|
466
|
-
GitlabUploadError: If both ``filedata`` and ``filepath`` are
|
467
|
-
specified
|
468
|
-
|
469
|
-
Returns:
|
470
|
-
A ``dict`` with the keys:
|
471
|
-
* ``alt`` - The alternate text for the upload
|
472
|
-
* ``url`` - The direct url to the uploaded file
|
473
|
-
* ``markdown`` - Markdown for the uploaded file
|
474
|
-
"""
|
475
|
-
if filepath is None and filedata is None:
|
476
|
-
raise exc.GitlabUploadError("No file contents or path specified")
|
477
|
-
|
478
|
-
if filedata is not None and filepath is not None:
|
479
|
-
raise exc.GitlabUploadError("File contents and file path specified")
|
480
|
-
|
481
|
-
if filepath is not None:
|
482
|
-
with open(filepath, "rb") as f:
|
483
|
-
filedata = f.read()
|
484
|
-
|
485
|
-
url = f"/projects/{self.encoded_id}/uploads"
|
486
|
-
file_info = {"file": (filename, filedata)}
|
487
|
-
data = self.manager.gitlab.http_post(url, files=file_info, **kwargs)
|
488
|
-
|
489
|
-
if TYPE_CHECKING:
|
490
|
-
assert isinstance(data, dict)
|
491
|
-
return {"alt": data["alt"], "url": data["url"], "markdown": data["markdown"]}
|
492
|
-
|
493
444
|
@cli.register_custom_action("Project")
|
494
445
|
@exc.on_http_error(exc.GitlabRestoreError)
|
495
446
|
def restore(self, **kwargs: Any) -> None:
|
gitlab/v4/objects/wikis.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from typing import Any, cast, Union
|
2
2
|
|
3
3
|
from gitlab.base import RESTManager, RESTObject
|
4
|
-
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin
|
4
|
+
from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin, UploadMixin
|
5
5
|
from gitlab.types import RequiredOptional
|
6
6
|
|
7
7
|
__all__ = [
|
@@ -12,9 +12,10 @@ __all__ = [
|
|
12
12
|
]
|
13
13
|
|
14
14
|
|
15
|
-
class ProjectWiki(SaveMixin, ObjectDeleteMixin, RESTObject):
|
15
|
+
class ProjectWiki(SaveMixin, ObjectDeleteMixin, UploadMixin, RESTObject):
|
16
16
|
_id_attr = "slug"
|
17
17
|
_repr_attr = "slug"
|
18
|
+
_upload_path = "/projects/{project_id}/wikis/attachments"
|
18
19
|
|
19
20
|
|
20
21
|
class ProjectWikiManager(CRUDMixin, RESTManager):
|
@@ -33,9 +34,10 @@ class ProjectWikiManager(CRUDMixin, RESTManager):
|
|
33
34
|
return cast(ProjectWiki, super().get(id=id, lazy=lazy, **kwargs))
|
34
35
|
|
35
36
|
|
36
|
-
class GroupWiki(SaveMixin, ObjectDeleteMixin, RESTObject):
|
37
|
+
class GroupWiki(SaveMixin, ObjectDeleteMixin, UploadMixin, RESTObject):
|
37
38
|
_id_attr = "slug"
|
38
39
|
_repr_attr = "slug"
|
40
|
+
_upload_path = "/groups/{group_id}/wikis/attachments"
|
39
41
|
|
40
42
|
|
41
43
|
class GroupWikiManager(CRUDMixin, RESTManager):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: python-gitlab
|
3
|
-
Version: 4.
|
3
|
+
Version: 4.2.0
|
4
4
|
Summary: A python wrapper for the GitLab API
|
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>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
gitlab/__init__.py,sha256=bd8BSLyUUjtHMKtzmf-T5855W6FUHcuhIwx2hNu0w2o,1382
|
2
2
|
gitlab/__main__.py,sha256=HTesNl0UAU6mPb9EXWkTKMy6Q6pAUxGi3iPnDHTE2uE,68
|
3
|
-
gitlab/_version.py,sha256=
|
3
|
+
gitlab/_version.py,sha256=YV5YCBnPKqGQ0ofpOS-7sXEufkVPLeL9S2OI0Va7gjw,249
|
4
4
|
gitlab/base.py,sha256=5cotawlHD01Vw88aN4o7wNIhDyk_bmcwubX4mbOpnVo,13780
|
5
5
|
gitlab/cli.py,sha256=uSziJ47Ig7FAIjkWC_R6lRwtv_ZjRnbVruqkwh-DU2s,11911
|
6
6
|
gitlab/client.py,sha256=uOjnB4Bvb2NFYGNLk66s_-4gRUQfZJT_QaHmUJQ1g00,48660
|
7
7
|
gitlab/config.py,sha256=T1DgUXD0-MN2qNszrv-SO5d4uy0FITnNN0vWJgOt2yo,9088
|
8
|
-
gitlab/const.py,sha256=
|
8
|
+
gitlab/const.py,sha256=rtPU-fxVSOvgpueoQVTvZGQp6iAZ-aa3nsY4RcSs_M4,5352
|
9
9
|
gitlab/exceptions.py,sha256=4CC99arH58PGH8cd7eCiFEVjjcw8CRmc1VFmChjqM1k,8220
|
10
|
-
gitlab/mixins.py,sha256=
|
10
|
+
gitlab/mixins.py,sha256=bCa_sI4wbdDrugoMy17ouLeNL5i19hJBsqbSz2QAiP8,34376
|
11
11
|
gitlab/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
12
|
gitlab/types.py,sha256=lepiiI_YOr94B4koqIHuY70tszZC_X3YW4lDvbadbI8,3312
|
13
13
|
gitlab/utils.py,sha256=Ppip4O1MsiNeddyWV4JZR9SNhgIag5MieN58ozoTAgo,6391
|
@@ -69,7 +69,7 @@ gitlab/v4/objects/pages.py,sha256=o6EHYJa-4qo8-IolppZk5Y5o64CAIlLceW2LPNR3nM4,11
|
|
69
69
|
gitlab/v4/objects/personal_access_tokens.py,sha256=5ynVC-tdi3U4hZSMBJfJsQeEh5PbxVF6LxnW00H8Te8,1222
|
70
70
|
gitlab/v4/objects/pipelines.py,sha256=wOSbwULKHVQuoRcoFw-hwkmoZz08LVs2IFNSef9sJhg,9723
|
71
71
|
gitlab/v4/objects/project_access_tokens.py,sha256=I730Y14izzXLbcuhxHbxzASt00i-EUKqb7ynicTP99o,706
|
72
|
-
gitlab/v4/objects/projects.py,sha256=
|
72
|
+
gitlab/v4/objects/projects.py,sha256=RFfIZQsM3DztpqHSjQpzgDaL1BMYiFZIBNbJlH0t_gE,44126
|
73
73
|
gitlab/v4/objects/push_rules.py,sha256=0dKMWEzF5h1zATh0_j_SvjQ7HKx9_5M7J9hzDGB66Rc,3041
|
74
74
|
gitlab/v4/objects/releases.py,sha256=j4_45oOj2yaA2XZ3fwBcKhFJ6li4vQy_zyr013LKfvY,1972
|
75
75
|
gitlab/v4/objects/repositories.py,sha256=A4Dtr8fay_LBUImdtVEkp7c5P2mjgE8SYItKCEM6a8Y,11047
|
@@ -87,11 +87,11 @@ gitlab/v4/objects/topics.py,sha256=24QtZfMcTjFZacLF6GVhdvb267n_ScXQjYfa3Ru_sd4,2
|
|
87
87
|
gitlab/v4/objects/triggers.py,sha256=UAERq_C-QdPBbBQPHLh5IfhpkdDeIxdnVGPHfu9Qy5Y,824
|
88
88
|
gitlab/v4/objects/users.py,sha256=AavShuFgTH4cOHS1AWrv16_JPLvw2lESHYao_sxOnYc,21280
|
89
89
|
gitlab/v4/objects/variables.py,sha256=BZ-DaASsguYKSp1wZ-vuuaUN8OUsMm9jMsAegl-URzc,2626
|
90
|
-
gitlab/v4/objects/wikis.py,sha256=
|
91
|
-
python_gitlab-4.
|
92
|
-
python_gitlab-4.
|
93
|
-
python_gitlab-4.
|
94
|
-
python_gitlab-4.
|
95
|
-
python_gitlab-4.
|
96
|
-
python_gitlab-4.
|
97
|
-
python_gitlab-4.
|
90
|
+
gitlab/v4/objects/wikis.py,sha256=JtI1cQqZV1_PRfKVlQRMh4LZjdxEfi9T2VuFYv6PrV8,1775
|
91
|
+
python_gitlab-4.2.0.dist-info/AUTHORS,sha256=Z0P61GJSVnp7iFbRcMezhx3f4zMyPkVmG--TWaRo768,526
|
92
|
+
python_gitlab-4.2.0.dist-info/COPYING,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
|
93
|
+
python_gitlab-4.2.0.dist-info/METADATA,sha256=zvNrZgbCrsVHewq4f7bhnF26ML3b5Z0SXGPnz6ubLJM,7668
|
94
|
+
python_gitlab-4.2.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
95
|
+
python_gitlab-4.2.0.dist-info/entry_points.txt,sha256=nhpKLLP_uQPFByn8UtE9zsvQQwa402t52o_Cw9IFXMo,43
|
96
|
+
python_gitlab-4.2.0.dist-info/top_level.txt,sha256=MvIaP8p_Oaf4gO_hXmHkX-5y2deHLp1pe6tJR3ukQ6o,7
|
97
|
+
python_gitlab-4.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|