[docs]@api_version(database_version)@router.post("/projects/{project_uuid}/opportunities",response_model=OpportunityResponse,summary="Create a new opportunity by its project UUID",)defcreate(project_uuid:str,opportunity_data:OpportunityCreate,service:OpportunityService=Depends(get_service),)->OpportunityResponse:"""Method to create a new opportunity connected to a project vertex Creates vertex with the label "opportunity" and the properties of opportunity_data Creates an edge between the project vertex specified by project_uuid and the newly create opportunity vertex Args: project_uuid (str): id of the project vertex the new opportunity will be connected to opportunity_data (OpportunityCreate): contains all properties for the opportunity Returns: OpportunityResponse: Created Opportunity with the opportunity_data as OpportunityCreate """returnservice.create(project_uuid=project_uuid,opportunity_data=opportunity_data)
[docs]@api_version(database_version)@router.get("/projects/{project_uuid}/opportunities",response_model=list[OpportunityResponse],summary="Get all opportunities by their project UUID",)defread_opportunities_all(project_uuid:str,filter_model:Filter=Depends(),service:OpportunityService=Depends(get_service),)->list[OpportunityResponse]:"""Read all opportunitys 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 opportunity node, should always be "contains" in this method (default "contains") filter_model (Filter(BaseModel)): contains a dict with different properties for filtering, like tag and description Returns List[OpportunityResponse]: List of Opportunitys which satisfy the condition to be connected to the Project vertex with a "contains" edge and have the label "opportunity" and satisfy the filters when the filter_model is given """returnservice.read_opportunities_all(project_uuid=project_uuid,filter_model=filter_model,)
[docs]@api_version(database_version)@router.get("/opportunities/{opportunity_uuid}",response_model=OpportunityResponse,summary="Get an opportunity by its UUID",)defread(opportunity_uuid:str,service:OpportunityService=Depends(get_service)):"""Read all opportunitys 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 opportunity node, should always be "contains" in this method (default "contains") filter_model (Filter(BaseModel)): contains a dict with different properties for filtering, like tag and description Returns List[OpportunityResponse]: List of Opportunitys which satisfy the condition to be connected to the Project vertex with a "contains" edge and have the label "opportunity" and satisfy the filters when the filter_model is given """returnservice.read(opportunity_uuid)
[docs]@api_version(database_version)@router.patch("/opportunities/{opportunity_uuid}",response_model=OpportunityResponse,summary="Partial update of an opportunity by its UUID",)defupdate(opportunity_uuid:str,modified_fields:OpportunityUpdate,service:OpportunityService=Depends(get_service),):"""Updates the specified opportunity based on the id with the new opportunity_data Args: opportunity_uuid (str): id of the opportunity vertex modified_fields (OpportunityUpdate): contains properties of the opportunity Returns OpportunityResponse: Opportunity with the opportunity_data as OpportunityData """returnservice.update(opportunity_uuid,modified_fields)
[docs]@api_version(database_version)@router.delete("/opportunities/{opportunity_uuid}",response_model=None,summary="Delete an objective by its UUID",)defdelete(opportunity_uuid:str,service:OpportunityService=Depends(get_service)):"""Deletes the opportunity vertex based on the id and also all in and outgoing edges from this vertex Args: opportunity_uuid (str): id of the opportunity vertex Returns None """returnservice.delete(opportunity_uuid)