pierrejeambrun commented on code in PR #43934: URL: https://github.com/apache/airflow/pull/43934#discussion_r1844103181
########## airflow/api_fastapi/common/utils.py: ########## @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +from datetime import datetime + +from fastapi import HTTPException, status +from pendulum.parsing import ParserError + +from airflow.utils import timezone + + +def format_datetime(value: str) -> datetime: + """ + Format datetime objects. + + If it can't be parsed, it returns an HTTP 400 exception. + """ + try: + return timezone.parse(value) + except (ParserError, TypeError) as err: + raise HTTPException(status.HTTP_400_BAD_REQUEST, detail=f"Incorrect datetime argument: {err}") Review Comment: what is the difference with the `_safe_parse_datetime` that is currently in `parameters.py` ? I don't think we should have two of them. Also comon ########## airflow/api_fastapi/core_api/routes/public/dags.py: ########## @@ -303,3 +307,45 @@ def delete_dag( status.HTTP_409_CONFLICT, f"Task instances of dag with id: '{dag_id}' are still running" ) return Response(status_code=status.HTTP_204_NO_CONTENT) + + +@dags_router.get( + "/{dag_id}/assets/queuedEvent", + responses=create_openapi_http_exception_doc( + [ + status.HTTP_401_UNAUTHORIZED, + status.HTTP_403_FORBIDDEN, + status.HTTP_404_NOT_FOUND, + ] + ), +) +def get_dag_asset_queued_events( + dag_id: str, + session: Annotated[Session, Depends(get_session)], + before: str = Query(None), Review Comment: You mentionned using `Optional[DateTimeQuery] = None` but the code stills mention `before: str = Query(None)` is that normal? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
