Skip to content

Commit 0c98b2d

Browse files
nejchJohnVillalovos
authored andcommitted
refactor: explicitly use ProjectSecureFile
1 parent ad7c8fa commit 0c98b2d

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

docs/gl_objects/secure_files.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ References
1010

1111
* v4 API:
1212

13-
+ :class:`gitlab.v4.objects.SecureFile`
14-
+ :class:`gitlab.v4.objects.SecureFileManager`
13+
+ :class:`gitlab.v4.objects.ProjectSecureFile`
14+
+ :class:`gitlab.v4.objects.ProjectSecureFileManager`
1515
+ :attr:`gitlab.v4.objects.Project.secure_files`
1616

1717
* GitLab API: https://docs.gitlab.com/ee/api/secure_files.html

gitlab/v4/objects/projects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
from .releases import ProjectReleaseManager # noqa: F401
8383
from .repositories import RepositoryMixin
8484
from .runners import ProjectRunnerManager # noqa: F401
85-
from .secure_files import SecureFileManager # noqa: F401
85+
from .secure_files import ProjectSecureFileManager # noqa: F401
8686
from .snippets import ProjectSnippetManager # noqa: F401
8787
from .statistics import ( # noqa: F401
8888
ProjectAdditionalStatisticsManager,
@@ -210,7 +210,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
210210
remote_mirrors: "ProjectRemoteMirrorManager"
211211
repositories: ProjectRegistryRepositoryManager
212212
runners: ProjectRunnerManager
213-
secure_files: SecureFileManager
213+
secure_files: ProjectSecureFileManager
214214
services: ProjectServiceManager
215215
snippets: ProjectSnippetManager
216216
storage: "ProjectStorageManager"

gitlab/v4/objects/secure_files.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin
1414
from gitlab.types import FileAttribute, RequiredOptional
1515

16-
__all__ = ["SecureFile", "SecureFileManager"]
16+
__all__ = ["ProjectSecureFile", "ProjectSecureFileManager"]
1717

1818

19-
class SecureFile(ObjectDeleteMixin, RESTObject):
20-
@cli.register_custom_action("SecureFile")
19+
class ProjectSecureFile(ObjectDeleteMixin, RESTObject):
20+
@cli.register_custom_action("ProjectSecureFile")
2121
@exc.on_http_error(exc.GitlabGetError)
2222
def download(
2323
self,
@@ -58,12 +58,14 @@ def download(
5858
)
5959

6060

61-
class SecureFileManager(NoUpdateMixin, RESTManager):
61+
class ProjectSecureFileManager(NoUpdateMixin, RESTManager):
6262
_path = "/projects/{project_id}/secure_files"
63-
_obj_cls = SecureFile
63+
_obj_cls = ProjectSecureFile
6464
_from_parent_attrs = {"project_id": "id"}
6565
_create_attrs = RequiredOptional(required=("name", "file"))
6666
_types = {"file": FileAttribute}
6767

68-
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> SecureFile:
69-
return cast(SecureFile, super().get(id=id, lazy=lazy, **kwargs))
68+
def get(
69+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
70+
) -> ProjectSecureFile:
71+
return cast(ProjectSecureFile, super().get(id=id, lazy=lazy, **kwargs))

tests/unit/objects/test_secure_files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66
import responses
77

8-
from gitlab.v4.objects import SecureFile
8+
from gitlab.v4.objects import ProjectSecureFile
99

1010
secure_file_content = {
1111
"id": 1,
@@ -93,7 +93,7 @@ def test_create_secure_file(project, resp_create_secure_file):
9393
def test_download_secure_file(project, binary_content, resp_download_secure_file):
9494
secure_file = project.secure_files.get(1)
9595
secure_content = secure_file.download()
96-
assert isinstance(secure_file, SecureFile)
96+
assert isinstance(secure_file, ProjectSecureFile)
9797
assert secure_content == binary_content
9898

9999

0 commit comments

Comments
 (0)