mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Put identifier in path (#48831)
This commit is contained in:
parent
809aa38103
commit
99eaa0fc20
@ -86,6 +86,8 @@ func (srv *ProvisioningSrv) RoutePostContactPoint(c *models.ReqContext, cp apimo
|
||||
}
|
||||
|
||||
func (srv *ProvisioningSrv) RoutePutContactPoint(c *models.ReqContext, cp apimodels.EmbeddedContactPoint) response.Response {
|
||||
id := web.Params(c.Req)[":ID"]
|
||||
cp.UID = id
|
||||
err := srv.contactPointService.UpdateContactPoint(c.Req.Context(), c.OrgId, cp, alerting_models.ProvenanceAPI)
|
||||
if err != nil {
|
||||
return ErrResp(http.StatusInternalServerError, err, "")
|
||||
|
@ -188,7 +188,7 @@ func (api *API) authorize(method, path string) web.Handler {
|
||||
|
||||
case http.MethodPut + "/api/provisioning/policies",
|
||||
http.MethodPost + "/api/provisioning/contact-points",
|
||||
http.MethodPut + "/api/provisioning/contact-points",
|
||||
http.MethodPut + "/api/provisioning/contact-points/{ID}",
|
||||
http.MethodDelete + "/api/provisioning/contact-points/{ID}",
|
||||
http.MethodPut + "/api/provisioning/templates/{name}",
|
||||
http.MethodDelete + "/api/provisioning/templates/{name}":
|
||||
|
@ -35,7 +35,7 @@ func (f *ForkedProvisioningApi) forkRoutePostContactpoints(ctx *models.ReqContex
|
||||
return f.svc.RoutePostContactPoint(ctx, cp)
|
||||
}
|
||||
|
||||
func (f *ForkedProvisioningApi) forkRoutePutContactpoints(ctx *models.ReqContext, cp apimodels.EmbeddedContactPoint) response.Response {
|
||||
func (f *ForkedProvisioningApi) forkRoutePutContactpoint(ctx *models.ReqContext, cp apimodels.EmbeddedContactPoint) response.Response {
|
||||
return f.svc.RoutePutContactPoint(ctx, cp)
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ type ProvisioningApiForkingService interface {
|
||||
RouteGetTemplate(*models.ReqContext) response.Response
|
||||
RouteGetTemplates(*models.ReqContext) response.Response
|
||||
RoutePostContactpoints(*models.ReqContext) response.Response
|
||||
RoutePutContactpoints(*models.ReqContext) response.Response
|
||||
RoutePutContactpoint(*models.ReqContext) response.Response
|
||||
RoutePutPolicyTree(*models.ReqContext) response.Response
|
||||
RoutePutTemplate(*models.ReqContext) response.Response
|
||||
}
|
||||
@ -64,12 +64,12 @@ func (f *ForkedProvisioningApi) RoutePostContactpoints(ctx *models.ReqContext) r
|
||||
return f.forkRoutePostContactpoints(ctx, conf)
|
||||
}
|
||||
|
||||
func (f *ForkedProvisioningApi) RoutePutContactpoints(ctx *models.ReqContext) response.Response {
|
||||
func (f *ForkedProvisioningApi) RoutePutContactpoint(ctx *models.ReqContext) response.Response {
|
||||
conf := apimodels.EmbeddedContactPoint{}
|
||||
if err := web.Bind(ctx.Req, &conf); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
return f.forkRoutePutContactpoints(ctx, conf)
|
||||
return f.forkRoutePutContactpoint(ctx, conf)
|
||||
}
|
||||
|
||||
func (f *ForkedProvisioningApi) RoutePutPolicyTree(ctx *models.ReqContext) response.Response {
|
||||
@ -161,12 +161,12 @@ func (api *API) RegisterProvisioningApiEndpoints(srv ProvisioningApiForkingServi
|
||||
),
|
||||
)
|
||||
group.Put(
|
||||
toMacaronPath("/api/provisioning/contact-points"),
|
||||
api.authorize(http.MethodPut, "/api/provisioning/contact-points"),
|
||||
toMacaronPath("/api/provisioning/contact-points/{ID}"),
|
||||
api.authorize(http.MethodPut, "/api/provisioning/contact-points/{ID}"),
|
||||
metrics.Instrument(
|
||||
http.MethodPut,
|
||||
"/api/provisioning/contact-points",
|
||||
srv.RoutePutContactpoints,
|
||||
"/api/provisioning/contact-points/{ID}",
|
||||
srv.RoutePutContactpoint,
|
||||
m,
|
||||
),
|
||||
)
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
// 202: Accepted
|
||||
// 400: ValidationError
|
||||
|
||||
// swagger:route PUT /api/provisioning/contact-points provisioning RoutePutContactpoints
|
||||
// swagger:route PUT /api/provisioning/contact-points/{ID} provisioning RoutePutContactpoint
|
||||
//
|
||||
// Update an existing contact point.
|
||||
//
|
||||
@ -48,7 +48,7 @@ import (
|
||||
// 202: Accepted
|
||||
// 400: ValidationError
|
||||
|
||||
// swagger:parameters RoutePostContactpoints RoutePutContactpoints
|
||||
// swagger:parameters RoutePostContactpoints RoutePutContactpoint
|
||||
type ContactPointPayload struct {
|
||||
// in:body
|
||||
Body EmbeddedContactPoint
|
||||
|
@ -3391,12 +3391,11 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
},
|
||||
"type": "array",
|
||||
"x-go-name": "GettableSilences",
|
||||
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
|
||||
"type": "array"
|
||||
},
|
||||
"labelSet": {
|
||||
"additionalProperties": {
|
||||
@ -4851,12 +4850,35 @@
|
||||
"tags": [
|
||||
"provisioning"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/provisioning/contact-points/{ID}": {
|
||||
"delete": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"operationId": "RouteDeleteContactpoints",
|
||||
"responses": {
|
||||
"202": {
|
||||
"$ref": "#/responses/Accepted"
|
||||
},
|
||||
"400": {
|
||||
"description": "ValidationError",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ValidationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"summary": "Delete a contact point.",
|
||||
"tags": [
|
||||
"provisioning"
|
||||
]
|
||||
},
|
||||
"put": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"operationId": "RoutePutContactpoints",
|
||||
"operationId": "RoutePutContactpoint",
|
||||
"parameters": [
|
||||
{
|
||||
"in": "body",
|
||||
@ -4883,29 +4905,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/provisioning/contact-points/{ID}": {
|
||||
"delete": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"operationId": "RouteDeleteContactpoints",
|
||||
"responses": {
|
||||
"202": {
|
||||
"$ref": "#/responses/Accepted"
|
||||
},
|
||||
"400": {
|
||||
"description": "ValidationError",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ValidationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
"summary": "Delete a contact point.",
|
||||
"tags": [
|
||||
"provisioning"
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/provisioning/policies": {
|
||||
"get": {
|
||||
"operationId": "RouteGetPolicyTree",
|
||||
|
@ -1144,36 +1144,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"provisioning"
|
||||
],
|
||||
"summary": "Update an existing contact point.",
|
||||
"operationId": "RoutePutContactpoints",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/EmbeddedContactPoint"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"202": {
|
||||
"$ref": "#/responses/Accepted"
|
||||
},
|
||||
"400": {
|
||||
"description": "ValidationError",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@ -1206,6 +1176,36 @@
|
||||
}
|
||||
},
|
||||
"/api/provisioning/contact-points/{ID}": {
|
||||
"put": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"provisioning"
|
||||
],
|
||||
"summary": "Update an existing contact point.",
|
||||
"operationId": "RoutePutContactpoint",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/EmbeddedContactPoint"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"202": {
|
||||
"$ref": "#/responses/Accepted"
|
||||
},
|
||||
"400": {
|
||||
"description": "ValidationError",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ValidationError"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@ -5375,12 +5375,11 @@
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence"
|
||||
},
|
||||
"x-go-name": "GettableSilences",
|
||||
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
|
||||
"$ref": "#/definitions/gettableSilences"
|
||||
},
|
||||
"labelSet": {
|
||||
|
Loading…
Reference in New Issue
Block a user