andyjianzhou commented on code in PR #40987:
URL: https://github.com/apache/airflow/pull/40987#discussion_r1702362378


##########
contributing-docs/17_adding_api_endpoints.rst:
##########
@@ -0,0 +1,134 @@
+.. 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.
+
+Adding a New API Endpoint in Apache Airflow
+===========================================
+
+This documentation outlines the steps required to add a new API endpoint in 
Apache Airflow. It includes defining the endpoint in the OpenAPI specification, 
implementing the logic, running pre-commit checks, and documenting the changes.
+
+**The outline for this document in GitHub is available at top-right corner 
button (with 3-dots and 3 lines).**
+
+Step 1: Define the Endpoint in ``v1.yaml``
+----------------------------------------
+1. Navigate to the ``v1.yaml`` file, which contains the OpenAPI specifications.
+2. Add a new path for your endpoint, specifying the URL path, HTTP method 
(GET, POST, etc.), and a brief summary.
+3. Define the parameters required for the endpoint, including types, 
required/optional status, and default values.
+4. Describe the responses, including status codes, content types, and schema 
details.
+
+Example:
+
+.. code-block:: yaml
+
+   paths:
+     /example/endpoint:
+       get:
+         summary: Example API endpoint
+         description: This endpoint provides an example response.
+         parameters:
+           - name: example_param
+             in: query
+             required: true
+             schema:
+               type: string
+         responses:
+           "200":
+             description: Successful response
+             content:
+               application/json:
+                 schema:
+                   type: object
+                   properties:
+                     message:
+                       type: string
+           "400":
+             $ref: "#/components/responses/BadRequest"
+           "404":
+             $ref: "#/components/responses/NotFound"
+
+
+Step 2: Implement the Endpoint Logic
+------------------------------------
+1. In the appropriate Python file, implement the endpoint's logic.
+2. Ensure proper parameter handling and validation.
+3. Implement the core logic, such as data retrieval or processing.
+4. Add error handling for potential issues like missing parameters or invalid 
data.
+
+Example:
+
+.. code-block:: python
+
+   @security.requires_access_dag("GET", DagAccessEntity.TASK_LOGS)
+   @provide_session
+   @unify_bucket_name_and_key
+   @provide_bucket_name
+   def get_example(
+       *,
+       example_param: str,
+       session: Session = NEW_SESSION,
+   ) -> APIResponse:
+       # Implementation details here
+       pass
+
+
+Step 3: Run Pre-commit Hooks

Review Comment:
   I think I got it! Check it out now 👍 



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