a Æ*NaÖã@stddlmZddlmZddlmZddlmZmZddlm Z m Z ddgZ Gdd„de eƒZ Gd d„de eƒZ d S) é)Úcli)Ú exceptions)Úutils)Ú RESTManagerÚ RESTObject)Ú RefreshMixinÚ RetrieveMixinÚ ProjectJobÚProjectJobManagerc@s eZdZe d¡e ej¡dd„ƒƒZe d¡e ej ¡dd„ƒƒZ e d¡e ej ¡dd„ƒƒZ e d¡e ej ¡dd„ƒƒZe d¡e ej¡d d „ƒƒZe d¡e ej¡d d „ƒƒZe d¡e ej¡ddd„ƒƒZe d¡e ej¡ddd„ƒƒZe d¡e ej¡ddd„ƒƒZdS)r cKs"d|jj| ¡f}|jj |¡S)a Cancel the job. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobCancelError: If the job could not be canceled z %s/%s/cancel©ÚmanagerÚpathÚget_idÚgitlabZ http_post©ÚselfÚkwargsr ©rúq/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/gitlab/v4/objects/jobs.pyÚcancels zProjectJob.cancelcKs"d|jj| ¡f}|jj |¡S)aRetry the job. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobRetryError: If the job could not be retried z %s/%s/retryr rrrrÚretrys zProjectJob.retrycKs&d|jj| ¡f}|jj |¡dS)aTrigger a job explicitly. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobPlayError: If the job could not be triggered z %s/%s/playNr rrrrÚplay,s zProjectJob.playcKs&d|jj| ¡f}|jj |¡dS)a&Erase the job (remove job artifacts and trace). Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobEraseError: If the job could not be erased z %s/%s/eraseNr rrrrÚerase;s zProjectJob.erasecKs&d|jj| ¡f}|jj |¡dS)a8Prevent artifacts from being deleted when expiration is set. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the request could not be performed z%s/%s/artifacts/keepNr rrrrÚkeep_artifactsJs zProjectJob.keep_artifactscKs&d|jj| ¡f}|jj |¡dS)aDelete artifacts of a job. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the request could not be performed ú%s/%s/artifactsN)r r rrZ http_deleterrrrÚdelete_artifactsYs zProjectJob.delete_artifactsFNécKs@d|jj| ¡f}|jjj|f|ddœ|¤Ž}t ||||¡S)aªGet the job artifacts. Args: streamed (bool): If True the data will be processed by chunks of `chunk_size` and each chunk is passed to `action` for treatment action (callable): Callable responsible of dealing with chunk of data chunk_size (int): Size of each chunk **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the artifacts could not be retrieved Returns: str: The artifacts if `streamed` is False, None otherwise. rT©ÚstreamedÚraw©r r rrZhttp_getrZresponse_content©rrÚactionÚ chunk_sizerr ÚresultrrrÚ artifactshsÿÿÿzProjectJob.artifactscKsBd|jj| ¡|f}|jjj|f|ddœ|¤Ž}t ||||¡S)aGet a single artifact file from within the job's artifacts archive. Args: path (str): Path of the artifact streamed (bool): If True the data will be processed by chunks of `chunk_size` and each chunk is passed to `action` for treatment action (callable): Callable responsible of dealing with chunk of data chunk_size (int): Size of each chunk **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the artifacts could not be retrieved Returns: str: The artifacts if `streamed` is False, None otherwise. z%s/%s/artifacts/%sTrr )rr rr"r#rr$rrrÚartifactƒsÿÿÿzProjectJob.artifactcKs@d|jj| ¡f}|jjj|f|ddœ|¤Ž}t ||||¡S)azGet the job trace. Args: streamed (bool): If True the data will be processed by chunks of `chunk_size` and each chunk is passed to `action` for treatment action (callable): Callable responsible of dealing with chunk of data chunk_size (int): Size of each chunk **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the artifacts could not be retrieved Returns: str: The trace z %s/%s/traceTrr r!rrrÚtraceŸsÿÿÿzProjectJob.trace)FNr)FNr)FNr)Ú__name__Ú __module__Ú __qualname__rZregister_custom_actionÚexcZ on_http_errorZGitlabJobCancelErrorrZGitlabJobRetryErrorrZGitlabJobPlayErrorrZGitlabJobEraseErrorrZGitlabCreateErrorrrZGitlabGetErrorr%r&r'rrrrr s6               c@seZdZdZeZddiZdS)r z/projects/%(project_id)s/jobsZ project_idÚidN)r(r)r*Ú_pathr Z_obj_clsZ_from_parent_attrsrrrrr »sN)rrrr+rZ gitlab.baserrZ gitlab.mixinsrrÚ__all__r r rrrrÚs   þ/