bugraoz93 commented on code in PR #66261:
URL: https://github.com/apache/airflow/pull/66261#discussion_r3369406122


##########
airflow-core/src/airflow/api/client/local_client.py:
##########
@@ -19,22 +19,77 @@
 
 from __future__ import annotations
 
+import json
+from datetime import datetime
+from typing import Any
+
 import httpx
+from airflowctl.api.client import ClientKind as AirflowCtlClientKind, 
ServerResponseError, provide_api_client
+from airflowctl.api.datamodels.generated import PoolBody, TriggerDAGRunPostBody
+from airflowctl.exceptions import AirflowCtlConnectionException
+from pydantic import BaseModel, ConfigDict, Field, ValidationError as 
PydanticValidationError
 
 from airflow.api.common import delete_dag, trigger_dag
+from airflow.api_fastapi.app import get_auth_manager, init_auth_manager
+from airflow.api_fastapi.auth.managers.simple.user import SimpleAuthManagerUser
+from airflow.configuration import conf
 from airflow.exceptions import AirflowBadRequest, PoolNotFound
 from airflow.models.pool import Pool
+from airflow.utils.platform import getuser
 from airflow.utils.types import DagRunTriggeredByType
 
 
+class LocalDagRunResponse(BaseModel):
+    """Dag Run response returned by the local fallback client."""
+
+    model_config = ConfigDict(from_attributes=True, populate_by_name=True)
+
+    conf: dict[str, Any] | None
+    dag_id: str
+    dag_run_id: str = Field(validation_alias="run_id")
+    data_interval_start: datetime | None
+    data_interval_end: datetime | None
+    end_date: datetime | None
+    last_scheduling_decision: datetime | None
+    logical_date: datetime | None
+    run_type: str
+    start_date: datetime | None
+    state: str
+    triggering_user_name: str | None
+
+
 class Client:
     """Local API client implementation."""
 
     def __init__(self, auth=None, session: httpx.Client | None = None):
         self._session: httpx.Client = session or httpx.Client()
         if auth:
             self._session.auth = auth
+        self.api_token = self._create_api_token()
+
+    def _create_api_token(self) -> str:
+        try:
+            auth_manager = get_auth_manager()
+        except RuntimeError:
+            auth_manager = init_auth_manager()
+        return auth_manager.generate_jwt(
+            user=SimpleAuthManagerUser(username=getuser(), role="admin"),

Review Comment:
   It is resolved, but this should be `BaseUser`, as stated in my May 3 
comment. This still points to simpleauthmanageruser. If airflow constructed 
with another auth  manager in the instance running the CLI can end up with 
other users too.
   
   https://github.com/apache/airflow/pull/66261/changes#r3178497850



-- 
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]

Reply via email to