refactor: improve RunPod client

- Refactor RunPod client to use generics for requests and
responses.
- This improves code readability and maintainability.
- Remove redundant code for building GraphQL queries and
handling HTTP requests.
- Add support for environment variables in pod creation.
- Update example with new API key and environment variables.

Co-authored-by: supermario <mariobassem12@gmail.com>
This commit is contained in:
Mahmoud Emad
2025-01-20 15:01:27 +02:00
parent 0d2307acc8
commit d54a1e5a34
5 changed files with 180 additions and 120 deletions

View File

@@ -6,14 +6,16 @@ import freeflowuniverse.herolib.clients.runpod
// Example 1: Create client with direct API key
mut rp := runpod.get_or_create(
name: 'example1'
api_key: 'rpa_1G9W44SJM2A70ILYQSPAPEKDCTT181SRZGZK03A22lpazg'
api_key: 'rpa_JDYDWBS0PDTC55T1BYT1PX85CL4D5YEBZ48LETRXyf4gxr'
)!
// Create a new pod
pod_response := rp.create_pod(
name: 'test-pod'
name: 'RunPod Tensorflow'
image_name: 'runpod/tensorflow'
env: [
{"JUPYTER_PASSWORD": "rn51hunbpgtltcpac3ol"}
]
)!
println('Created pod with ID: ${pod_response.id}')