def new(httpreq: Request, request: NewObservableRequest) -> ObservableTypes:
    """Creates a new observable in the database.

    Raises:
        HTTPException(400) if observable already exists.
    """
    if observable.find(value=request.value, type=request.type):
        raise HTTPException(
            status_code=400,
            detail=f"Observable with value {request.value} already exists",
        )
    try:
        new = observable.save(type=request.type, value=request.value, tags=request.tags)
        audit.log_timeline(httpreq.state.username, new)
        rbac.set_acls(new, user=httpreq.state.user)

        return new
    except Exception:
        raise HTTPException(
            status_code=400,
            detail="Failed to add observable",
        )
Creates a new observable in the database.

    Raises:
        HTTPException(400) if observable already exists.
    
core/web/apiv2/observables.py