[docs]@api_version(database_version)@router.post("/projects/{project_uuid}/objectives",response_model=ObjectiveResponse,summary="Create a new objective by its project UUID",)defcreate(project_uuid:str,objective_data:ObjectiveCreate,service:ObjectiveService=Depends(get_service),)->ObjectiveResponse:"""Method to create a new objective connected to a project vertex Creates vertex with the label "objective" and the properties of objective_data Creates an edge between the project vertex specified by project_uuid and the newly create objective vertex Args: project_uuid (str): id of the project vertex the new objective will be connected to objective_data (ObjectiveCreate): contains all properties for the objective Returns: ObjectiveResponse: Created Objective with the objective_data as ObjectiveData """returnservice.create(project_uuid=project_uuid,objective_data=objective_data)
[docs]@api_version(database_version)@router.get("/projects/{project_uuid}/objectives",response_model=list[ObjectiveResponse],summary="Get all objectives by their project UUID",)defread_objectives_all(project_uuid:str,filter_model:Filter=Depends(),service:ObjectiveService=Depends(get_service),)->list[ObjectiveResponse]:"""Read all objectives connected to one project with filter possibilities Args: project_uuid (str): id of the project vertex vertex_label (str): label of the vertices of interest edge_label (str): edge_label to clarify the connection between the project node and objective node, should always be "contains" in this method (default "contains") filter_model (Filter (BaseModel)) contains a dict with different properties for filtering, like hierarchy, tag, and description Returns List[ObjectiveResponse]: List of Objectives which satisfy the condition to be connected to the Project vertex with a "contains" edge and have the label "objective" and satisfy the filters when the filter_model is given """returnservice.read_objectives_all(project_uuid=project_uuid,filter_model=filter_model,)
[docs]@api_version(database_version)@router.get("/objectives/{objective_uuid}",response_model=ObjectiveResponse,summary="Get an objective by its UUID",)defread(objective_uuid:str,service:ObjectiveService=Depends(get_service))->ObjectiveResponse:"""Method to read one objective based on the id Args: objective_uuid (str): id of the vertex with the label "objective" Returns ObjectiveResponse: Objective with all properties """returnservice.read(objective_uuid)
[docs]@api_version(database_version)@router.patch("/objectives/{objective_uuid}",response_model=ObjectiveResponse,summary="Partial update of an objective by its UUID",)defupdate_objective(objective_uuid:str,modified_fields:ObjectiveUpdate,service:ObjectiveService=Depends(get_service),)->ObjectiveResponse:"""Updates the specified objective based on the id with the new objective_data Args: objective_uuid (str): id of the objective vertex modified_fields (ObjectiveUpdate): contains properties of the objective Returns: ObjectiveResponse: Objective with the objective_data as ObjectiveData """returnservice.update(objective_uuid,modified_fields)
[docs]@api_version(database_version)@router.delete("/objectives/{objective_uuid}",response_model=None,summary="Delete an objective by its UUID",)defdelete_objective(objective_uuid:str,service:ObjectiveService=Depends(get_service)):"""Deletes the objective vertex based on the id and also all in and outgoing edges from this vertex Args: objective_uuid (str): id of the objective vertex Returns: None """service.delete(objective_uuid)return