a *Na@sTddlmZmZmZmZmZmZmZmZddl Z ddl m Z m Z ddl m Zddl mZmZddlmZmZmZddlmZmZmZmZmZmZmZdd lmZdd lm Z dd l!m"Z"dd l#m$Z$dd l%m&Z&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;mZ>ddl?m@Z@ddlAmBZBddlCmDZDddlEmFZFddlGmHZHmIZIddlJmKZKmLZLddlMmNZNdd lOmPZPdd!lQmRZRdd"lSmTZTdd#lUmVZVmWZWdd$lXmYZYdd%lZm[Z[m\Z\m]Z]dd&l^m_Z_dd'l`maZadd(lbmcZcdd)ldmeZedd*lfmgZgdd+lhmiZidd,ljmkZkdd-llmmZmmnZndd.lompZpmqZqdd/lrmsZsdd0ltmuZudd1lvmwZwdd2lxmyZygd3ZzGd4d5d5eZ{Gd6d7d7eeZ|Gd8d9d9eeeeeeZ}Gd:d;d;eeZ~Gdd?d?eeeZGd@dAdAeeZGdBdCdCeeeeZdS)D)AnyCallablecastDictListOptional TYPE_CHECKINGUnionN)cliclient) exceptions)typesutils)RequiredOptional RESTManager RESTObject) CreateMixin CRUDMixin ListMixinObjectDeleteMixin RefreshMixin SaveMixin UpdateMixin)ProjectAccessRequestManager)ProjectAuditEventManager)ProjectBadgeManager)ProjectBoardManager)ProjectBranchManagerProjectProtectedBranchManager)ProjectClusterManager)ProjectCommitManager) ProjectRegistryRepositoryManager)ProjectCustomAttributeManager)ProjectKeyManager)ProjectDeployTokenManager)ProjectDeploymentManager)ProjectEnvironmentManager)ProjectEventManager)ProjectExportManagerProjectImportManager)ProjectFileManager)ProjectHookManager)ProjectIssueManager)ProjectJobManager)ProjectLabelManager)ProjectMemberAllManagerProjectMemberManager)ProjectApprovalManagerProjectApprovalRuleManager)ProjectMergeRequestManager)ProjectMilestoneManager)ProjectNoteManager)"ProjectNotificationSettingsManager)GenericPackageManagerProjectPackageManager)ProjectPagesDomainManager)ProjectPipelineProjectPipelineManagerProjectPipelineScheduleManager)ProjectAccessTokenManager)ProjectPushRulesManager)ProjectReleaseManager)RepositoryMixin)ProjectRunnerManager)ProjectServiceManager)ProjectSnippetManager)"ProjectAdditionalStatisticsManagerProjectIssuesStatisticsManager)ProjectProtectedTagManagerProjectTagManager)ProjectTriggerManager)ProjectUserManager)ProjectVariableManager)ProjectWikiManager) GroupProjectGroupProjectManagerProjectProjectManager ProjectForkProjectForkManagerProjectRemoteMirrorProjectRemoteMirrorManagerc@s eZdZdS)rMN__name__ __module__ __qualname__rYrYu/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/gitlab/v4/objects/projects.pyrMTsrMc@s eZdZdZeZddiZdZdS)rNz/groups/%(group_id)s/projectsgroup_idid)archived visibilityorder_bysortsearchsimpleownedstarredwith_custom_attributesZinclude_subgroupswith_issues_enabledwith_merge_requests_enabledZ with_sharedmin_access_levelZwith_security_reportsN)rVrWrX_pathrM_obj_cls_from_parent_attrs _list_filtersrYrYrYrZrNXsrNc @seZdZdZdZeddeej e e ddddZ edeej e ddd d Zedeeje eeee fejfdd d Zedeej e ddd dZedeej e ddddZedeej e ddddZedeej e ddddZedddeej dBe e eee ddddZeddeej e e ddddZeddeej dCeeeeee fe edd d!Zedeeje ddd"d#Z edd$eej!dDeee"eee eee fd%d&d'Z#ejdd(d)eejdEe$e$ee%e e ee"d,d-d.Z&edd/eej'eee ee(j)e*eee ffd0d1d2Z+edeej e ddd3d4Z,edd5eej-ee dd6d7d8Z.edd9d:eejdFeee$ee%e e ee"d;deejdGeeee$ee%e e ee"d?d@dAZ0dS)HrOpath)4)Z access_tokensr>)Zaccessrequestsr)Z approvalsr2)Z approvalrulesr3)badgesr)boardsr)branchesr)jobsr.)commitsr!)Zcustomattributesr#) deploymentsr&) environmentsr')eventsr() audit_eventsr)exportsr))filesr+)ZforksrR)Zgeneric_packagesr8)hooksr,)keysr$)Zimportsr*)issuesr-)labelsr/)membersr1)Z members_allr0)Z mergerequestsr4) milestonesr5)notesr6)Znotificationsettingsr7)packagesr9)Z pagesdomainsr:) pipelinesr<)Zprotectedbranchesr)Z protectedtagsrG)Zpipelineschedulesr=)Z pushrulesr?)releasesr@)Zremote_mirrorsrT) repositoriesr")runnersrB)servicesrC)snippetsrD)tagsrH)usersrJ)triggersrI) variablesrK)wikisrL)clustersr )ZadditionalstatisticsrE)Zissues_statisticsrF)ZissuesstatisticsrF)Z deploytokensr%)forked_from_idN)rkwargsreturncKs*d||f}|jjj|fi|dS)aCreate a forked from/to relation between existing projects. Args: forked_from_id (int): The ID of the project that was forked from **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the relation could not be created z/projects/%s/fork/%sNget_idmanagergitlab http_post)selfrrrmrYrYrZcreate_fork_relations zProject.create_fork_relation)rrcKs&d|}|jjj|fi|dS)a5Delete a forked relation between existing projects. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server failed to perform the request z/projects/%s/forkNrrrZ http_deleterrrmrYrYrZdelete_fork_relations zProject.delete_fork_relationcKs"d|}|jjj|fi|S)a7Get languages used in the project with percentage value. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the server failed to perform the request z/projects/%s/languages)rrrhttp_getrrYrYrZ languagess zProject.languagescKsBd|}|jjj|fi|}tr4t|ts4J||dS)aStar a project. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server failed to perform the request z/projects/%s/starNrrrrr isinstancedict _update_attrsrrrmZ server_datarYrYrZstars z Project.starcKsBd|}|jjj|fi|}tr4t|ts4J||dS)aUnstar a project. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server failed to perform the request z/projects/%s/unstarNrrrYrYrZunstars zProject.unstarcKsBd|}|jjj|fi|}tr4t|ts4J||dS)aArchive a project. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server failed to perform the request z/projects/%s/archiveNrrrYrYrZarchives zProject.archivecKsBd|}|jjj|fi|}tr4t|ts4J||dS)aUnarchive a project. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server failed to perform the request z/projects/%s/unarchiveNrrrYrYrZ unarchive s zProject.unarchive)r[ group_access) expires_at)r[rrrrcKs6d|}|||d}|jjj|fd|i|dS)aShare the project with a group. Args: group_id (int): ID of the group. group_access (int): Access level for the group. **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server failed to perform the request z/projects/%s/share)r[rr post_dataNr)rr[rrrrmdatarYrYrZshares  z Project.share)r[)r[rrcKs*d||f}|jjj|fi|dS)a[Delete a shared project link within a group. Args: group_id (int): ID of the group. **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the server failed to perform the request z/projects/%s/share/%sNr)rr[rrmrYrYrZunshare<s zProject.unshare)reftoken)rrrrrcKsX|pi}d|}|||d}|jjj|fd|i|}trLt|tsLJt|j|S)aTrigger a CI build. See https://gitlab.com/help/ci/triggers/README.md#trigger-a-build Args: ref (str): Commit to build; can be a branch name or a tag token (str): The trigger token variables (dict): Variables passed to the build script **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server failed to perform the request z/projects/%s/trigger/pipeline)rrrr) rrrrrrrr;r)rrrrrrmrattrsrYrYrZtrigger_pipelineMs  zProject.trigger_pipelinecKs&d|}|jjj|fi|dS)aIStart the housekeeping task. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabHousekeepingError: If the server failed to perform the request z/projects/%s/housekeepingNrrrYrYrZ housekeepingls zProject.housekeeping)filenamefilepath)rfiledatarrrc Ks|dur|durtd|dur4|dur4td|durnt|d}|}Wdn1sd0Ydd|ji}d||fi}|jjj||d}trt |t sJ|d |d |d d S) aUpload the specified file into the project. .. note:: Either ``filedata`` or ``filepath`` *MUST* be specified. Args: filename (str): The name of the file being uploaded filedata (bytes): The raw data of the file being uploaded filepath (str): The path to a local file to upload (optional) Raises: GitlabConnectionError: If the server cannot be reached GitlabUploadError: If the file upload fails GitlabUploadError: If ``filedata`` and ``filepath`` are not specified GitlabUploadError: If both ``filedata`` and ``filepath`` are specified Returns: dict: A ``dict`` with the keys: * ``alt`` - The alternate text for the upload * ``url`` - The direct url to the uploaded file * ``markdown`` - Markdown for the uploaded file Nz"No file contents or path specifiedz%File contents and file path specifiedrbz/projects/%(id)s/uploadsr\file)rxalturlmarkdown)rrr) excGitlabUploadErroropenreadr\rrrrrr) rrrrrfr file_inforrYrYrZupload}s"   & zProject.upload)wikioptionalF)rstreamedaction chunk_sizerrcKsLd|}|jjj|f|dd|}trrrrrrrrrrrrrrZci_default_git_depthZci_forward_deployment_enabledrrrrrrrrrrrrrrrZ#mirror_overwrites_diverged_branchesrZmirror_user_idrrrrrZonly_mirror_protected_branchesrrrZrestrict_user_defined_variablesrmrrrrrrZservice_desk_enabledrrr r Zsuggestion_commit_messager r^r r Zissues_templateZmerge_requests_template)r]Zid_afterZ id_beforeZlast_activity_afterZlast_activity_before membershiprhr_rcZrepository_checksum_failedrZsearch_namespacesrarbr`rd statisticstopicr^Zwiki_checksum_failedrerfrgZwith_programming_language)rrF)r\lazyrrc stttjf||d|S)N)r\r)rrOsuperget)rr\rr __class__rYrZr szProjectManager.getN)rrmrr overwriteoverride_paramsrrc Ksrdd|dfi}|t|d} |r>|D]\} } | | d| <q(|durN|| d<|rZ|| d<|jjd | |d |S) aImport a project from an archive file. Args: file: Data or file object containing the project path (str): Name and path for the new project namespace (str): The ID or path of the namespace that the project will be imported to overwrite (bool): If True overwrite an existing project with the same path override_params (dict): Set the specific settings for the project **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabListError: If the server failed to perform the request Returns: dict: A representation of the import status. rz file.tar.gzzapplication/octet-stream)rmrzoverride_params[%s]Nrr/projects/import)rrx)r)ritemsrr) rrrmrrrrrrxrkvrYrYrZimport_projects zProjectManager.import_project) bitbucket_server_urlbitbucket_server_usernamepersonal_access_tokenbitbucket_server_projectbitbucket_server_reponew_nametarget_namespacerrc Ksj|||||d} |r|| d<|r(|| d<d|vsH|jjdusH|jjdkrPd|d<|jjd d| i|} | S) a^ Import a project from BitBucket Server to Gitlab (schedule the import) This method will return when an import operation has been safely queued, or an error has occurred. After triggering an import, check the ``import_status`` of the newly created project to detect when the import operation has completed. .. note:: This request may take longer than most other API requests. So this method will specify a 60 second default timeout if none is specified. A timeout can be specified via kwargs to override this functionality. Args: bitbucket_server_url (str): Bitbucket Server URL bitbucket_server_username (str): Bitbucket Server Username personal_access_token (str): Bitbucket Server personal access token/password bitbucket_server_project (str): Bitbucket Project Key bitbucket_server_repo (str): Bitbucket Repository Name new_name (str): New repository name (Optional) target_namespace (str): Namespace to import repository into. Supports subgroups like /namespace/subgroup (Optional) **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabListError: If the server failed to perform the request Returns: dict: A representation of the import status. Example: .. code-block:: python gl = gitlab.Gitlab_from_config() print("Triggering import") result = gl.projects.import_bitbucket_server( bitbucket_server_url="https://some.server.url", bitbucket_server_username="some_bitbucket_user", personal_access_token="my_password_or_access_token", bitbucket_server_project="my_project", bitbucket_server_repo="my_repo", new_name="gl_project_name", target_namespace="gl_project_path" ) project = gl.projects.get(ret['id']) print("Waiting for import to complete") while project.import_status == u'started': time.sleep(1.0) project = gl.projects.get(project.id) print("BitBucket import complete") )rrrr r!r"r#timeoutNN@/import/bitbucket_serverr)r&rr$r) rrrrr r!r"r#rrrrYrYrZimport_bitbucket_server:s2B   z&ProjectManager.import_bitbucket_server)rrepo_idr#r"rrcKsZ|||d}|r||d<d|vs8|jjdus8|jjdkr@d|d<|jjdd|i|}|S) aImport a project from Github to Gitlab (schedule the import) This method will return when an import operation has been safely queued, or an error has occurred. After triggering an import, check the ``import_status`` of the newly created project to detect when the import operation has completed. .. note:: This request may take longer than most other API requests. So this method will specify a 60 second default timeout if none is specified. A timeout can be specified via kwargs to override this functionality. Args: personal_access_token (str): GitHub personal access token repo_id (int): Github repository ID target_namespace (str): Namespace to import repo into new_name (str): New repo name (Optional) **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabListError: If the server failed to perform the request Returns: dict: A representation of the import status. Example: .. code-block:: python gl = gitlab.Gitlab_from_config() print("Triggering import") result = gl.projects.import_github(ACCESS_TOKEN, 123456, "my-group/my-subgroup") project = gl.projects.get(ret['id']) print("Waiting for import to complete") while project.import_status == u'started': time.sleep(1.0) project = gl.projects.get(project.id) print("Github import complete") )rr)r#r"r$Nr%/import/githubr)r*r')rrr)r#r"rrrrYrYrZ import_githubs4   zProjectManager.import_github)F)NNFN)NN)N)rVrWrXrirOrjr _create_attrsrrlr ZImageAttributeZ ListAttribute_typesr rrrrrrrrrrr(r+ __classcell__rYrYrrZrPis^AB" 1 `rPc@s eZdZdS)rQNrUrYrYrYrZrQsrQc@sJeZdZdZeZddiZdZeddZ d e e e e fe edd d ZdS) rRz/projects/%(project_id)s/forks project_idr\) r]r^r_r`rarbrcrrdrrerfrg)rrN)rrrcKs>tr|jdusJ|jdd}tttj||fd|i|S)a Creates a new object. Args: data (dict): Parameters to send to the server to create the resource **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server cannot perform the request Returns: RESTObject: A new instance of the managed object class build with the data sent by the server Nrm)rrmrrQrcreate)rrrrmrYrYrZr1szProjectForkManager.create)N)rVrWrXrirQrjrkrlrr,rrrrr1rYrYrYrZrRs rRc@s eZdZdS)rSNrUrYrYrYrZrSsrSc@s2eZdZdZeZddiZedddZeddZ dS) rTz'/projects/%(project_id)s/remote_mirrorsr/r\)r)ZenabledZonly_protected_branches)requiredrrN) rVrWrXrirSrjrkrr,rrYrYrYrZrTsrT)typingrrrrrrrr rrr r r rr rZ gitlab.baserrrZ gitlab.mixinsrrrrrrrZaccess_requestsrrvrrnrrorrprrrr rrr!Zcontainer_registryr"Zcustom_attributesr#Z deploy_keysr$Z deploy_tokensr%rsr&rtr'rur(Z export_importr)r*rxr+ryr,r{r-rqr.r|r/r}r0r1Zmerge_request_approvalsr2r3Zmerge_requestsr4r~r5rr6Znotification_settingsr7rr8r9Zpagesr:rr;r<r=Zproject_access_tokensr>Z push_rulesr?rr@rrArrBrrCrrDrrErFrrGrHrrIrrJrrKrrL__all__rMrNrOrPrQrRrSrTrYrYrYrZs|( $                                   }v-