mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 14:35:50 +08:00
docs: build OpenAPI spec and cut version 1.10 (#13537)
* build-api * bump-version-to-1.10 * fix-broken-links
This commit is contained in:
@ -0,0 +1,23 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
payload = {
|
||||
"name": "new_project_name",
|
||||
"description": "string",
|
||||
"components_list": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
|
||||
"flows_list": ["3fa85f64-5717-4562-b3fc-2c963f66afa6"],
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/"
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
payload = {"name": "new_project_name", "description": "string", "components_list": [], "flows_list": []}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,26 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
headers = {"accept": "*/*", "Content-Type": "application/json", "x-api-key": api_key}
|
||||
|
||||
create = requests.post(
|
||||
f"{base}/api/v1/projects/",
|
||||
headers=headers,
|
||||
json={
|
||||
"name": "docs-example-delete-me",
|
||||
"description": "Temporary project",
|
||||
"components_list": [],
|
||||
"flows_list": [],
|
||||
},
|
||||
timeout=30,
|
||||
)
|
||||
create.raise_for_status()
|
||||
project_id = create.json()["id"]
|
||||
|
||||
delete = requests.delete(f"{base}/api/v1/projects/{project_id}", headers=headers, timeout=30)
|
||||
delete.raise_for_status()
|
||||
print(delete.text)
|
||||
@ -0,0 +1,17 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/download/{os.getenv('PROJECT_ID', '')}"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
with open("langflow-project.zip", "wb") as f:
|
||||
f.write(response.content)
|
||||
print("Saved response to langflow-project.zip")
|
||||
@ -0,0 +1,19 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
fixtures = Path(__file__).resolve().parents[2] / "fixtures"
|
||||
default_json = fixtures / "project-import.json"
|
||||
import_path = Path(os.environ.get("PROJECT_IMPORT_JSON", str(default_json)))
|
||||
|
||||
headers = {"accept": "application/json", "x-api-key": api_key}
|
||||
|
||||
files = {"file": (import_path.name, import_path.read_bytes(), "application/json")}
|
||||
response = requests.post(f"{base}/api/v1/projects/upload/", headers=headers, files=files, timeout=60)
|
||||
|
||||
response.raise_for_status()
|
||||
print(response.text)
|
||||
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/{os.getenv('PROJECT_ID', '')}"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,15 @@
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
url = f"{os.getenv('LANGFLOW_URL', '')}/api/v1/projects/"
|
||||
|
||||
headers = {
|
||||
"accept": "application/json",
|
||||
"x-api-key": f"{os.getenv('LANGFLOW_API_KEY', '')}",
|
||||
}
|
||||
|
||||
response = requests.request("GET", url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
print(response.text)
|
||||
@ -0,0 +1,19 @@
|
||||
import os
|
||||
import uuid
|
||||
|
||||
import requests
|
||||
|
||||
base = os.environ.get("LANGFLOW_URL") or os.environ.get("LANGFLOW_SERVER_URL", "")
|
||||
project_id = os.environ.get("PROJECT_ID", "")
|
||||
api_key = os.environ.get("LANGFLOW_API_KEY", "")
|
||||
|
||||
headers = {"accept": "application/json", "Content-Type": "application/json", "x-api-key": api_key}
|
||||
|
||||
payload = {
|
||||
"name": f"docs-example-renamed-project-{uuid.uuid4().hex[:8]}",
|
||||
"description": "Updated via API docs Python example",
|
||||
}
|
||||
|
||||
response = requests.patch(f"{base}/api/v1/projects/{project_id}", headers=headers, json=payload, timeout=30)
|
||||
response.raise_for_status()
|
||||
print(response.text)
|
||||
Reference in New Issue
Block a user