nephila / python-taiga

:evergreen_tree: Python module for communicating with the Taiga API
https://python-taiga.readthedocs.io
MIT License
94 stars 41 forks source link

Add support for swimlanes #162

Closed psybers closed 6 months ago

psybers commented 6 months ago

Description

Currently, the API has the ability to read data about swimlanes:

    swimlanes = project.swimlanes
    print(swimlanes)
    # [
    #    {'id': 1234, 'name': 'Swimlane 1', 'order': 0, 'project_id': 1234},
    #    {'id': 1235, 'name': 'Swimlane 2', 'order': 1, 'project_id': 1234}
    #    {'id': 1236, 'name': 'Swimlane 3', 'order': 2, 'project_id': 1234}
    # ]

But the objects returned have no models. There also isn't, as far as I can find, a way to create or modify swimlanes.

Use cases

In general, it can be nice to add new swimlanes programmatically or to update existing ones. Changing their order might be especially useful.

My specific use case is because (apparently) duplicating a project does not duplicate its swimlanes. So I need a way to programmatically create a bunch of swimlanes for new projects.

Proposed solution

Adding Swimlane and Swimlanes models, similar to the other models, and similar functions for creating/editing them.

Projects would return these instances instead of the raw objects you get currently when you access project.swimlanes.

You could also get a Swimlane object back from a UserStory when calling us.swimlane on it.

Additional information

To be honest, the REST API documentation does not mention swimlanes anywhere. So it might not be supported on their end.

psybers commented 6 months ago

Ok they definitely implement it via the REST API, it just is not documented. But I can see calls going to things like https://api.taiga.io/api/v1/swimlanes.

psybers commented 6 months ago

Creating a swimlane sends this payload to that URL: {project: 1234, name: "test"}

Getting the swimlanes for a project: GET https://api.taiga.io/api/v1/swimlanes?project=1234

Editing: PATCH https://api.taiga.io/api/v1/swimlanes/12345 with a payload of the new name {name: "test"}

Deleting: DELETE https://api.taiga.io/api/v1/swimlanes/12346?moveTo=12345. This one seems to pass an argument of another swimlane ID that the stories in the deleted lane should move to. Not sure what happens if you omit that.

Reordering: POST https://api.taiga.io/api/v1/swimlanes/bulk_update_order with a payload {project: 1234, bulk_swimlanes: [[12347, 0], [12346, 1], [12345, 2], [12348, 3], [912345, 4]]}

psybers commented 6 months ago

I started working on this. Haven't had time to read contributing docs or write tests, but seems to work.

https://github.com/psybers/python-taiga/commit/416d35b382dfc3026bad371cb1c854f9388afb08

If I get time I might polish it up and PR. Feel free to use that code if you want to add it yourselves.