File size: 1,795 Bytes
d6f631f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | package router
import (
"net/http"
"github.com/openmeterio/openmeter/api"
"github.com/openmeterio/openmeter/openmeter/productcatalog/planaddon/httpdriver"
)
// List all available add-ons for plan
// (GET /api/v1/plans/{planId}/addons)
func (a *Router) ListPlanAddons(w http.ResponseWriter, r *http.Request, planId string, params api.ListPlanAddonsParams) {
a.planAddonHandler.ListPlanAddons().With(httpdriver.ListPlanAddonsParams{
ListPlanAddonsParams: params,
PlanIDOrKey: planId,
}).ServeHTTP(w, r)
}
// Create new add-on assignment for plan
// (POST /api/v1/plans/{planId}/addons)
func (a *Router) CreatePlanAddon(w http.ResponseWriter, r *http.Request, planId string) {
a.planAddonHandler.CreatePlanAddon().With(planId).ServeHTTP(w, r)
}
// Delete add-on assignment for plan
// (DELETE /api/v1/plans/{planId}/addons/{planAddonId})
func (a *Router) DeletePlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
a.planAddonHandler.DeletePlanAddon().With(httpdriver.DeletePlanAddonParams{
PlanID: planId,
AddonID: planAddonId,
}).ServeHTTP(w, r)
}
// Get add-on assignment for plan
// (GET /api/v1/plans/{planId}/addons/{planAddonId})
func (a *Router) GetPlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
a.planAddonHandler.GetPlanAddon().With(httpdriver.GetPlanAddonParams{
PlanIDOrKey: planId,
AddonIDOrKey: planAddonId,
}).ServeHTTP(w, r)
}
// Update add-on assignment for plan
// (PUT /api/v1/plans/{planId}/addons/{planAddonId})
func (a *Router) UpdatePlanAddon(w http.ResponseWriter, r *http.Request, planId string, planAddonId string) {
a.planAddonHandler.UpdatePlanAddon().With(httpdriver.UpdatePlanAddonParams{
PlanID: planId,
AddonID: planAddonId,
}).ServeHTTP(w, r)
}
|