SDK methods that list child objects don't always work when the parent object is in an organization

Actions before raising this issue

  • I searched the existing issues and did not find anything similar.
  • I read/searched the docs

Steps to Reproduce

  1. Create two accounts, user1 and user2.

  2. Create an organization as user1, and add user2 as a maintainer.

  3. Create a project in the organization as user1.

  4. Create a task in the project as user1.

  5. Create the following script:

    import os
    import sys
    
    from cvat_sdk import make_client
    
    def main():
        proj_id = int(sys.argv[1])
    
        with make_client(
            host="http://localhost:8080",
            credentials=(os.environ["CVAT_AI_USER"], os.environ["CVAT_AI_PASS"])
        ) as client:
            project = client.projects.retrieve(proj_id)
    
            for task in project.get_tasks():
                print(task.id)
    
    main()
  6. Run the script with user2's credentials, passing the ID of the project. It prints nothing.

Expected Behavior

The script should print the ID of the task.

By comparison, if you run the script with user1's credentials, this does happen.

Possible Solution

We should probably make the SDK override the current organization while making the "list tasks" request, if the project is in an organization.

Alternatively, we could alter the server's response to list all tasks that the user has access to, regardless of what organization they are in.

Context

I believe this affects all SDK methods that list child objects of some other objects, although I haven't tested them all. These methods are:

Issue.get_comments
Job.get_labels
Job.get_issues
Project.get_tasks
Project.get_labels
Task.get_jobs
Task.get_labels

Environment

Reproducible with commit b594b1cb.