-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2e4d21
commit 9392ebe
Showing
13 changed files
with
652 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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 fastapi import Depends, HTTPException | ||
from sqlalchemy import select | ||
from sqlalchemy.orm import Session | ||
from typing_extensions import Annotated | ||
|
||
from airflow.api_fastapi.common.db.common import ( | ||
get_session, | ||
) | ||
from airflow.api_fastapi.common.router import AirflowRouter | ||
from airflow.api_fastapi.core_api.serializers.event_logs import ( | ||
EventLogResponse, | ||
) | ||
from airflow.models import Log | ||
|
||
event_logs_router = AirflowRouter(tags=["Event Log"], prefix="/eventLogs") | ||
|
||
|
||
@event_logs_router.get("/{event_log_id}") | ||
async def get_event_log( | ||
event_log_id: int, | ||
session: Annotated[Session, Depends(get_session)], | ||
) -> EventLogResponse: | ||
event_log = session.scalar(select(Log).where(Log.id == event_log_id)) | ||
if event_log is None: | ||
raise HTTPException(404, f"The Event Log with id: `{event_log_id}` not found") | ||
return EventLogResponse.model_validate( | ||
event_log, | ||
from_attributes=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 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 pydantic import BaseModel, ConfigDict, Field | ||
|
||
|
||
class EventLogResponse(BaseModel): | ||
"""Event Log Response.""" | ||
|
||
id: int = Field(alias="event_log_id") | ||
dttm: datetime = Field(alias="when") | ||
dag_id: str | None | ||
task_id: str | None | ||
run_id: str | None | ||
map_index: int | None | ||
try_number: int | None | ||
event: str | ||
execution_date: datetime | None = Field(alias="logical_date") | ||
owner: str | None | ||
extra: str | None | ||
|
||
model_config = ConfigDict(populate_by_name=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.