diff --git a/docs/pagure2gitlab/gitlab.rst b/docs/pagure2gitlab/gitlab.rst index e82de02..7743764 100644 --- a/docs/pagure2gitlab/gitlab.rst +++ b/docs/pagure2gitlab/gitlab.rst @@ -2,3 +2,83 @@ GitLab API investigation ======================== + +This document investigates API calls that are needed to address the requirements for Pagure to GitLab +importer. Currently the GitLab provides both `REST `_ +and `GraphQL `_ APIs. In this investigation I will only +focus on REST API v4, because GraphQL API doesn't provide required calls +(importing project and importing merge requests). + +All the REST API calls need user to provide +`GitLab API token `_. + +For the purpose of this investigation I tried to import `ARC repository +`_ to GitLab. + +GitLab API documentation: https://docs.gitlab.com/ee/api/ + + +Importing a git repository +-------------------------- + +Project can be imported by using `create project call +`_. Following is a payload for import +of the ARC repository. + +.. code-block:: json + + { + "name":"arc", + "description":"The Advance Reconnaissance Crew", + "namespace_id":"10910066", + "import_url":"https://pagure.io/fedora-infra/arc.git" + } + +This creates `ARC repository on GitLab `_ with the whole +commit history and users mapped by the e-mail. + + +Importing ticket +---------------- + +Ticket can be imported by `creating an issue `_ +, `commenting on it `_, +eventually close it by `editing the issue +`_ and add any attachments by +`uploading file to project `_. + +I tested this on `ARC project ticket `_. + +1. Payload for creating an issue + + .. code-block:: json + + { + "created_at": "2023-01-19T11:41:40Z", + "title": "Investigate the GitLab API for Pagure to Gitlab importer", + "description": "Investigate the GitLab API for Pagure to Gitlab importer ARC investigation. This ticket will also work as a test ticket in investigation." + } + + This creates the `issue on GitLab `_. + +2. Payload for adding a comment + + .. code-block:: json + + { + "created_at": "2023-01-19T12:59:59Z", + "body": "Here's a sample comment as you requested @zlopez." + } + + This creates `comment `_ on + the previously created issue. In this case the comment was created by user, who executed the + API call and according to API documentation it's not possible to change it. + + +Conclusion +---------- + +Using the REST API v4 is not useful for our purpose, because it will set author of every pull +request, issue and comment to user running the migration tool. This means that we will lose +most of the information we want to preserve. Thus it doesn't make sense to continue in the +investigation.