https://github.com/zzstoatzz/prefect-go
https://github.com/zzstoatzz/prefect-go
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/zzstoatzz/prefect-go
- Owner: zzstoatzz
- Created: 2023-01-17T00:43:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-17T04:30:47.000Z (over 2 years ago)
- Last Synced: 2025-03-25T19:12:31.334Z (2 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# a golang prefect client
## Overview
Very much a work in progress. Currently only supports the following endpoints:
- health check: `/health` (GET)- read flow by ID: `/flows/{flow_id}` (GET)
- read flow by name: `/flows/name/{flow_name}` (GET)
- read flow run by ID: `/flow-runs/{flow_run_id}` (GET)
```go
package mainimport (
"encoding/json"
"fmt"
"os""github.com/joho/godotenv"
"github.com/zzstoatzz/prefect-go/pkg/client"
)func main() {
// load .env file
godotenv.Load()api_key := os.Getenv("PREFECT_API_KEY")
base_url := os.Getenv("PREFECT_API_URL")// create a new client
prefect_client := client.NewClient(api_key, base_url)// test read flow runs
flowRunId := "c451b292-148e-4f47-8d8c-393712975936"resp, err := prefect_client.ReadFlowRun(flowRunId)
// handle errors
if err != nil {
fmt.Printf("ERROR: %s\n", err)
}// pretty print the response
empJson, _ := json.MarshalIndent(resp, "", " ")fmt.Printf("RESPONSE: %s\n", string(empJson))
}
```I would like to generate the contents of the [`pkg/data`](pkg/data/) directory using the [OpenAPI spec](https://api.prefect.cloud/api/openapi.json). I have not yet figured out how to do this, although something in [this](https://www.jvt.me/posts/2022/04/06/generate-go-struct-openapi/) vein seems promising.
## Development
### Setup
```bash
git clone https://github.com/zzstoatzz/prefect-go.git
```