Skip to content

Commit b350110

Browse files
authored
Commitments base URL updated (#632)
1 parent 364c4a1 commit b350110

6 files changed

Lines changed: 14 additions & 14 deletions

File tree

internal/scheduling/reservations/commitments/api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ func (api *HTTPAPI) Init(mux *http.ServeMux, registry prometheus.Registerer, log
5454
registry.MustRegister(&api.usageMonitor)
5555
registry.MustRegister(&api.capacityMonitor)
5656
registry.MustRegister(&api.infoMonitor)
57-
mux.HandleFunc("/v1/commitments/change-commitments", api.HandleChangeCommitments)
58-
mux.HandleFunc("/v1/commitments/report-capacity", api.HandleReportCapacity)
59-
mux.HandleFunc("/v1/commitments/info", api.HandleInfo)
60-
mux.HandleFunc("/v1/commitments/projects/", api.HandleReportUsage) // matches /v1/commitments/projects/:project_id/report-usage
57+
mux.HandleFunc("/commitments/v1/change-commitments", api.HandleChangeCommitments)
58+
mux.HandleFunc("/commitments/v1/report-capacity", api.HandleReportCapacity)
59+
mux.HandleFunc("/commitments/v1/info", api.HandleInfo)
60+
mux.HandleFunc("/commitments/v1/projects/", api.HandleReportUsage) // matches /commitments/v1/projects/:project_id/report-usage
6161

6262
log.Info("commitments API initialized",
6363
"changeCommitmentsEnabled", api.config.EnableChangeCommitmentsAPI,

internal/scheduling/reservations/commitments/api_change_commitments_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ func (env *CommitmentTestEnv) CallChangeCommitmentsAPI(reqJSON string) (resp liq
10851085
}()
10861086

10871087
// Make HTTP request
1088-
url := env.HTTPServer.URL + "/v1/commitments/change-commitments"
1088+
url := env.HTTPServer.URL + "/commitments/v1/change-commitments"
10891089
httpResp, err := http.Post(url, "application/json", bytes.NewReader([]byte(reqJSON))) //nolint:gosec,noctx // test server URL, not user input
10901090
if err != nil {
10911091
cancel()

internal/scheduling/reservations/commitments/api_report_capacity.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"github.com/sapcc/go-api-declarations/liquid"
1515
)
1616

17-
// handles POST /v1/commitments/report-capacity requests from Limes:
17+
// handles POST /commitments/v1/report-capacity requests from Limes:
1818
// See: https://github.com/sapcc/go-api-declarations/blob/main/liquid/commitment.go
1919
// See: https://pkg.go.dev/github.com/sapcc/go-api-declarations/liquid
2020
// Reports available capacity across all flavor group resources. Note, unit is specified in the Info API response with multiple of the smallest memory resource unit within a flavor group.
@@ -38,7 +38,7 @@ func (api *HTTPAPI) HandleReportCapacity(w http.ResponseWriter, r *http.Request)
3838
}
3939

4040
ctx := reservations.WithGlobalRequestID(r.Context(), "committed-resource-"+requestID)
41-
logger := LoggerFromContext(ctx).WithValues("component", "api", "endpoint", "/v1/commitments/report-capacity")
41+
logger := LoggerFromContext(ctx).WithValues("component", "api", "endpoint", "/commitments/v1/report-capacity")
4242

4343
// Only accept POST method
4444
if r.Method != http.MethodPost {

internal/scheduling/reservations/commitments/api_report_usage.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/sapcc/go-api-declarations/liquid"
1616
)
1717

18-
// HandleReportUsage implements POST /v1/commitments/projects/:project_id/report-usage from Limes LIQUID API.
18+
// HandleReportUsage implements POST /commitments/v1/projects/:project_id/report-usage from Limes LIQUID API.
1919
// See: https://github.com/sapcc/go-api-declarations/blob/main/liquid/report_usage.go
2020
// See: https://pkg.go.dev/github.com/sapcc/go-api-declarations/liquid
2121
//
@@ -51,7 +51,7 @@ func (api *HTTPAPI) HandleReportUsage(w http.ResponseWriter, r *http.Request) {
5151
}
5252

5353
// Extract project UUID from URL path
54-
// URL pattern: /v1/commitments/projects/:project_id/report-usage
54+
// URL pattern: /commitments/v1/projects/:project_id/report-usage
5555
projectID, err := extractProjectIDFromPath(r.URL.Path)
5656
if err != nil {
5757
log.Error(err, "failed to extract project ID from path")
@@ -99,9 +99,9 @@ func (api *HTTPAPI) recordUsageMetrics(statusCode int, startTime time.Time) {
9999
}
100100

101101
// extractProjectIDFromPath extracts the project UUID from the URL path.
102-
// Expected path format: /v1/commitments/projects/:project_id/report-usage
102+
// Expected path format: /commitments/v1/projects/:project_id/report-usage
103103
func extractProjectIDFromPath(path string) (string, error) {
104-
// Path: /v1/commitments/projects/<uuid>/report-usage
104+
// Path: /commitments/v1/projects/<uuid>/report-usage
105105
parts := strings.Split(strings.Trim(path, "/"), "/")
106106
// Expected: ["v1", "commitments", "projects", "<uuid>", "report-usage"]
107107
if len(parts) < 5 {

internal/scheduling/reservations/commitments/api_report_usage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ func (env *UsageTestEnv) CallReportUsageAPI(projectID string, allAZs []string, u
576576
}
577577

578578
// Build URL
579-
url := env.HTTPServer.URL + "/v1/commitments/projects/" + projectID + "/report-usage"
579+
url := env.HTTPServer.URL + "/commitments/v1/projects/" + projectID + "/report-usage"
580580

581581
method := http.MethodPost
582582
if useGET {

internal/scheduling/reservations/commitments/e2e_checks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ type E2EChecksConfig struct {
2727
BaseURL string `json:"baseURL"`
2828
}
2929

30-
// CheckCommitmentsInfoEndpoint sends a GET request to the /v1/commitments/info endpoint
30+
// CheckCommitmentsInfoEndpoint sends a GET request to the /commitments/v1/info endpoint
3131
// and verifies that it returns HTTP 200 with a valid ServiceInfo response.
3232
func CheckCommitmentsInfoEndpoint(ctx context.Context, config E2EChecksConfig) {
3333
baseURL := config.BaseURL
3434
if baseURL == "" {
3535
baseURL = defaultCommitmentsAPIURL
3636
}
37-
apiURL := baseURL + "/v1/commitments/info"
37+
apiURL := baseURL + "/commitments/v1/info"
3838
slog.Info("checking commitments info endpoint", "apiURL", apiURL)
3939

4040
httpReq := must.Return(http.NewRequestWithContext(ctx, http.MethodGet, apiURL, http.NoBody))

0 commit comments

Comments
 (0)