def new_from_yaml(httpreq: Request, request: NewDFIQRequest) -> dfiq.DFIQTypes:
    """Creates a new DFIQ object in the database."""
    try:
        new = dfiq.TYPE_MAPPING[request.dfiq_type].from_yaml(request.dfiq_yaml)
    except ValueError as error:
        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(error))

    # Ensure there is not an object with the same ID or UUID

    if new.dfiq_id and dfiq.DFIQBase.find(dfiq_id=new.dfiq_id):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail=f"DFIQ with id {new.dfiq_id} already exists",
        )

    if dfiq.DFIQBase.find(uuid=new.uuid):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail=f"DFIQ with uuid {new.uuid} already exists",
        )

    intended_parents = []

    # Scenarios don't have parent IDs
    parent_ids = [] if new.type == dfiq.DFIQType.scenario else new.parent_ids
    for parent_id in parent_ids:
        parent = dfiq.DFIQBase.find(dfiq_id=parent_id)
        if not parent:
            parent = dfiq.DFIQBase.find(uuid=parent_id)
        intended_parents.append(parent)
    if not all(intended_parents):
        raise HTTPException(
            status_code=status.HTTP_400_BAD_REQUEST,
            detail=f"Missing parent(s), provided {new.parent_ids}",
        )

    new = new.save()
    httpreq.state.user.link_to_acl(new, roles.Role.OWNER)
    audit.log_timeline(httpreq.state.username, new)

    try:
        new.update_parents()
    except ValueError as error:
        raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(error))

    if request.update_indicators and new.type == dfiq.DFIQType.question:
        dfiq.extract_indicators(new, user=httpreq.state.user.username)

    return new
Creates a new DFIQ object in the database.
core/web/apiv2/dfiq.py