generated from coulomb/repo-seed
merge-duplicates slice and did a first polish
This commit is contained in:
@@ -94,6 +94,26 @@ class CandidateLeafRelink(BaseModel):
|
||||
notes: str = ""
|
||||
|
||||
|
||||
class CandidateAbilityMerge(BaseModel):
|
||||
target_ability_id: int
|
||||
notes: str = ""
|
||||
|
||||
|
||||
class CandidateCapabilityMerge(BaseModel):
|
||||
target_capability_id: int
|
||||
notes: str = ""
|
||||
|
||||
|
||||
class CandidateFeatureMerge(BaseModel):
|
||||
target_feature_id: int
|
||||
notes: str = ""
|
||||
|
||||
|
||||
class CandidateEvidenceMerge(BaseModel):
|
||||
target_evidence_id: int
|
||||
notes: str = ""
|
||||
|
||||
|
||||
app = FastAPI(title="Repository Ability Registry", version="0.1.0")
|
||||
|
||||
|
||||
@@ -426,6 +446,102 @@ def relink_candidate_evidence(
|
||||
raise HTTPException(status_code=404, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.post(
|
||||
"/repos/{repository_id}/analysis-runs/{analysis_run_id}"
|
||||
"/candidate-abilities/{source_ability_id}/merge"
|
||||
)
|
||||
def merge_candidate_ability(
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
source_ability_id: int,
|
||||
payload: CandidateAbilityMerge,
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> dict[str, object]:
|
||||
try:
|
||||
return asdict(
|
||||
service.merge_candidate_ability(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
source_ability_id,
|
||||
**payload.model_dump(),
|
||||
)
|
||||
)
|
||||
except (NotFoundError, ValueError) as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.post(
|
||||
"/repos/{repository_id}/analysis-runs/{analysis_run_id}"
|
||||
"/candidate-capabilities/{source_capability_id}/merge"
|
||||
)
|
||||
def merge_candidate_capability(
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
source_capability_id: int,
|
||||
payload: CandidateCapabilityMerge,
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> dict[str, object]:
|
||||
try:
|
||||
return asdict(
|
||||
service.merge_candidate_capability(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
source_capability_id,
|
||||
**payload.model_dump(),
|
||||
)
|
||||
)
|
||||
except (NotFoundError, ValueError) as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.post(
|
||||
"/repos/{repository_id}/analysis-runs/{analysis_run_id}"
|
||||
"/candidate-features/{source_feature_id}/merge"
|
||||
)
|
||||
def merge_candidate_feature(
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
source_feature_id: int,
|
||||
payload: CandidateFeatureMerge,
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> dict[str, object]:
|
||||
try:
|
||||
return asdict(
|
||||
service.merge_candidate_feature(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
source_feature_id,
|
||||
**payload.model_dump(),
|
||||
)
|
||||
)
|
||||
except (NotFoundError, ValueError) as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.post(
|
||||
"/repos/{repository_id}/analysis-runs/{analysis_run_id}"
|
||||
"/candidate-evidence/{source_evidence_id}/merge"
|
||||
)
|
||||
def merge_candidate_evidence(
|
||||
repository_id: int,
|
||||
analysis_run_id: int,
|
||||
source_evidence_id: int,
|
||||
payload: CandidateEvidenceMerge,
|
||||
service: RegistryService = Depends(get_service),
|
||||
) -> dict[str, object]:
|
||||
try:
|
||||
return asdict(
|
||||
service.merge_candidate_evidence(
|
||||
repository_id,
|
||||
analysis_run_id,
|
||||
source_evidence_id,
|
||||
**payload.model_dump(),
|
||||
)
|
||||
)
|
||||
except (NotFoundError, ValueError) as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
@app.post("/repos/{repository_id}/abilities", status_code=201)
|
||||
def create_ability(
|
||||
repository_id: int,
|
||||
|
||||
Reference in New Issue
Block a user