Add project_id response field to reports.create endpoint

This commit is contained in:
allegroai 2022-12-21 18:35:14 +02:00
parent 54ce6c34c6
commit 18570bfccb
2 changed files with 8 additions and 3 deletions

View File

@ -139,6 +139,10 @@ create {
description: "ID of the report" description: "ID of the report"
type: string type: string
} }
project_id {
description: "ID of the project that the report belongs to"
type: string
}
} }
} }
} }

View File

@ -14,7 +14,7 @@ from apiserver.apimodels.reports import (
GetAllRequest, GetAllRequest,
) )
from apiserver.apierrors import errors from apiserver.apierrors import errors
from apiserver.apimodels.base import IdResponse, UpdateResponse from apiserver.apimodels.base import UpdateResponse
from apiserver.services.utils import process_include_subprojects, sort_tags_response from apiserver.services.utils import process_include_subprojects, sort_tags_response
from apiserver.bll.organization import OrgBLL from apiserver.bll.organization import OrgBLL
from apiserver.bll.project import ProjectBLL from apiserver.bll.project import ProjectBLL
@ -119,7 +119,7 @@ def _ensure_reports_project(company: str, user: str, name: str):
) )
@endpoint("reports.create", response_data_model=IdResponse) @endpoint("reports.create")
def create_report(call: APICall, company_id: str, request: CreateReportRequest): def create_report(call: APICall, company_id: str, request: CreateReportRequest):
user_id = call.identity.user user_id = call.identity.user
project_id = request.project project_id = request.project
@ -147,7 +147,8 @@ def create_report(call: APICall, company_id: str, request: CreateReportRequest):
), ),
) )
task.save() task.save()
return IdResponse(id=task.id)
call.result.data = {"id": task.id, "project_id": project_id}
def _delete_reports_project_if_empty(project_id): def _delete_reports_project_if_empty(project_id):