feat: proxy PreZero priority endpoints to FastAPI
This commit is contained in:
1 parent
a0ad60ec53
commit
7e9c2d9663
5 files changed
+564
-11
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -176,6 +177,28 @@ func (c *Client) TrainStatus(ctx context.Context, jobID string) (int, []byte, er
|
||||
return c.controlRequest(ctx, http.MethodGet, "/train/"+url.PathEscape(jobID), "", nil)
|
||||
}
|
||||
|
||||
// PreZeroSummary proxies GET /prezero/summary.
|
||||
func (c *Client) PreZeroSummary(ctx context.Context) (int, []byte, error) {
|
||||
return c.controlRequest(ctx, http.MethodGet, "/prezero/summary", "", nil)
|
||||
}
|
||||
|
||||
// PreZeroPriority proxies GET /prezero/priority. priority may be empty to
|
||||
// return every tier; limit and offset are always forwarded.
|
||||
func (c *Client) PreZeroPriority(ctx context.Context, priority string, limit, offset int) (int, []byte, error) {
|
||||
query := url.Values{}
|
||||
if priority != "" {
|
||||
query.Set("priority", priority)
|
||||
}
|
||||
query.Set("limit", strconv.Itoa(limit))
|
||||
query.Set("offset", strconv.Itoa(offset))
|
||||
return c.controlRequest(ctx, http.MethodGet, "/prezero/priority?"+query.Encode(), "", nil)
|
||||
}
|
||||
|
||||
// PreZeroContainer proxies GET /prezero/containers/{location_id}.
|
||||
func (c *Client) PreZeroContainer(ctx context.Context, locationID string) (int, []byte, error) {
|
||||
return c.controlRequest(ctx, http.MethodGet, "/prezero/containers/"+url.PathEscape(locationID), "", nil)
|
||||
}
|
||||
|
||||
// controlRequest performs a training/control request and returns the raw
|
||||
// upstream status and body. Non-2xx responses are not errors: the proxy
|
||||
// forwards them so clients see FastAPI's 400/404/409 semantics.
|
||||
|
||||
Reference in new issue
Block a user