MCPcopy Create free account
hub / github.com/IQEngine/IQEngine / create_meta

Function create_meta

api/handlers/metadata.py:344–389  ·  view source on GitHub ↗
(
    account: str,
    container: str,
    filepath: str,
    metadata: Metadata,
    datasources: AgnosticCollection = Depends(datasource_repo.collection),
    metadatas: AgnosticCollection = Depends(metadata_repo.collection),
    versions: AgnosticCollection = Depends(metadata_repo.versions_collection),
    access_allowed=Depends(check_access),
)

Source from the content-addressed store, hash-verified

342 response_model=Metadata,
343)
344async def create_meta(
345 account: str,
346 container: str,
347 filepath: str,
348 metadata: Metadata,
349 datasources: AgnosticCollection = Depends(datasource_repo.collection),
350 metadatas: AgnosticCollection = Depends(metadata_repo.collection),
351 versions: AgnosticCollection = Depends(metadata_repo.versions_collection),
352 access_allowed=Depends(check_access),
353):
354 if access_allowed != "owner":
355 raise HTTPException(status_code=403, detail="No Access")
356 # Check datasource id is valid
357 datasource = await datasources.find_one(
358 {"account": account, "container": container}
359 )
360 if not datasource:
361 raise HTTPException(status_code=404, detail="Datasource not found")
362
363 # Check metadata doesn't already exist
364 if await metadatas.find_one(
365 {
366 "global.traceability:origin.account": account,
367 "global.traceability:origin.container": container,
368 "global.traceability:origin.file_path": filepath,
369 }
370 ):
371 raise HTTPException(status_code=409, detail="Metadata already exists")
372
373 # Create the first metadata record
374 metadata.globalMetadata.traceability_origin = DataSourceReference(
375 **{
376 "type": "api",
377 "account": account,
378 "container": container,
379 "file_path": filepath,
380 }
381 )
382 metadata.globalMetadata.traceability_revision = 0
383 await metadatas.insert_one(
384 metadata.dict(by_alias=True, exclude_unset=True, exclude_none=True)
385 )
386 await versions.insert_one(
387 metadata.dict(by_alias=True, exclude_unset=True, exclude_none=True)
388 )
389 return metadata
390
391
392@router.put(

Callers

nothing calls this directly

Calls 1

DataSourceReferenceClass · 0.90

Tested by

no test coverage detected