You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/18 10:38:53 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #9322: DAG Source endpoint

mik-laj commented on a change in pull request #9322:
URL: https://github.com/apache/airflow/pull/9322#discussion_r442133045



##########
File path: airflow/api_connexion/endpoints/dag_source_endpoint.py
##########
@@ -14,13 +14,35 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+import json
+import logging
 
-# TODO(mik-laj): We have to implement it.
-#     Do you want to help? Please look at: https://github.com/apache/airflow/issues/8137
+from flask import Response, current_app, request
+from itsdangerous import BadSignature, URLSafeSerializer
 
+from airflow.api_connexion.exceptions import NotFound
+from airflow.models.dagcode import DagCode
 
-def get_dag_source():
+log = logging.getLogger(__name__)
+
+
+def get_dag_source(file_token: str):
     """
     Get source code using file token
     """
-    raise NotImplementedError("Not implemented yet.")
+    secret_key = current_app.config["SECRET_KEY"]
+    auth_s = URLSafeSerializer(secret_key)
+    try:
+        path = auth_s.loads(file_token)
+        dag_source = DagCode.code(path)
+    except (BadSignature, FileNotFoundError):
+        raise NotFound("Dag Source not found")
+
+    from accept_types import get_best_match

Review comment:
       Can you add this library to setup.py?




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

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