feat: add kimi a7m overlay workflow and remote43 validation
This commit is contained in:
@@ -34,3 +34,27 @@ func (c *Client) DisableOpenAIResponsesAPI(ctx context.Context, accountIDs []str
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) ClearTempUnschedulable(ctx context.Context, accountIDs []string) error {
|
||||
seen := map[string]struct{}{}
|
||||
for _, rawID := range accountIDs {
|
||||
accountID := strings.TrimSpace(rawID)
|
||||
if accountID == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := seen[accountID]; ok {
|
||||
continue
|
||||
}
|
||||
seen[accountID] = struct{}{}
|
||||
|
||||
path := "/api/v1/admin/accounts/" + accountID + "/temp-unschedulable"
|
||||
statusCode, _, body, err := c.perform(ctx, http.MethodDelete, path, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if statusCode < http.StatusOK || statusCode >= http.StatusMultipleChoices {
|
||||
return newHTTPError(http.MethodDelete, path, statusCode, body)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -60,6 +60,58 @@ func TestDisableOpenAIResponsesAPIReturnsHTTPError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClearTempUnschedulableSkipsEmptyAccountIDs(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, err := NewClient("https://sub2api.example.com", WithHTTPClient(&http.Client{
|
||||
Transport: roundTripperFunc(func(*http.Request) (*http.Response, error) {
|
||||
t.Fatal("unexpected HTTP request for empty account ids")
|
||||
return nil, nil
|
||||
}),
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatalf("NewClient() error = %v", err)
|
||||
}
|
||||
|
||||
if err := client.ClearTempUnschedulable(context.Background(), []string{" ", ""}); err != nil {
|
||||
t.Fatalf("ClearTempUnschedulable() error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClearTempUnschedulableReturnsHTTPError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var gotPath string
|
||||
client, err := NewClient("https://sub2api.example.com", WithHTTPClient(&http.Client{
|
||||
Transport: roundTripperFunc(func(req *http.Request) (*http.Response, error) {
|
||||
gotPath = req.URL.Path
|
||||
return &http.Response{
|
||||
StatusCode: http.StatusForbidden,
|
||||
Header: make(http.Header),
|
||||
Body: io.NopCloser(strings.NewReader(`{"error":"forbidden"}`)),
|
||||
}, nil
|
||||
}),
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatalf("NewClient() error = %v", err)
|
||||
}
|
||||
|
||||
err = client.ClearTempUnschedulable(context.Background(), []string{"account-1"})
|
||||
if err == nil {
|
||||
t.Fatal("ClearTempUnschedulable() error = nil, want HTTP error")
|
||||
}
|
||||
httpErr, ok := err.(*HTTPError)
|
||||
if !ok {
|
||||
t.Fatalf("ClearTempUnschedulable() error type = %T, want *HTTPError", err)
|
||||
}
|
||||
if gotPath != "/api/v1/admin/accounts/account-1/temp-unschedulable" {
|
||||
t.Fatalf("request path = %q, want /api/v1/admin/accounts/account-1/temp-unschedulable", gotPath)
|
||||
}
|
||||
if httpErr.StatusCode != http.StatusForbidden {
|
||||
t.Fatalf("HTTPError.StatusCode = %d, want %d", httpErr.StatusCode, http.StatusForbidden)
|
||||
}
|
||||
}
|
||||
|
||||
type roundTripperFunc func(*http.Request) (*http.Response, error)
|
||||
|
||||
func (fn roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
|
||||
@@ -32,6 +32,7 @@ type HostAdapter interface {
|
||||
CheckGatewayAccess(ctx context.Context, req GatewayAccessCheckRequest) (GatewayAccessResult, error)
|
||||
CheckGatewayCompletion(ctx context.Context, req GatewayCompletionCheckRequest) (GatewayCompletionResult, error)
|
||||
DisableOpenAIResponsesAPI(ctx context.Context, accountIDs []string) error
|
||||
ClearTempUnschedulable(ctx context.Context, accountIDs []string) error
|
||||
ListManagedResources(ctx context.Context, req ListManagedResourcesRequest) (ManagedResourceSnapshot, error)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user