Skip to content

Commit 50bc028

Browse files
authored
Merge branch 'python-gitlab:main' into feat/runner-new-registration
2 parents 004a51a + 9b6d89e commit 50bc028

File tree

15 files changed

+17
-292
lines changed

15 files changed

+17
-292
lines changed

docs/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Example::
4242
Not all items are returned from the API
4343
"""""""""""""""""""""""""""""""""""""""
4444

45-
If you've passed ``all=True`` (or ``--all`` via the CLI) to the API and still cannot see all items returned,
45+
If you've passed ``all=True`` to the API and still cannot see all items returned,
4646
use ``get_all=True`` (or ``--get-all`` via the CLI) instead. See :ref:`pagination` for more details.
4747

4848
Common errors

docs/gl_objects/pipelines_and_jobs.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,6 @@ a branch or tag::
255255

256256
project.artifacts.download(ref_name='main', job='build')
257257

258-
.. attention::
259-
260-
An older method ``project.artifacts()`` is deprecated and will be
261-
removed in a future version.
262-
263258
.. warning::
264259

265260
Artifacts are entirely stored in memory in this example.
@@ -305,11 +300,6 @@ Get a single artifact file by branch and job::
305300

306301
project.artifacts.raw('branch', 'path/to/file', 'job')
307302

308-
.. attention::
309-
310-
An older method ``project.artifact()`` is deprecated and will be
311-
removed in a future version.
312-
313303
Mark a job artifact as kept when expiration is set::
314304

315305
build_or_job.keep_artifacts()

gitlab/client.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -402,32 +402,6 @@ def version(self) -> Tuple[str, str]:
402402

403403
return cast(str, self._server_version), cast(str, self._server_revision)
404404

405-
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabVerifyError)
406-
def lint(self, content: str, **kwargs: Any) -> Tuple[bool, List[str]]:
407-
"""Validate a gitlab CI configuration.
408-
409-
Args:
410-
content: The .gitlab-ci.yml content
411-
**kwargs: Extra options to send to the server (e.g. sudo)
412-
413-
Raises:
414-
GitlabAuthenticationError: If authentication is not correct
415-
GitlabVerifyError: If the validation could not be done
416-
417-
Returns:
418-
(True, []) if the file is valid, (False, errors(list)) otherwise
419-
"""
420-
utils.warn(
421-
"`lint()` is deprecated and will be removed in a future version.\n"
422-
"Please use `ci_lint.create()` instead.",
423-
category=DeprecationWarning,
424-
)
425-
post_data = {"content": content}
426-
data = self.http_post("/ci/lint", post_data=post_data, **kwargs)
427-
if TYPE_CHECKING:
428-
assert not isinstance(data, requests.Response)
429-
return (data["status"] == "valid", data["errors"])
430-
431405
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabMarkdownError)
432406
def markdown(
433407
self, text: str, gfm: bool = False, project: Optional[str] = None, **kwargs: Any
@@ -869,7 +843,6 @@ def http_list(
869843
path: str,
870844
query_data: Optional[Dict[str, Any]] = None,
871845
*,
872-
as_list: Optional[bool] = None, # Deprecated in favor of `iterator`
873846
iterator: Optional[bool] = None,
874847
**kwargs: Any,
875848
) -> Union["GitlabList", List[Dict[str, Any]]]:
@@ -896,23 +869,6 @@ def http_list(
896869
"""
897870
query_data = query_data or {}
898871

899-
# Don't allow both `as_list` and `iterator` to be set.
900-
if as_list is not None and iterator is not None:
901-
raise ValueError(
902-
"Only one of `as_list` or `iterator` can be used. "
903-
"Use `iterator` instead of `as_list`. `as_list` is deprecated."
904-
)
905-
906-
if as_list is not None:
907-
iterator = not as_list
908-
utils.warn(
909-
message=(
910-
f"`as_list={as_list}` is deprecated and will be removed in a "
911-
f"future version. Use `iterator={iterator}` instead."
912-
),
913-
category=DeprecationWarning,
914-
)
915-
916872
# Provide a `get_all`` param to avoid clashes with `all` API attributes.
917873
get_all = kwargs.pop("get_all", None)
918874

@@ -926,8 +882,6 @@ def http_list(
926882

927883
if iterator and page is not None:
928884
arg_used_message = f"iterator={iterator}"
929-
if as_list is not None:
930-
arg_used_message = f"as_list={as_list}"
931885
utils.warn(
932886
message=(
933887
f"`{arg_used_message}` and `page={page}` were both specified. "

gitlab/v4/cli.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,6 @@ def _populate_sub_parser_by_class(
236236
action="store_true",
237237
help="Return all items from the server, without pagination.",
238238
)
239-
sub_parser_action.add_argument(
240-
"--all",
241-
required=False,
242-
action="store_true",
243-
help="Deprecated. Use --get-all instead.",
244-
)
245239

246240
if action_name == "delete":
247241
if cls._id_attr is not None:

gitlab/v4/objects/artifacts.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,6 @@ class ProjectArtifactManager(RESTManager):
2525
_path = "/projects/{project_id}/jobs/artifacts"
2626
_from_parent_attrs = {"project_id": "id"}
2727

28-
@cli.register_custom_action(
29-
"Project", ("ref_name", "job"), ("job_token",), custom_action="artifacts"
30-
)
31-
def __call__(
32-
self,
33-
*args: Any,
34-
**kwargs: Any,
35-
) -> Optional[bytes]:
36-
utils.warn(
37-
message=(
38-
"The project.artifacts() method is deprecated and will be removed in a "
39-
"future version. Use project.artifacts.download() instead.\n"
40-
),
41-
category=DeprecationWarning,
42-
)
43-
data = self.download(
44-
*args,
45-
**kwargs,
46-
)
47-
if TYPE_CHECKING:
48-
assert data is not None
49-
assert isinstance(data, bytes)
50-
return data
51-
5228
@exc.on_http_error(exc.GitlabDeleteError)
5329
def delete(self, **kwargs: Any) -> None:
5430
"""Delete the project's artifacts on the server.

gitlab/v4/objects/commits.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class ProjectCommitManager(RetrieveMixin, CreateMixin, RESTManager):
155155
optional=("author_email", "author_name"),
156156
)
157157
_list_filters = (
158+
"all",
158159
"ref_name",
159160
"since",
160161
"until",

gitlab/v4/objects/groups.py

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import gitlab
66
from gitlab import cli
77
from gitlab import exceptions as exc
8-
from gitlab import types, utils
8+
from gitlab import types
99
from gitlab.base import RESTManager, RESTObject
1010
from gitlab.mixins import (
1111
CreateMixin,
@@ -164,64 +164,6 @@ def search(
164164
path = f"/groups/{self.encoded_id}/search"
165165
return self.manager.gitlab.http_list(path, query_data=data, **kwargs)
166166

167-
@cli.register_custom_action("Group", ("cn", "group_access", "provider"))
168-
@exc.on_http_error(exc.GitlabCreateError)
169-
def add_ldap_group_link(
170-
self, cn: str, group_access: int, provider: str, **kwargs: Any
171-
) -> None:
172-
"""Add an LDAP group link.
173-
174-
Args:
175-
cn: CN of the LDAP group
176-
group_access: Minimum access level for members of the LDAP
177-
group
178-
provider: LDAP provider for the LDAP group
179-
**kwargs: Extra options to send to the server (e.g. sudo)
180-
181-
Raises:
182-
GitlabAuthenticationError: If authentication is not correct
183-
GitlabCreateError: If the server cannot perform the request
184-
"""
185-
utils.warn(
186-
message=(
187-
"The add_ldap_group_link() method is deprecated and will be removed "
188-
"in a future version. Use ldap_group_links.create() instead."
189-
),
190-
category=DeprecationWarning,
191-
)
192-
path = f"/groups/{self.encoded_id}/ldap_group_links"
193-
data = {"cn": cn, "group_access": group_access, "provider": provider}
194-
self.manager.gitlab.http_post(path, post_data=data, **kwargs)
195-
196-
@cli.register_custom_action("Group", ("cn",), ("provider",))
197-
@exc.on_http_error(exc.GitlabDeleteError)
198-
def delete_ldap_group_link(
199-
self, cn: str, provider: Optional[str] = None, **kwargs: Any
200-
) -> None:
201-
"""Delete an LDAP group link.
202-
203-
Args:
204-
cn: CN of the LDAP group
205-
provider: LDAP provider for the LDAP group
206-
**kwargs: Extra options to send to the server (e.g. sudo)
207-
208-
Raises:
209-
GitlabAuthenticationError: If authentication is not correct
210-
GitlabDeleteError: If the server cannot perform the request
211-
"""
212-
utils.warn(
213-
message=(
214-
"The delete_ldap_group_link() method is deprecated and will be "
215-
"removed in a future version. Use ldap_group_links.delete() instead."
216-
),
217-
category=DeprecationWarning,
218-
)
219-
path = f"/groups/{self.encoded_id}/ldap_group_links"
220-
if provider is not None:
221-
path += f"/{provider}"
222-
path += f"/{cn}"
223-
self.manager.gitlab.http_delete(path, **kwargs)
224-
225167
@cli.register_custom_action("Group")
226168
@exc.on_http_error(exc.GitlabCreateError)
227169
def ldap_sync(self, **kwargs: Any) -> None:

gitlab/v4/objects/projects.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -625,37 +625,6 @@ def transfer(self, to_namespace: Union[int, str], **kwargs: Any) -> None:
625625
path, post_data={"namespace": to_namespace}, **kwargs
626626
)
627627

628-
@cli.register_custom_action("Project", ("to_namespace",))
629-
def transfer_project(self, *args: Any, **kwargs: Any) -> None:
630-
utils.warn(
631-
message=(
632-
"The project.transfer_project() method is deprecated and will be "
633-
"removed in a future version. Use project.transfer() instead."
634-
),
635-
category=DeprecationWarning,
636-
)
637-
return self.transfer(*args, **kwargs)
638-
639-
@cli.register_custom_action("Project", ("ref_name", "artifact_path", "job"))
640-
@exc.on_http_error(exc.GitlabGetError)
641-
def artifact(
642-
self,
643-
*args: Any,
644-
**kwargs: Any,
645-
) -> Optional[bytes]:
646-
utils.warn(
647-
message=(
648-
"The project.artifact() method is deprecated and will be "
649-
"removed in a future version. Use project.artifacts.raw() instead."
650-
),
651-
category=DeprecationWarning,
652-
)
653-
data = self.artifacts.raw(*args, **kwargs)
654-
if TYPE_CHECKING:
655-
assert data is not None
656-
assert isinstance(data, bytes)
657-
return data
658-
659628

660629
class ProjectManager(CRUDMixin, RESTManager):
661630
_path = "/projects"

gitlab/v4/objects/releases.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ class ProjectReleaseLinkManager(CRUDMixin, RESTManager):
5050
_obj_cls = ProjectReleaseLink
5151
_from_parent_attrs = {"project_id": "project_id", "tag_name": "tag_name"}
5252
_create_attrs = RequiredOptional(
53-
required=("name", "url"), optional=("filepath", "link_type")
53+
required=("name", "url"),
54+
optional=("filepath", "direct_asset_path", "link_type"),
55+
)
56+
_update_attrs = RequiredOptional(
57+
optional=("name", "url", "filepath", "direct_asset_path", "link_type")
5458
)
55-
_update_attrs = RequiredOptional(optional=("name", "url", "filepath", "link_type"))
5659

5760
def get(
5861
self, id: Union[str, int], lazy: bool = False, **kwargs: Any

tests/functional/api/test_gitlab.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ def test_markdown_in_project(gl, project):
6666
assert "foo" in html
6767

6868

69-
def test_lint(gl):
70-
with pytest.deprecated_call():
71-
success, errors = gl.lint("Invalid")
72-
assert success is False
73-
assert errors
74-
75-
7669
def test_sidekiq_queue_metrics(gl):
7770
out = gl.sidekiq.queue_metrics()
7871
assert isinstance(out, dict)
@@ -289,17 +282,3 @@ def test_list_iterator_true_nowarning(gl, recwarn):
289282
items = gl.gitlabciymls.list(iterator=True)
290283
assert not recwarn
291284
assert len(list(items)) > 20
292-
293-
294-
def test_list_as_list_false_warnings(gl):
295-
"""Using `as_list=False` will disable the UserWarning but cause a
296-
DeprecationWarning"""
297-
with pytest.warns(DeprecationWarning) as record:
298-
items = gl.gitlabciymls.list(as_list=False)
299-
assert len(record) == 1
300-
assert len(list(items)) > 20
301-
302-
303-
def test_list_with_as_list_and_iterator_raises(gl):
304-
with pytest.raises(ValueError, match="`as_list` or `iterator`"):
305-
gl.gitlabciymls.list(as_list=False, iterator=True)

tests/functional/cli/test_cli_artifacts.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -77,29 +77,6 @@ def test_cli_project_artifact_download(gitlab_config, job_with_artifacts):
7777
assert is_zipfile(artifacts_zip)
7878

7979

80-
def test_cli_project_artifacts_warns_deprecated(gitlab_config, job_with_artifacts):
81-
cmd = [
82-
"gitlab",
83-
"--config-file",
84-
gitlab_config,
85-
"project",
86-
"artifacts",
87-
"--id",
88-
str(job_with_artifacts.pipeline["project_id"]),
89-
"--ref-name",
90-
job_with_artifacts.ref,
91-
"--job",
92-
job_with_artifacts.name,
93-
]
94-
95-
artifacts = subprocess.run(cmd, capture_output=True, check=True)
96-
assert isinstance(artifacts.stdout, bytes)
97-
assert b"DeprecationWarning" in artifacts.stderr
98-
99-
artifacts_zip = BytesIO(artifacts.stdout)
100-
assert is_zipfile(artifacts_zip)
101-
102-
10380
def test_cli_project_artifact_raw(gitlab_config, job_with_artifacts):
10481
cmd = [
10582
"gitlab",
@@ -120,26 +97,3 @@ def test_cli_project_artifact_raw(gitlab_config, job_with_artifacts):
12097
artifacts = subprocess.run(cmd, capture_output=True, check=True)
12198
assert isinstance(artifacts.stdout, bytes)
12299
assert artifacts.stdout == b"test\n"
123-
124-
125-
def test_cli_project_artifact_warns_deprecated(gitlab_config, job_with_artifacts):
126-
cmd = [
127-
"gitlab",
128-
"--config-file",
129-
gitlab_config,
130-
"project",
131-
"artifact",
132-
"--id",
133-
str(job_with_artifacts.pipeline["project_id"]),
134-
"--ref-name",
135-
job_with_artifacts.ref,
136-
"--job",
137-
job_with_artifacts.name,
138-
"--artifact-path",
139-
"artifact.txt",
140-
]
141-
142-
artifacts = subprocess.run(cmd, capture_output=True, check=True)
143-
assert isinstance(artifacts.stdout, bytes)
144-
assert b"DeprecationWarning" in artifacts.stderr
145-
assert artifacts.stdout == b"test\n"

tests/functional/cli/test_cli_repository.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ def test_list_all_commits(gitlab_cli, project):
4343
assert commit.id not in ret.stdout
4444

4545
# Listing commits on other branches requires `all` parameter passed to the API
46-
cmd = ["project-commit", "list", "--project-id", project.id, "--get-all", "--all"]
46+
cmd = [
47+
"project-commit",
48+
"list",
49+
"--project-id",
50+
project.id,
51+
"--get-all",
52+
"--all",
53+
"true",
54+
]
4755
ret_all = gitlab_cli(cmd)
4856
assert commit.id in ret_all.stdout
4957
assert len(ret_all.stdout) > len(ret.stdout)

0 commit comments

Comments
 (0)