summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNejc Habjan <nejc.habjan@siemens.com>2022-11-17 18:34:10 +0100
committerJohn Villalovos <john@sodarock.com>2022-11-17 14:39:05 -0800
commit0c98b2d8f4b8c1ac6a4b496282f307687b652759 (patch)
treeccf45b0379cd07526ad536732b4232dd47c98a44
parentad7c8fafd56866002aa6723ceeba4c4bc071ca0d (diff)
downloadgitlab-0c98b2d8f4b8c1ac6a4b496282f307687b652759.tar.gz
refactor: explicitly use ProjectSecureFile
-rw-r--r--docs/gl_objects/secure_files.rst4
-rw-r--r--gitlab/v4/objects/projects.py4
-rw-r--r--gitlab/v4/objects/secure_files.py16
-rw-r--r--tests/unit/objects/test_secure_files.py4
4 files changed, 15 insertions, 13 deletions
diff --git a/docs/gl_objects/secure_files.rst b/docs/gl_objects/secure_files.rst
index e7374bb..6fe1d2e 100644
--- a/docs/gl_objects/secure_files.rst
+++ b/docs/gl_objects/secure_files.rst
@@ -10,8 +10,8 @@ References
* v4 API:
- + :class:`gitlab.v4.objects.SecureFile`
- + :class:`gitlab.v4.objects.SecureFileManager`
+ + :class:`gitlab.v4.objects.ProjectSecureFile`
+ + :class:`gitlab.v4.objects.ProjectSecureFileManager`
+ :attr:`gitlab.v4.objects.Project.secure_files`
* GitLab API: https://docs.gitlab.com/ee/api/secure_files.html
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py
index fad21eb..e030965 100644
--- a/gitlab/v4/objects/projects.py
+++ b/gitlab/v4/objects/projects.py
@@ -82,7 +82,7 @@ from .push_rules import ProjectPushRulesManager # noqa: F401
from .releases import ProjectReleaseManager # noqa: F401
from .repositories import RepositoryMixin
from .runners import ProjectRunnerManager # noqa: F401
-from .secure_files import SecureFileManager # noqa: F401
+from .secure_files import ProjectSecureFileManager # noqa: F401
from .snippets import ProjectSnippetManager # noqa: F401
from .statistics import ( # noqa: F401
ProjectAdditionalStatisticsManager,
@@ -210,7 +210,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
remote_mirrors: "ProjectRemoteMirrorManager"
repositories: ProjectRegistryRepositoryManager
runners: ProjectRunnerManager
- secure_files: SecureFileManager
+ secure_files: ProjectSecureFileManager
services: ProjectServiceManager
snippets: ProjectSnippetManager
storage: "ProjectStorageManager"
diff --git a/gitlab/v4/objects/secure_files.py b/gitlab/v4/objects/secure_files.py
index ce8d12d..a7da5ea 100644
--- a/gitlab/v4/objects/secure_files.py
+++ b/gitlab/v4/objects/secure_files.py
@@ -13,11 +13,11 @@ from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import NoUpdateMixin, ObjectDeleteMixin
from gitlab.types import FileAttribute, RequiredOptional
-__all__ = ["SecureFile", "SecureFileManager"]
+__all__ = ["ProjectSecureFile", "ProjectSecureFileManager"]
-class SecureFile(ObjectDeleteMixin, RESTObject):
- @cli.register_custom_action("SecureFile")
+class ProjectSecureFile(ObjectDeleteMixin, RESTObject):
+ @cli.register_custom_action("ProjectSecureFile")
@exc.on_http_error(exc.GitlabGetError)
def download(
self,
@@ -58,12 +58,14 @@ class SecureFile(ObjectDeleteMixin, RESTObject):
)
-class SecureFileManager(NoUpdateMixin, RESTManager):
+class ProjectSecureFileManager(NoUpdateMixin, RESTManager):
_path = "/projects/{project_id}/secure_files"
- _obj_cls = SecureFile
+ _obj_cls = ProjectSecureFile
_from_parent_attrs = {"project_id": "id"}
_create_attrs = RequiredOptional(required=("name", "file"))
_types = {"file": FileAttribute}
- def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> SecureFile:
- return cast(SecureFile, super().get(id=id, lazy=lazy, **kwargs))
+ def get(
+ self, id: Union[str, int], lazy: bool = False, **kwargs: Any
+ ) -> ProjectSecureFile:
+ return cast(ProjectSecureFile, super().get(id=id, lazy=lazy, **kwargs))
diff --git a/tests/unit/objects/test_secure_files.py b/tests/unit/objects/test_secure_files.py
index b614dc2..4aa2136 100644
--- a/tests/unit/objects/test_secure_files.py
+++ b/tests/unit/objects/test_secure_files.py
@@ -5,7 +5,7 @@ GitLab API: https://docs.gitlab.com/ee/api/secure_files.html
import pytest
import responses
-from gitlab.v4.objects import SecureFile
+from gitlab.v4.objects import ProjectSecureFile
secure_file_content = {
"id": 1,
@@ -93,7 +93,7 @@ def test_create_secure_file(project, resp_create_secure_file):
def test_download_secure_file(project, binary_content, resp_download_secure_file):
secure_file = project.secure_files.get(1)
secure_content = secure_file.download()
- assert isinstance(secure_file, SecureFile)
+ assert isinstance(secure_file, ProjectSecureFile)
assert secure_content == binary_content