edumuellerFSL commented on code in PR #37570:
URL: https://github.com/apache/airflow/pull/37570#discussion_r1500430412


##########
airflow/api_connexion/endpoints/dataset_endpoint.py:
##########
@@ -301,3 +312,37 @@ def delete_dataset_queued_events(
         "Queue event not found",
         detail=f"Queue event with dataset uri: `{uri}` was not found",
     )
+
+
+@security.requires_access_dataset("POST")
+@provide_session
+@action_logging(
+    event=action_event_from_permission(
+        prefix=RESOURCE_EVENT_PREFIX,
+        permission=permissions.ACTION_CAN_CREATE,
+    ),
+)
+def post_dataset_event(session: Session = NEW_SESSION) -> APIResponse:
+    """Post dataset event."""
+    try:
+        json_body = dataset_event_schema.load(get_json_request_dict(), 
session=session)
+    except ValidationError as err:
+        raise BadRequest(detail=str(err))
+    uri = json_body["dataset_uri"]
+    dm = session.scalar(select(DatasetModel).where(DatasetModel.uri == 
uri).limit(1))
+    if not dm:
+        raise NotFound(title="Dataset not found", detail=f"Dataset with uri: 
'{uri}' not found")
+    timestamp = datetime.now()
+    timestamp = timestamp.astimezone(timezone.utc)
+    extra = json_body.get("extra", {})
+    dataset_event = dataset_manager.register_dataset_change(
+        dataset=Dataset(uri),
+        timestamp=timestamp,
+        extra=extra,
+        session=session,
+    )
+    if not dataset_event:
+        raise NotFound(title="Dataset not found", detail=f"Dataset with uri: 
'{uri}' not found")
+    event = dataset_event_schema.dump(dataset_event)
+    event.pop("created_dagruns")

Review Comment:
   We can remove it, thanks @Lee-W 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to