summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects/projects.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/v4/objects/projects.py')
-rw-r--r--gitlab/v4/objects/projects.py61
1 files changed, 28 insertions, 33 deletions
diff --git a/gitlab/v4/objects/projects.py b/gitlab/v4/objects/projects.py
index 551079a..ac18158 100644
--- a/gitlab/v4/objects/projects.py
+++ b/gitlab/v4/objects/projects.py
@@ -176,7 +176,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the relation could not be created
"""
- path = "/projects/%s/fork/%s" % (self.get_id(), forked_from_id)
+ path = f"/projects/{self.get_id()}/fork/{forked_from_id}"
self.manager.gitlab.http_post(path, **kwargs)
@cli.register_custom_action("Project")
@@ -191,7 +191,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server failed to perform the request
"""
- path = "/projects/%s/fork" % self.get_id()
+ path = f"/projects/{self.get_id()}/fork"
self.manager.gitlab.http_delete(path, **kwargs)
@cli.register_custom_action("Project")
@@ -206,7 +206,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabGetError: If the server failed to perform the request
"""
- path = "/projects/%s/languages" % self.get_id()
+ path = f"/projects/{self.get_id()}/languages"
return self.manager.gitlab.http_get(path, **kwargs)
@cli.register_custom_action("Project")
@@ -221,7 +221,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server failed to perform the request
"""
- path = "/projects/%s/star" % self.get_id()
+ path = f"/projects/{self.get_id()}/star"
server_data = self.manager.gitlab.http_post(path, **kwargs)
if TYPE_CHECKING:
assert isinstance(server_data, dict)
@@ -239,7 +239,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server failed to perform the request
"""
- path = "/projects/%s/unstar" % self.get_id()
+ path = f"/projects/{self.get_id()}/unstar"
server_data = self.manager.gitlab.http_post(path, **kwargs)
if TYPE_CHECKING:
assert isinstance(server_data, dict)
@@ -257,7 +257,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server failed to perform the request
"""
- path = "/projects/%s/archive" % self.get_id()
+ path = f"/projects/{self.get_id()}/archive"
server_data = self.manager.gitlab.http_post(path, **kwargs)
if TYPE_CHECKING:
assert isinstance(server_data, dict)
@@ -275,7 +275,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server failed to perform the request
"""
- path = "/projects/%s/unarchive" % self.get_id()
+ path = f"/projects/{self.get_id()}/unarchive"
server_data = self.manager.gitlab.http_post(path, **kwargs)
if TYPE_CHECKING:
assert isinstance(server_data, dict)
@@ -290,7 +290,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
group_id: int,
group_access: int,
expires_at: Optional[str] = None,
- **kwargs: Any
+ **kwargs: Any,
) -> None:
"""Share the project with a group.
@@ -303,7 +303,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server failed to perform the request
"""
- path = "/projects/%s/share" % self.get_id()
+ path = f"/projects/{self.get_id()}/share"
data = {
"group_id": group_id,
"group_access": group_access,
@@ -324,7 +324,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server failed to perform the request
"""
- path = "/projects/%s/share/%s" % (self.get_id(), group_id)
+ path = f"/projects/{self.get_id()}/share/{group_id}"
self.manager.gitlab.http_delete(path, **kwargs)
# variables not supported in CLI
@@ -335,7 +335,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
ref: str,
token: str,
variables: Optional[Dict[str, Any]] = None,
- **kwargs: Any
+ **kwargs: Any,
) -> ProjectPipeline:
"""Trigger a CI build.
@@ -352,7 +352,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabCreateError: If the server failed to perform the request
"""
variables = variables or {}
- path = "/projects/%s/trigger/pipeline" % self.get_id()
+ path = f"/projects/{self.get_id()}/trigger/pipeline"
post_data = {"ref": ref, "token": token, "variables": variables}
attrs = self.manager.gitlab.http_post(path, post_data=post_data, **kwargs)
if TYPE_CHECKING:
@@ -372,7 +372,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabHousekeepingError: If the server failed to perform the
request
"""
- path = "/projects/%s/housekeeping" % self.get_id()
+ path = f"/projects/{self.get_id()}/housekeeping"
self.manager.gitlab.http_post(path, **kwargs)
# see #56 - add file attachment features
@@ -383,7 +383,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
filename: str,
filedata: Optional[bytes] = None,
filepath: Optional[str] = None,
- **kwargs: Any
+ **kwargs: Any,
) -> Dict[str, Any]:
"""Upload the specified file into the project.
@@ -420,7 +420,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
with open(filepath, "rb") as f:
filedata = f.read()
- url = "/projects/%(id)s/uploads" % {"id": self.id}
+ url = f"/projects/{self.id}/uploads"
file_info = {"file": (filename, filedata)}
data = self.manager.gitlab.http_post(url, files=file_info)
@@ -436,7 +436,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
streamed: bool = False,
action: Optional[Callable] = None,
chunk_size: int = 1024,
- **kwargs: Any
+ **kwargs: Any,
) -> Optional[bytes]:
"""Return a snapshot of the repository.
@@ -457,7 +457,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
Returns:
str: The uncompressed tar archive of the repository
"""
- path = "/projects/%s/snapshot" % self.get_id()
+ path = f"/projects/{self.get_id()}/snapshot"
result = self.manager.gitlab.http_get(
path, streamed=streamed, raw=True, **kwargs
)
@@ -485,7 +485,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabList: A list of dicts describing the resources found.
"""
data = {"scope": scope, "search": search}
- path = "/projects/%s/search" % self.get_id()
+ path = f"/projects/{self.get_id()}/search"
return self.manager.gitlab.http_list(path, query_data=data, **kwargs)
@cli.register_custom_action("Project")
@@ -500,7 +500,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabCreateError: If the server failed to perform the request
"""
- path = "/projects/%s/mirror/pull" % self.get_id()
+ path = f"/projects/{self.get_id()}/mirror/pull"
self.manager.gitlab.http_post(path, **kwargs)
@cli.register_custom_action("Project", ("to_namespace",))
@@ -517,7 +517,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
GitlabAuthenticationError: If authentication is not correct
GitlabTransferProjectError: If the project could not be transferred
"""
- path = "/projects/%s/transfer" % (self.id,)
+ path = f"/projects/{self.id}/transfer"
self.manager.gitlab.http_put(
path, post_data={"namespace": to_namespace}, **kwargs
)
@@ -531,7 +531,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
streamed: bool = False,
action: Optional[Callable] = None,
chunk_size: int = 1024,
- **kwargs: Any
+ **kwargs: Any,
) -> Optional[bytes]:
"""Get the job artifacts archive from a specific tag or branch.
@@ -556,7 +556,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
Returns:
str: The artifacts if `streamed` is False, None otherwise.
"""
- path = "/projects/%s/jobs/artifacts/%s/download" % (self.get_id(), ref_name)
+ path = f"/projects/{self.get_id()}/jobs/artifacts/{ref_name}/download"
result = self.manager.gitlab.http_get(
path, job=job, streamed=streamed, raw=True, **kwargs
)
@@ -574,7 +574,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
streamed: bool = False,
action: Optional[Callable] = None,
chunk_size: int = 1024,
- **kwargs: Any
+ **kwargs: Any,
) -> Optional[bytes]:
"""Download a single artifact file from a specific tag or branch from within the job’s artifacts archive.
@@ -598,12 +598,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
str: The artifacts if `streamed` is False, None otherwise.
"""
- path = "/projects/%s/jobs/artifacts/%s/raw/%s?job=%s" % (
- self.get_id(),
- ref_name,
- artifact_path,
- job,
- )
+ path = f"/projects/{self.get_id()}/jobs/artifacts/{ref_name}/raw/{artifact_path}?job={job}"
result = self.manager.gitlab.http_get(
path, streamed=streamed, raw=True, **kwargs
)
@@ -787,7 +782,7 @@ class ProjectManager(CRUDMixin, RESTManager):
namespace: Optional[str] = None,
overwrite: bool = False,
override_params: Optional[Dict[str, Any]] = None,
- **kwargs: Any
+ **kwargs: Any,
) -> Union[Dict[str, Any], requests.Response]:
"""Import a project from an archive file.
@@ -812,7 +807,7 @@ class ProjectManager(CRUDMixin, RESTManager):
data = {"path": path, "overwrite": str(overwrite)}
if override_params:
for k, v in override_params.items():
- data["override_params[%s]" % k] = v
+ data[f"override_params[{k}]"] = v
if name is not None:
data["name"] = name
if namespace:
@@ -830,7 +825,7 @@ class ProjectManager(CRUDMixin, RESTManager):
bitbucket_server_repo: str,
new_name: Optional[str] = None,
target_namespace: Optional[str] = None,
- **kwargs: Any
+ **kwargs: Any,
) -> Union[Dict[str, Any], requests.Response]:
"""Import a project from BitBucket Server to Gitlab (schedule the import)
@@ -918,7 +913,7 @@ class ProjectManager(CRUDMixin, RESTManager):
repo_id: int,
target_namespace: str,
new_name: Optional[str] = None,
- **kwargs: Any
+ **kwargs: Any,
) -> Union[Dict[str, Any], requests.Response]:
"""Import a project from Github to Gitlab (schedule the import)