Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(main.py): Add noevent flag #583

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pymongo.errors import DuplicateKeyError
from fastapi_users import FastAPIUsers
from beanie import PydanticObjectId
from kernelci.api.models import (

Check failure on line 37 in api/main.py

View workflow job for this annotation

GitHub Actions / Lint

Unable to import 'kernelci.api.models'
Node,
Hierarchy,
PublishEvent,
Expand Down Expand Up @@ -713,8 +713,9 @@


@app.put('/node/{node_id}', response_model=Node, response_model_by_alias=False)
async def put_node(node_id: str, node: Node,

Check warning on line 716 in api/main.py

View workflow job for this annotation

GitHub Actions / Lint

Too many local variables (16/15)
user: str = Depends(authorize_user)):
user: str = Depends(authorize_user),
noevent: Optional[bool] = Query(None)):
"""Update an already added node"""
metrics.add('http_requests_total', 1)
node.id = ObjectId(node_id)
Expand Down Expand Up @@ -763,9 +764,10 @@
attributes = {}
if data.get('owner', None):
attributes['owner'] = data['owner']
await pubsub.publish_cloudevent('node', data, attributes)
evhist = _get_eventhistory(data)
await db.create(evhist)
if not noevent:
await pubsub.publish_cloudevent('node', data, attributes)
evhist = _get_eventhistory(data)
await db.create(evhist)
return obj


Expand Down
Loading