|
18 | 18 | )
|
19 | 19 |
|
20 | 20 | from .access_requestsimportProjectAccessRequestManager# noqa: F401
|
| 21 | +from .artifactsimportProjectArtifactManager# noqa: F401 |
21 | 22 | from .audit_eventsimportProjectAuditEventManager# noqa: F401
|
22 | 23 | from .badgesimportProjectBadgeManager# noqa: F401
|
23 | 24 | from .boardsimportProjectBoardManager# noqa: F401
|
@@ -136,6 +137,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
|
136 | 137 | additionalstatistics:ProjectAdditionalStatisticsManager
|
137 | 138 | approvalrules:ProjectApprovalRuleManager
|
138 | 139 | approvals:ProjectApprovalManager
|
| 140 | +artifacts:ProjectArtifactManager |
139 | 141 | audit_events:ProjectAuditEventManager
|
140 | 142 | badges:ProjectBadgeManager
|
141 | 143 | boards:ProjectBoardManager
|
@@ -553,94 +555,19 @@ def transfer_project(self, *args: Any, **kwargs: Any) -> None:
|
553 | 555 | )
|
554 | 556 | returnself.transfer(*args,**kwargs)
|
555 | 557 |
|
556 |
| -@cli.register_custom_action("Project", ("ref_name","job"), ("job_token",)) |
557 |
| -@exc.on_http_error(exc.GitlabGetError) |
558 |
| -defartifacts( |
559 |
| -self, |
560 |
| -ref_name:str, |
561 |
| -job:str, |
562 |
| -streamed:bool=False, |
563 |
| -action:Optional[Callable]=None, |
564 |
| -chunk_size:int=1024, |
565 |
| -**kwargs:Any, |
566 |
| - )->Optional[bytes]: |
567 |
| -"""Get the job artifacts archive from a specific tag or branch. |
568 |
| -
|
569 |
| - Args: |
570 |
| - ref_name: Branch or tag name in repository. HEAD or SHA references |
571 |
| - are not supported. |
572 |
| - artifact_path: Path to a file inside the artifacts archive. |
573 |
| - job: The name of the job. |
574 |
| - job_token: Job token for multi-project pipeline triggers. |
575 |
| - streamed: If True the data will be processed by chunks of |
576 |
| - `chunk_size` and each chunk is passed to `action` for |
577 |
| - treatment |
578 |
| - action: Callable responsible of dealing with chunk of |
579 |
| - data |
580 |
| - chunk_size: Size of each chunk |
581 |
| - **kwargs: Extra options to send to the server (e.g. sudo) |
582 |
| -
|
583 |
| - Raises: |
584 |
| - GitlabAuthenticationError: If authentication is not correct |
585 |
| - GitlabGetError: If the artifacts could not be retrieved |
586 |
| -
|
587 |
| - Returns: |
588 |
| - The artifacts if `streamed` is False, None otherwise. |
589 |
| - """ |
590 |
| -path=f"/projects/{self.encoded_id}/jobs/artifacts/{ref_name}/download" |
591 |
| -result=self.manager.gitlab.http_get( |
592 |
| -path,job=job,streamed=streamed,raw=True,**kwargs |
593 |
| - ) |
594 |
| -ifTYPE_CHECKING: |
595 |
| -assertisinstance(result,requests.Response) |
596 |
| -returnutils.response_content(result,streamed,action,chunk_size) |
597 |
| - |
598 | 558 | @cli.register_custom_action("Project", ("ref_name","artifact_path","job"))
|
599 | 559 | @exc.on_http_error(exc.GitlabGetError)
|
600 | 560 | defartifact(
|
601 | 561 | self,
|
602 |
| -ref_name:str, |
603 |
| -artifact_path:str, |
604 |
| -job:str, |
605 |
| -streamed:bool=False, |
606 |
| -action:Optional[Callable]=None, |
607 |
| -chunk_size:int=1024, |
| 562 | +*args:Any, |
608 | 563 | **kwargs:Any,
|
609 | 564 | )->Optional[bytes]:
|
610 |
| -"""Download a single artifact file from a specific tag or branch from |
611 |
| - within the job’s artifacts archive. |
612 |
| -
|
613 |
| - Args: |
614 |
| - ref_name: Branch or tag name in repository. HEAD or SHA references |
615 |
| - are not supported. |
616 |
| - artifact_path: Path to a file inside the artifacts archive. |
617 |
| - job: The name of the job. |
618 |
| - streamed: If True the data will be processed by chunks of |
619 |
| - `chunk_size` and each chunk is passed to `action` for |
620 |
| - treatment |
621 |
| - action: Callable responsible of dealing with chunk of |
622 |
| - data |
623 |
| - chunk_size: Size of each chunk |
624 |
| - **kwargs: Extra options to send to the server (e.g. sudo) |
625 |
| -
|
626 |
| - Raises: |
627 |
| - GitlabAuthenticationError: If authentication is not correct |
628 |
| - GitlabGetError: If the artifacts could not be retrieved |
629 |
| -
|
630 |
| - Returns: |
631 |
| - The artifacts if `streamed` is False, None otherwise. |
632 |
| - """ |
633 |
| - |
634 |
| -path= ( |
635 |
| -f"/projects/{self.encoded_id}/jobs/artifacts/{ref_name}/raw/" |
636 |
| -f"{artifact_path}?job={job}" |
637 |
| - ) |
638 |
| -result=self.manager.gitlab.http_get( |
639 |
| -path,streamed=streamed,raw=True,**kwargs |
| 565 | +warnings.warn( |
| 566 | +"The project.artifact() method is deprecated and will be " |
| 567 | +"removed in a future version. Use project.artifacts.raw() instead.", |
| 568 | +DeprecationWarning, |
640 | 569 | )
|
641 |
| -ifTYPE_CHECKING: |
642 |
| -assertisinstance(result,requests.Response) |
643 |
| -returnutils.response_content(result,streamed,action,chunk_size) |
| 570 | +returnself.artifacts.raw(*args,**kwargs) |
644 | 571 |
|
645 | 572 |
|
646 | 573 | classProjectManager(CRUDMixin,RESTManager):
|
|