Added put service endpoint

This commit is contained in:
2024-01-15 17:17:17 +01:00
parent d2af394fc7
commit eb5eb1613f
2 changed files with 29 additions and 0 deletions

View File

@@ -64,6 +64,25 @@ def set_service_usage(
return db_service
def set_service(
db: Session, service_uuid: str, service: schemas.ServiceCreate
) -> sql_models.Service:
db_service = get_service_by_uuid(db, service_uuid)
if db_service is None:
raise ClanError(f"Service with uuid '{service_uuid}' not found")
db_service.service_name = service.service_name # type: ignore
db_service.service_type = service.service_type # type: ignore
db_service.endpoint_url = service.endpoint_url # type: ignore
db_service.status = service.status # type: ignore
db_service.other = service.other # type: ignore
db_service.entity_did = service.entity_did # type: ignore
db_service.action = service.action # type: ignore
db.add(db_service)
db.commit()
db.refresh(db_service)
return db_service
def add_service_usage(
db: Session, service_uuid: str, usage: schemas.ServiceUsageCreate
) -> sql_models.Service: