File: bulk_imports.rst

package info (click to toggle)
python-gitlab 1%3A8.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,884 kB
  • sloc: python: 25,823; makefile: 171; ruby: 27; javascript: 3
file content (82 lines) | stat: -rw-r--r-- 2,170 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#########################
Migrations (Bulk Imports)
#########################

References
----------

* v4 API:

  + :class:`gitlab.v4.objects.BulkImport`
  + :class:`gitlab.v4.objects.BulkImportManager`
  + :attr:`gitlab.Gitlab.bulk_imports`
  + :class:`gitlab.v4.objects.BulkImportAllEntity`
  + :class:`gitlab.v4.objects.BulkImportAllEntityManager`
  + :attr:`gitlab.Gitlab.bulk_import_entities`
  + :class:`gitlab.v4.objects.BulkImportEntity`
  + :class:`gitlab.v4.objects.BulkImportEntityManager`
  + :attr:`gitlab.v4.objects.BulkImport.entities`

* GitLab API: https://docs.gitlab.com/api/bulk_imports

Examples
--------

.. note::

    Like the project/group imports and exports, this is an asynchronous operation and you
    will need to refresh the state from the server to get an accurate migration status. See
    :ref:`project_import_export` in the import/export section for more details and examples.

Start a bulk import/migration of a group and wait for completion::

    # Create the migration
    configuration = {
        "url": "https://gitlab.example.com",
        "access_token": private_token,
    }
    entity = {
        "source_full_path": "source_group",
        "source_type": "group_entity",
        "destination_slug": "imported-group",
        "destination_namespace": "imported-namespace",
    }
    migration = gl.bulk_imports.create(
        {
            "configuration": configuration,
            "entities": [entity],
        }
    )

    # Wait for the 'finished' status
    while migration.status != "finished":
        time.sleep(1)
        migration.refresh()

List all migrations::

    gl.bulk_imports.list(get_all=True)

List the entities of all migrations::

    gl.bulk_import_entities.list(get_all=True)

Get a single migration by ID::

    migration = gl.bulk_imports.get(123)

List the entities of a single migration::

    entities = migration.entities.list(get_all=True)

Get a single entity of a migration by ID::

    entity = migration.entities.get(123)

Refresh the state of a migration or entity from the server::

    migration.refresh()
    entity.refresh()

    print(migration.status)
    print(entity.status)