Skip to content

Public api: Create link has 'data' argument#308

Open
iLLiCiTiT wants to merge 1 commit intodevelopfrom
bugfix/create-link-public-api
Open

Public api: Create link has 'data' argument#308
iLLiCiTiT wants to merge 1 commit intodevelopfrom
bugfix/create-link-public-api

Conversation

@iLLiCiTiT
Copy link
Member

Changelog Description

Public api function create_link does have data argument now.

Additional review information

Without this PR it is not possible to pass data to public function create_link instead developer has to get the connection object and call it on that.

Testing notes:

  1. It is possible to pass data to public create_link function.

@iLLiCiTiT iLLiCiTiT added the type: bug Something isn't working label Feb 25, 2026
@iLLiCiTiT iLLiCiTiT self-assigned this Feb 25, 2026
@iLLiCiTiT iLLiCiTiT requested a review from BigRoy February 25, 2026 15:59
Copy link
Contributor

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get the data returned from the link:

import ayon_api
import os

os.environ["AYON_SERVER_URL"] = "http://localhost:5000"
os.environ["AYON_API_KEY"] = "54f2c159eedc4b5fa10447571161e978"

project_name = "test"
folder_a = ayon_api.get_folder_by_path("test", "/apps/blender")
folder_b = ayon_api.get_folder_by_path("test", "/apps/maya")
link_type_name = "breakdown"

ayon_api.create_link(
    project_name=project_name,
    link_type_name=link_type_name,
    input_id=folder_a["id"],
    input_type="folder",
    output_id=folder_b["id"],
    output_type="folder",
    link_name="MyLink",
    data={"foo": "bar", "hello": "world"},
)

print(ayon_api.get_folder_links(
    project_name,
    folder_b["id"],
    link_types=[link_type_name])
)
# This fails to work.
[{'direction': 'in', 'linkType': 'breakdown', 'name': 'MyLink', 'description': 'breakdown link with input folder and output folder', 'entityType': 'folder', 'author': 'deadline', 'projectName': 'test', 'id': '64df3768129911f19082ee69ed383011', 'entityId': '0867b2404af211f0985a3b9388bc26af'}, {'direction': 'in', 'linkType': 'breakdown', 'name': 'MyLink', 'description': 'breakdown link with input folder and output folder', 'entityType': 'folder', 'author': 'deadline', 'projectName': 'test', 'id': 'ab7d5fec129911f19082ee69ed383011', 'entityId': '0867b2404af211f0985a3b9388bc26af'}, {'direction': 'in', 'linkType': 'breakdown', 'name': 'MyLink', 'description': 'breakdown link with input folder and output folder', 'entityType': 'folder', 'author': 'deadline', 'projectName': 'test', 'id': 'b2508236129911f19082ee69ed383011', 'entityId': '0867b2404af211f0985a3b9388bc26af'}, {'direction': 'in', 'linkType': 'breakdown', 'name': 'MyLink', 'description': 'breakdown link with input folder and output folder', 'entityType': 'folder', 'author': 'deadline', 'projectName': 'test', 'id': 'd5131b80129911f19082ee69ed383011', 'entityId': '0867b2404af211f0985a3b9388bc26af'}, {'direction': 'in', 'linkType': 'breakdown', 'name': 'MyLink', 'description': 'breakdown link with input folder and output folder', 'entityType': 'folder', 'author': 'deadline', 'projectName': 'test', 'id': 'dcfa442c129911f19082ee69ed383011', 'entityId': '0867b2404af211f0985a3b9388bc26af'}]

@iLLiCiTiT
Copy link
Member Author

iLLiCiTiT commented Feb 26, 2026

I don't get the data returned from the link:

Not related to this PR. Without this PR you could not call the ayon_api.create_link(...) with data kwarg in it.

@BigRoy
Copy link
Contributor

BigRoy commented Feb 26, 2026

Not related to this PR. Without this PR you could not call the ayon_api.create_link(...) with data kwarg in it.

I understand - but adding the data kwarg... does nothing? Or at least, I can't seem to confirm the data ends up in the result so my assumption now is that it's not writing the data to begin with?

I also can't seem to get the link data via GraphQL @martastain (not exposed?)?

Anyway, without the data being present I can't confirm this PR does what it should?

Copy link
Contributor

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR works.

You can check the data via GraphQL with ynput/ayon-backend#867

Otherwise via the manage.ps1 dbshell and doing something like:

SELECT * FROM project_{projectname}.links WHERE data != '{}';

Resulting in:

ayon=# SELECT * FROM project_test.links WHERE data != '{}';
                  id                  |  name  |        link_type        |               input_id               |              output_id               |  author  |               data               |          created_at           | creation_order
--------------------------------------+--------+-------------------------+--------------------------------------+--------------------------------------+----------+----------------------------------+-------------------------------+----------------
 64df3768-1299-11f1-9082-ee69ed383011 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar"}                   | 2026-02-25 22:29:05.684429+00 |            532
 ab7d5fec-1299-11f1-9082-ee69ed383011 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar"}                   | 2026-02-25 22:31:04.161401+00 |            533
 b2508236-1299-11f1-9082-ee69ed383011 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar"}                   | 2026-02-25 22:31:15.611413+00 |            534
 d5131b80-1299-11f1-9082-ee69ed383011 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar"}                   | 2026-02-25 22:32:13.929273+00 |            535
 dcfa442c-1299-11f1-9082-ee69ed383011 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar", "hello": "world"} | 2026-02-25 22:32:27.188238+00 |            536
 664dc2b8-1348-11f1-8055-7ae238a541a5 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar", "hello": "world"} | 2026-02-26 19:21:50.014271+00 |            540
 24c9a63a-1349-11f1-8055-7ae238a541a5 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar", "hello": "world"} | 2026-02-26 19:27:09.593337+00 |            541
 f6bdffec-1358-11f1-8adc-3298230c2905 | MyLink | breakdown|folder|folder | 0867b240-4af2-11f0-985a-3b9388bc26af | 6844a8a0-2737-11f0-8312-29f47de0c09d | deadline | {"foo": "bar", "hello": "world"} | 2026-02-26 21:20:24.289475+00 |            543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants