### Environment Setup Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Provides guidance on setting up the necessary environment for running the tool, including installing dependencies. This is crucial for a smooth user experience. ```bash # Create a virtual environment python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` # Install the library and its dependencies pip install api-doc-extractor # Or if installing from source: # pip install -e .[all] ``` -------------------------------- ### Basic Command-Line Usage Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Demonstrates the fundamental way to use the tool from the command line. Ensure the tool is installed and accessible in your PATH. ```bash api_doc_extractor --url "https://example.com" --output "./output.md" ``` -------------------------------- ### Python Client Initialization Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/api-reference/file-output.md Quick start example for initializing the Hetzner Cloud API client in Python. ```python from hetzner import Client client = Client(token="your-token") ``` -------------------------------- ### Install Chromium Browser Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/api-reference/browser-automation.md Use these commands for initial setup or to update the Chromium browser binaries. Ensure Playwright is installed or updated first. ```bash # First-time setup playwright install chromium ``` ```bash # Update to latest pip install --upgrade playwright playwright install chromium ``` -------------------------------- ### Get all Primary IPs (CLI) Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md This command-line interface example demonstrates how to list all Primary IPs using the Hetzner Cloud CLI. Ensure the CLI is installed and authenticated with your API token. ```bash hcloud primary-ip list ``` -------------------------------- ### Install and Run Project Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/README.md Installs necessary Python packages, downloads Playwright browsers, and runs the API documentation extractor script. Ensure you have Python and pip installed. ```bash # Install and run pip install playwright beautifulsoup4 markdownify playwright install python api_doc_extractor.py ``` -------------------------------- ### Complete Workflow Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/api-reference/api_doc_extractor.md This Python script demonstrates the full process of fetching HTML from a webpage, extracting the main content into Markdown format, and saving the result to a file. It requires the `api_doc_extractor` library to be installed. ```python from api_doc_extractor import fetch_homepage_html, extract_main_content, save_markdown # Step 1: Fetch the documentation page print("Fetching documentation...") html = fetch_homepage_html() # Step 2: Extract and convert to markdown print("Extracting content...") title, markdown_content = extract_main_content(html) # Step 3: Save to file print("Saving to file...") save_markdown(title, markdown_content, "docs_output.md") print("Complete!") ``` -------------------------------- ### Quick Reference Table Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Shows an example of a quick reference table, summarizing key functions, constants, or configuration options for easy lookup. ```markdown | Function/Constant | Description | |---|---| | `fetch_homepage_html(url)` | Fetches HTML content from a URL. | | `extract_main_content(html)` | Extracts main markdown content from HTML. | | `save_markdown(content, path)` | Saves markdown content to a file. | | `BASE_URL` | Default base URL for API requests. | | `OUTPUT_FILE` | Default output filename. | ``` -------------------------------- ### Serve Documentation from Python Web Server Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/examples.md Starts a local HTTP server to serve generated Markdown documentation. It ensures documentation exists before starting and runs the server in a background thread. ```python from http.server import HTTPServer, SimpleHTTPRequestHandler from pathlib import Path import threading from api_doc_extractor import fetch_homepage_html, extract_main_content, save_markdown class DocServer: def __init__(self, port=8000, output_file="docs.md"): self.port = port self.output_file = output_file self.server = None def ensure_docs_exist(self): """Generate docs if they don't exist.""" if not Path(self.output_file).exists(): print("Generating documentation...") html = fetch_homepage_html() title, markdown = extract_main_content(html) save_markdown(title, markdown, self.output_file) def start(self): """Start HTTP server.""" self.ensure_docs_exist() handler = SimpleHTTPRequestHandler self.server = HTTPServer(("localhost", self.port), handler) print(f"šŸ“š Server starting on http://localhost:{self.port}") print(f"šŸ“„ Serving: {self.output_file}") # Run in background thread thread = threading.Thread(target=self.server.serve_forever, daemon=True) thread.start() return self.server # Usage if __name__ == "__main__": doc_server = DocServer(port=8000) doc_server.start() # Keep server running try: import time while True: time.sleep(1) except KeyboardInterrupt: print("\nāœ… Server stopped") ``` -------------------------------- ### Git Integration Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Shows how the documentation extraction process can be integrated with Git, for example, to automatically update documentation in a repository or track changes. ```bash # Example: After generating docs, commit them to Git # cd /path/to/your/repo # git add docs/ # git commit -m "Update documentation" # git push origin main ``` -------------------------------- ### Verify Installation Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/getting-started.md Verify that the script is installed correctly by checking its help message. ```bash python api_doc_extractor.py --help ``` -------------------------------- ### Power on a Server Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md Starts a server by turning its power on. ```APIDOC ## Power on a Server ### Description Starts a server by turning its power on. ### Method POST ### Endpoint `/servers/{id}/actions/poweron` ### Parameters #### Path Parameters - **id** (int64) - Required - ID of the Server. ### Response #### Success Response (201) - **action** (object) - Details about the action performed. ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/START_HERE.md Install the necessary Python packages and Playwright browser binaries. This step is crucial before running the extractor. ```bash pip install playwright beautifulsoup4 markdownify playwright install ``` -------------------------------- ### Install Playwright and Browser Binaries Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/getting-started.md Run this command to install the Playwright library and download the Chromium browser binaries, which are necessary for headless browser automation. ```bash pip install --upgrade playwright playwright install chromium ``` -------------------------------- ### Power on a Server Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/llm.txt Starts a server by turning its power on. ```curl curl \ -X POST \ -H "Authorization: Bearer $API_TOKEN" \ "https://api.hetzner.cloud/v1/servers/$ID/actions/poweron" ``` ```json { "action": { "id": 13, "command": "start_server", "status": "running", "progress": 0, "started": "2016-01-30T23:50:00+00:00", "finished": null, "resources": [ { "id": 42, "type": "server" } ], "error": { "code": "action_failed", "message": "Action failed" } } } ``` -------------------------------- ### Testing Examples - HTML Parsing Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Provides examples of how to test the HTML parsing functionality, ensuring accurate conversion from HTML to the desired output format. ```python import unittest from api_doc_extractor import extract_main_content # Assuming this function handles parsing class TestHtmlParsing(unittest.TestCase): def test_simple_paragraph(self): html = "

Hello world

" expected_md = "Hello world" self.assertEqual(extract_main_content(html).strip(), expected_md) def test_heading_conversion(self): html = "

A Title

" expected_md = "# A Title" self.assertEqual(extract_main_content(html).strip(), expected_md) if __name__ == '__main__': unittest.main() ``` -------------------------------- ### Documentation Server Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Illustrates how to serve the generated documentation using a simple HTTP server. This is useful for previewing or sharing documentation. ```bash # After generating markdown files: python -m http.server 8000 --directory ./output_directory ``` -------------------------------- ### Bash Diagnose Playwright Installation Issues Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/errors.md A collection of bash commands to verify Playwright installation, check browser binaries, and install dependencies. Use these to diagnose setup problems. ```bash # Verify Playwright installation python -c "from playwright.sync_api import sync_playwright; print('Playwright OK')" # Check browser binaries python -m playwright install --with-deps # Verify chromium specifically python -m playwright install chromium # Run diagnostics python -m playwright install-deps ``` -------------------------------- ### File Output Configuration Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Demonstrates configuration options for file output, including specifying the output directory, filename, and handling file overwrites. This controls where and how the generated documentation is saved. ```python from pathlib import Path output_directory = Path("./docs") output_directory.mkdir(exist_ok=True) filename = "api_documentation.md" full_path = output_directory / filename # Example: Overwrite behavior is default, to prevent overwrite: # if full_path.exists(): # print(f"File {full_path} already exists. Skipping.") # else: # with open(full_path, "w", encoding="utf-8") as f: # f.write("# API Docs") ``` -------------------------------- ### Main Function Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Demonstrates the entry point of the script, showing how the core functions are orchestrated to perform the documentation extraction. This is typically the function called when running the script directly. ```python from api_doc_extractor import main if __name__ == "__main__": main() # Assumes main function handles argument parsing and execution flow ``` -------------------------------- ### Get All Certificates Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md Retrieves all Certificate objects from the Hetzner Cloud API. This example uses cURL to make the request. ```bash curl \ -H "Authorization: Bearer $API_TOKEN" \ "https://api.hetzner.cloud/v1/certificates" ``` -------------------------------- ### BASE_URL Constant Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Shows how the `BASE_URL` constant is used, typically as a default or starting point for API requests or web scraping. It can be overridden via configuration or command-line arguments. ```python from api_doc_extractor import BASE_URL print(f"Default base URL: {BASE_URL}") # Example of overriding: # config = {'BASE_URL': 'https://api.example.com'} # html = fetch_homepage_html(config.get('BASE_URL', BASE_URL)) ``` -------------------------------- ### Platform Considerations Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Discusses considerations for running the tool on different operating systems (Windows, macOS, Linux), particularly regarding file path handling and external dependencies. ```python from pathlib import Path import os # Example: Using Path for cross-platform compatibility output_dir = Path("output") output_dir.mkdir(exist_ok=True) # Example: Handling environment variables which might differ # temp_dir = os.environ.get('TEMP', '/tmp') # Windows vs Unix-like # print(f"Using temporary directory: {temp_dir}") ``` -------------------------------- ### Firewall Creation Response Sample Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md Example response after successfully creating a firewall, detailing its properties and associated actions. ```json { "firewall": { "id": 42, "name": "new-name", "labels": { "environment": "prod", "example.com/my": "label", "just-a-key": "" }, "created": "2016-01-30T23:55:00+00:00", "rules": [ { "description": null, "direction": "in", "source_ips": [ "28.239.13.1/32", "28.239.14.0/24", "ff21:1eac:9a3b:ee58:5ca:990c:8bc9:c03b/128" ], "destination_ips": [], "protocol": "tcp", "port": "80" } ], "applied_to": [ { "type": "server", "server": { "id": 42 }, "label_selector": { "selector": "env=prod" }, "applied_to_resources": [ { "type": "server", "server": { "id": 42 } } ] } ] }, "actions": [ { "id": 13, "command": "set_firewall_rules", "status": "success", "progress": 100, "started": "2016-01-30T23:55:00+00:00", "finished": "2016-01-30T23:56:00+00:00", "resources": [ { "id": 38, "type": "firewall" } ], "error": { "code": "action_failed", "message": "Action failed" } }, { "id": 14, "command": "apply_firewall", "status": "success", "progress": 100, "started": "2016-01-30T23:55:00+00:00", "finished": "2016-01-30T23:56:00+00:00", "resources": [ { "id": 42, "type": "server" }, { "id": 38, "type": "firewall" } ], "error": { "code": "action_failed", "message": "Action failed" } } ] } ``` -------------------------------- ### Get Load Balancer Metrics (cURL) Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md Use this cURL command to retrieve metrics for a specific load balancer. Ensure you replace placeholders like $API_TOKEN, $ID, $TYPE, $START, and $END with your actual values. ```bash curl \ -H "Authorization: Bearer $API_TOKEN" \ "https://api.hetzner.cloud/v1/load_balancers/$ID/metrics?type=$TYPE&start=$START&end=$END" ``` -------------------------------- ### Get all Actions for a Certificate Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/README.md Returns all Action objects for a Certificate. Supports sorting by fields like `id`, `command`, `status`, `started`, and `finished`, and filtering by `status` (running, success, error). Pagination is available via `page` and `per_page` parameters. ```APIDOC ## GET /certificates/{id}/actions ### Description Returns all Action objects for a Certificate. You can sort the results by using the `sort` URI parameter, and filter them with the `status` parameter. Only type `managed` Certificates can have Actions. For type `uploaded` Certificates the `actions` key will always contain an empty array. ### Method GET ### Endpoint /certificates/{id}/actions ### Parameters #### Path Parameters - **id** (integer, int64) - Required - ID of the Certificate. #### Query Parameters - **sort** (string) - Optional - Allowed: `id` `id:asc` `id:desc` `command` `command:asc` `command:desc` `status` `status:asc` `status:desc` `started` `started:asc` `started:desc` `finished` `finished:asc` `finished:desc` - Sort actions by field and direction. Can be used multiple times. For more information, see "[Sorting](#sorting)". - **status** (string) - Optional - Allowed: `running` `success` `error` - Filter the actions by status. Can be used multiple times. The response will only contain actions matching the specified statuses. - **page** (integer, int64) - Optional - Default: `1` - Page number to return. For more information, see "[Pagination](#pagination)". - **per_page** (integer, int64) - Optional - Default: `25` - Maximum number of entries returned per page. For more information, see "[Pagination](#pagination)". ### Response #### Success Response (200) - **actions** (array of objects) - Required - **meta** (object) - Required #### Response Example ```json { "actions": [ { "id": 14, "command": "issue_certificate", "status": "success", "progress": 100, "started": "2021-01-30T23:55:00+00:00", "finished": "2021-01-30T23:57:00+00:00", "resources": [ { "id": 896, "type": "certificate" } ], "error": { "code": "action_failed", "message": "Action failed" } } ], "meta": { "pagination": { "page": 1, "per_page": 25, "previous_page": null, "next_page": null, "last_page": 1, "total_entries": 21 } } } ``` ``` -------------------------------- ### Logging and Monitoring Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Demonstrates how to integrate logging to track the execution of the documentation extractor. This is vital for debugging and monitoring the process. ```python import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logging.info("Starting documentation extraction...") try: # ... extraction logic ... logging.info("Extraction completed successfully.") except Exception as e: logging.error(f"An error occurred: {e}", exc_info=True) ``` -------------------------------- ### Schedule Documentation Updates with APScheduler Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/examples.md This Python script uses APScheduler to run a background job that fetches, extracts, and saves Hetzner Cloud API documentation at a specified interval. It includes functions to perform the update and start the scheduler. Ensure the necessary API extraction libraries are installed. ```python from apscheduler.schedulers.background import BackgroundScheduler from api_doc_extractor import fetch_homepage_html, extract_main_content, save_markdown from datetime import datetime def update_docs_job(): """Background job to update documentation.""" timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") print(f"[{timestamp}] Starting scheduled documentation update...") try: html = fetch_homepage_html() title, markdown = extract_main_content(html) save_markdown(title, markdown, "hetzner_cloud_api.md") print(f"[{timestamp}] āœ… Documentation updated successfully") except Exception as e: print(f"[{timestamp}] āŒ Update failed: {e}") def start_scheduler(interval_hours=6): """Start scheduler for periodic updates.""" scheduler = BackgroundScheduler() # Schedule job every N hours scheduler.add_job( update_docs_job, 'interval', hours=interval_hours, id='doc_update', name='Update Hetzner Cloud API docs' ) scheduler.start() print(f"šŸ“… Scheduler started - docs will update every {interval_hours} hours") return scheduler # Usage if __name__ == "__main__": scheduler = start_scheduler(interval_hours=6) # Keep running try: import time while True: time.sleep(1) except KeyboardInterrupt: scheduler.shutdown() print("āœ… Scheduler stopped") ``` -------------------------------- ### Install Playwright Browser Binaries Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/configuration.md Installs the necessary browser binaries for Playwright. Use `playwright install` for default browsers or `playwright install --with-deps` to include system dependencies. ```bash # Install default browsers (chromium) playwright install ``` ```bash # Install all browsers playwright install chromium firefox webkit ``` ```bash # Install with system dependencies playwright install-deps ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/configuration.md Installs the required Python packages for the project using pip. Ensure you have Python 3.8 or higher installed. ```bash pip install playwright beautifulsoup4 markdownify ``` -------------------------------- ### Sample Response for Server Creation Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/README.md This is a sample JSON response received after a server creation request. It includes details about the created server, the associated action, and potential next actions. ```json { "server": { "id": 42, "name": "my-server", "status": "initializing", "created": "2016-01-30T23:50:00+00:00", "public_net": { "ipv4": { "ip": "1.2.3.4", "blocked": false, "dns_ptr": "server01.example.com" }, "ipv6": { "ip": "2001:db8::/64", "blocked": false, "dns_ptr": [ { "ip": "2001:db8::1", "dns_ptr": "server.example.com" } ] }, "floating_ips": [ 478 ], "firewalls": [ { "id": 38, "status": "applied" } ] }, "private_net": [ { "network": 4711, "ip": "10.0.0.2", "alias_ips": [], "mac_address": "86:00:ff:2a:7d:e1" } ], "server_type": { "id": 1, "name": "cpx11", "description": "CPX11", "cores": 2, "memory": 2, "disk": 40, "deprecated": true, "prices": [ { "location": "fsn1", "price_hourly": { "net": "1.0000000000", "gross": "1.1900000000000000" }, "price_monthly": { "net": "1.0000000000", "gross": "1.1900000000000000" }, "included_traffic": 21990232555520, "price_per_tb_traffic": { "net": "1.0000000000", "gross": "1.1900000000000000" } } ], "storage_type": "local", "cpu_type": "shared", "architecture": "x86" }, "datacenter": { "id": 1, "name": "fsn1-dc8", "description": "Falkenstein 1 DC 8", "location": { "id": 1, "name": "fsn1", "description": "Falkenstein DC Park 1", "country": "DE", "city": "Falkenstein", "latitude": 50.47612, "longitude": 12.370071, "network_zone": "eu-central" }, "server_types": { "supported": [ 1, 2, 3 ], "available": [ 1, 2, 3 ], "available_for_migration": [ 1, 2, 3 ] } }, "image": { "id": 4711, "type": "snapshot", "status": "available", "name": "ubuntu-20.04", "description": "Ubuntu 20.04 Standard 64 bit", "image_size": 2.3, "disk_size": 10, "created": "2016-01-30T23:50:00+00:00", "created_from": { "id": 1, "name": "Server" }, "bound_to": null, "os_flavor": "ubuntu", "os_version": "20.04", "rapid_deploy": false, "protection": { "delete": false }, "deprecated": "2018-02-28T00:00:00+00:00", "deleted": null, "labels": { "key": "value" }, "architecture": "x86" }, "iso": { "id": 4711, "name": "FreeBSD-11.0-RELEASE-amd64-dvd1", "description": "FreeBSD 11.0 x64", "type": "public", "deprecation": { "announced": "2018-02-28T00:00:00+00:00", "unavailable_after": "2018-05-31T00:00:00+00:00" }, "architecture": "x86" }, "rescue_enabled": false, "locked": false, "backup_window": "22-02", "outgoing_traffic": 123456, "ingoing_traffic": 123456, "included_traffic": 654321, "protection": { "delete": false, "rebuild": false }, "labels": { "key": "value" }, "volumes": [], "load_balancers": [], "primary_disk_size": 50 }, "action": { "id": 1, "command": "create_server", "status": "running", "progress": 0, "started": "2016-01-30T23:50:00+00:00", "finished": null, "resources": [ { "id": 42, "type": "server" } ], "error": { "code": "action_failed", "message": "Action failed" } }, "next_actions": [ { "id": 13, "command": "start_server", "status": "running", "progress": 0, "started": "2016-01-30T23:50:00+00:00", "finished": null, "resources": [ { "id": 42, "type": "server" } ], "error": { "code": "action_failed", "message": "Action failed" } } ], "root_password": "YItygq1v3GYjjMomLaKc" } ``` -------------------------------- ### Wait Strategy Configuration Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Illustrates different strategies for waiting for page elements or network conditions to be met before proceeding. This is crucial for reliable automation on dynamic websites. ```python from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page() # Wait for a specific network event # page.goto("https://example.com", wait_until="networkidle") # Wait for a selector to be visible # page.wait_for_selector("#my-element", state="visible") # Explicit wait with timeout # page.wait_for_timeout(5000) # Wait for 5 seconds browser.close() ``` -------------------------------- ### uniqueness_error Example Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md An example of a `uniqueness_error`, which is returned when a field that must be unique already contains the given value. ```json { "error": { "code": "uniqueness_error", "message": "SSH key with the same fingerprint already exists", "details": { "fields": [ { "name": "public_key" } ] } } } ``` -------------------------------- ### Example Action Response Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md This is a sample JSON response for an action, showing details like ID, command, status, progress, resources, and potential errors. ```json { "actions": [ { "id": 42, "command": "start_resource", "status": "running", "started": "2016-01-30T23:55:00+00:00", "finished": "2016-01-30T23:55:00+00:00", "progress": 100, "resources": [ { "id": 42, "type": "server" } ], "error": { "code": "action_failed", "message": "Action failed" } } ] } ``` -------------------------------- ### Install APScheduler Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/examples.md Install the APScheduler library using pip to enable scheduled task management for your Python applications. ```bash pip install apscheduler ``` -------------------------------- ### File Path Examples Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/api-reference/file-output.md Illustrates various formats for the `file_path` parameter, including relative, absolute, and paths with subdirectories. ```python "hetzner_cloud_api.md" "./docs/api.md" "/tmp/docs.md" "C:\\Users\\User\\Docs\\api.md" ``` -------------------------------- ### Usage Examples - api_doc_extractor Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Provides practical examples of how to use the `api_doc_extractor` module for common documentation generation tasks. ```python # Basic usage: # api_doc_extractor.main(['--url', 'http://example.com', '--output', 'docs.md']) # Using browser automation: # api_doc_extractor.main(['--url', 'http://dynamic-site.com', '--output', 'dynamic.md', '--use-browser']) # With custom timeout: # api_doc_extractor.main(['--url', 'http://slow-site.com', '--output', 'slow.md', '--timeout', '60']) ``` -------------------------------- ### Create a Server Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/llm.txt Creates a new server. ```APIDOC ## POST /servers ### Description Creates a new Server. ### Method POST ### Endpoint /servers ### Request Body - **name** (string) - Required - Name of the Server. - **server_type** (string) - Required - Server type of the Server. - **image** (string) - Required - Image of the Server. - **location** (string) - Optional - Location of the Server. - **ssh_keys** (array) - Optional - SSH keys of the Server. - **user_data** (string) - Optional - User data for the Server. - **backups** (boolean) - Optional - Enable backups for the Server. - **ipv6** (boolean) - Optional - Enable IPv6 for the Server. - **start_after_create** (boolean) - Optional - Start the Server after creation. - **placement_group** (int64) - Optional - Placement group of the Server. - **networks** (array) - Optional - Networks of the Server. - **primary_ip** (string) - Optional - Primary IP of the Server. - **primary_ipv4** (string) - Optional - Primary IPv4 of the Server. - **primary_ipv6** (string) - Optional - Primary IPv6 of the Server. - **labels** (object) - Optional - User-defined labels. ``` -------------------------------- ### Create a Server Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation. ```APIDOC ## POST /servers ### Description Creates a new Server. Returns preliminary information about the Server as well as an Action that covers progress of creation. ### Method POST ### Endpoint /servers ### Request Body - **name** (string) - Required - Name of the Server - **server_type** (string) - Required - The Server type ID or name - **image** (string) - Required - The image ID or name - **start_after_create** (boolean) - Optional - If set to true, the Server will be started automatically after creation. Default: true - **location** (string) - Optional - The location ID or name the Server should be created in - **user_data** (string) - Optional - User data to be passed to the Server - **ssh_keys** (array) - Optional - IDs or names of SSH keys to be added to the Server - **backups** (boolean) - Optional - Enable backups for the Server. Default: false - **volumes** (array) - Optional - IDs of the Volumes to attach to the Server - **placement_group** (object) - Optional - Placement group the Server should be part of - **id** (int) - Required - ID of the Placement Group - **labels** (object) - Optional - User-defined labels - **key** (string) - Optional - Value of the label - **rescue_email** (string) - Optional - Email address for rescue system - **automount** (boolean) - Optional - Enable automount for volumes. Default: true - **network** (object) - Optional - Network configuration for the Server - **network** (int) - Required - ID of the Network - **ip** (string) - Optional - IP address of the Server in the Network - **alias_ips** (array) - Optional - Alias IP addresses for the Server - **ip** (string) - Required - Alias IP address ### Request Example ```json { "name": "my-server", "server_type": "cx11", "image": "ubuntu-20.04", "location": "fsn1", "ssh_keys": ["my-ssh-key"], "backups": true, "labels": { "environment": "production" } } ``` ### Response #### Success Response (201) - **server** (object) - Information about the created Server - **id** (int) - ID of the Server - **name** (string) - Name of the Server - **status** (string) - Status of the Server (e.g., `creating`, `running`, `stopped`) - **created** (string) - Timestamp of creation - **public_net** (object) - Public network information - **private_net** (array) - Private network information - **server_type** (object) - Server type details - **datacenter** (object) - Datacenter details - **image** (object) - Image details - **iso** (object) - ISO image details - **rescue_enabled** (boolean) - Whether rescue mode is enabled - **locked** (boolean) - Whether the Server is locked - **backup_window** (string) - Backup window - **outgoing_traffic** (int) - Outgoing traffic in bytes - **ingoing_traffic** (int) - Ingoing traffic in bytes - **included_traffic** (int) - Included traffic in bytes - **protection** (object) - Protection settings - **labels** (object) - User-defined labels - **volumes** (array) - IDs of attached Volumes - **load_balancers** (array) - IDs of attached Load Balancers - **primary_disk_size** (int) - Size of the primary disk - **placement_group** (object) - Placement group details - **action** (object) - Information about the creation action - **id** (int) - ID of the Action - **command** (string) - Command executed - **status** (string) - Status of the Action (e.g., `running`, `successful`, `failed`) - **started** (string) - Timestamp of start - **completed** (string) - Timestamp of completion #### Response Example ```json { "servers": [ { "id": 42, "name": "my-resource", "status": "running", "created": "2016-01-30T23:55:00+00:00", "public_net": { "ipv4": { "id": 42, "ip": "1.2.3.4", "blocked": false, "dns_ptr": "server01.example.com" }, "ipv6": { "id": 42, "ip": "2001:db8::/64", "blocked": false, "dns_ptr": [ { "ip": "2001:db8::1", "dns_ptr": "server.example.com" } ] }, "floating_ips": [ 478 ], "firewalls": [ { "id": 42, "status": "applied" } ] }, "private_net": [ { "network": 4711, "ip": "10.0.0.2", "alias_ips": [ "10.0.0.3", "10.0.0.4" ], "mac_address": "86:00:ff:2a:7d:e1" } ], "server_type": { "id": 1, "name": "cpx11", "description": "CPX11", "cores": 2, "memory": 2, "disk": 40, "deprecated": false, "prices": [ { "location": "fsn1", "price_hourly": { "net": "1.0000", "gross": "1.1900" }, "price_monthly": { "net": "1.0000", "gross": "1.1900" }, "included_traffic": 654321, "price_per_tb_traffic": { "net": "1.0000", "gross": "1.1900" } } ], "storage_type": "local", "cpu_type": "shared", "architecture": "x86", "deprecation": { "unavailable_after": "2023-09-01T00:00:00+00:00", "announced": "2023-06-01T00:00:00+00:00" } }, "datacenter": { "id": 42, "name": "fsn1-dc8", "description": "Falkenstein DC Park 8", "location": { "id": 42, "name": "fsn1", "description": "Falkenstein DC Park 1", "country": "DE", "city": "Falkenstein", "latitude": 50.47612, "longitude": 12.370071, "network_zone": "eu-central" }, "server_types": { "supported": [ 1, 2, 3 ], "available": [ 1, 2, 3 ], "available_for_migration": [ 1, 2, 3 ] } }, "image": { "id": 42, "type": "snapshot", "status": "available", "name": "ubuntu-20.04", "description": "Ubuntu 20.04 Standard 64 bit", "image_size": 2.3, "disk_size": 10, "created": "2016-01-30T23:55:00+00:00", "created_from": { "id": 1, "name": "Server" }, "bound_to": null, "os_flavor": "ubuntu", "os_version": "20.04", "rapid_deploy": false, "protection": { "delete": false }, "deprecated": "2018-02-28T00:00:00+00:00", "deleted": null, "labels": { "environment": "prod", "example.com/my": "label", "just-a-key": "" }, "architecture": "x86" }, "iso": { "id": 42, "name": "FreeBSD-11.0-RELEASE-amd64-dvd1", "description": "FreeBSD 11.0 x64", "type": "public", "deprecation": { "unavailable_after": "2023-09-01T00:00:00+00:00", "announced": "2023-06-01T00:00:00+00:00" }, "architecture": "x86" }, "rescue_enabled": false, "locked": false, "backup_window": "22-02", "outgoing_traffic": 123456, "ingoing_traffic": 123456, "included_traffic": 654321, "protection": { "delete": false, "rebuild": false }, "labels": { "environment": "prod", "example.com/my": "label", "just-a-key": "" }, "volumes": [ 0 ], "load_balancers": [ 0 ], "primary_disk_size": 50, "placement_group": { "id": 42, "name": "my-resource", "labels": { "environment": "prod", "example.com/my": "label", "just-a-key": "" }, "type": "spread", "created": "2016-01-30T23:55:00+00:00", "servers": [ 42 ] } } ], "meta": { "pagination": { "page": 3, "per_page": 25, "previous_page": 2, "next_page": 4, "last_page": 4, "total_entries": 100 } } } ``` ``` -------------------------------- ### Example API Response for Servers Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md This is an example JSON response when listing servers. It includes a list of servers and pagination metadata. ```json { "servers": [], "meta": { "pagination": { "page": 1, "per_page": 25, "previous_page": null, "next_page": null, "last_page": 1, "total_entries": 0 } } } ``` -------------------------------- ### Testing Examples - HTML Parsing Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/MANIFEST.txt Provides example code for testing the HTML parsing functionality, ensuring accurate conversion. ```python import unittest # Assume extract_main_content is the function performing the parsing from api_doc_extractor import extract_main_content class TestHtmlParsing(unittest.TestCase): def test_basic_conversion(self): html = "

Test paragraph.

" expected = "Test paragraph." self.assertEqual(extract_main_content(html).strip(), expected) if __name__ == '__main__': unittest.main() ``` -------------------------------- ### Example Content for Markdown File Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/_autodocs/api-reference/file-output.md An example of Markdown content that can be passed to the `save_markdown` function. This content includes headings and text. ```markdown ## Introduction Welcome to the API. ### Getting Started Follow these steps... ## API Endpoints ### GET /servers Retrieve server list. ``` -------------------------------- ### Get All Volumes Source: https://github.com/smrezvani/hetzner-cloud-api-document/blob/main/hetzner_cloud_api.md Retrieves all available volumes associated with your Hetzner Cloud account. This is a basic GET request to the volumes endpoint. ```cURL curl \ -H "Authorization: Bearer $API_TOKEN" \ "https://api.hetzner.cloud/v1/volumes" ```