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 {
|
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)
|
err := srv.contactPointService.UpdateContactPoint(c.Req.Context(), c.OrgId, cp, alerting_models.ProvenanceAPI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ErrResp(http.StatusInternalServerError, err, "")
|
return ErrResp(http.StatusInternalServerError, err, "")
|
||||||
|
@ -188,7 +188,7 @@ func (api *API) authorize(method, path string) web.Handler {
|
|||||||
|
|
||||||
case http.MethodPut + "/api/provisioning/policies",
|
case http.MethodPut + "/api/provisioning/policies",
|
||||||
http.MethodPost + "/api/provisioning/contact-points",
|
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.MethodDelete + "/api/provisioning/contact-points/{ID}",
|
||||||
http.MethodPut + "/api/provisioning/templates/{name}",
|
http.MethodPut + "/api/provisioning/templates/{name}",
|
||||||
http.MethodDelete + "/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)
|
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)
|
return f.svc.RoutePutContactPoint(ctx, cp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ type ProvisioningApiForkingService interface {
|
|||||||
RouteGetTemplate(*models.ReqContext) response.Response
|
RouteGetTemplate(*models.ReqContext) response.Response
|
||||||
RouteGetTemplates(*models.ReqContext) response.Response
|
RouteGetTemplates(*models.ReqContext) response.Response
|
||||||
RoutePostContactpoints(*models.ReqContext) response.Response
|
RoutePostContactpoints(*models.ReqContext) response.Response
|
||||||
RoutePutContactpoints(*models.ReqContext) response.Response
|
RoutePutContactpoint(*models.ReqContext) response.Response
|
||||||
RoutePutPolicyTree(*models.ReqContext) response.Response
|
RoutePutPolicyTree(*models.ReqContext) response.Response
|
||||||
RoutePutTemplate(*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)
|
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{}
|
conf := apimodels.EmbeddedContactPoint{}
|
||||||
if err := web.Bind(ctx.Req, &conf); err != nil {
|
if err := web.Bind(ctx.Req, &conf); err != nil {
|
||||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
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 {
|
func (f *ForkedProvisioningApi) RoutePutPolicyTree(ctx *models.ReqContext) response.Response {
|
||||||
@ -161,12 +161,12 @@ func (api *API) RegisterProvisioningApiEndpoints(srv ProvisioningApiForkingServi
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
group.Put(
|
group.Put(
|
||||||
toMacaronPath("/api/provisioning/contact-points"),
|
toMacaronPath("/api/provisioning/contact-points/{ID}"),
|
||||||
api.authorize(http.MethodPut, "/api/provisioning/contact-points"),
|
api.authorize(http.MethodPut, "/api/provisioning/contact-points/{ID}"),
|
||||||
metrics.Instrument(
|
metrics.Instrument(
|
||||||
http.MethodPut,
|
http.MethodPut,
|
||||||
"/api/provisioning/contact-points",
|
"/api/provisioning/contact-points/{ID}",
|
||||||
srv.RoutePutContactpoints,
|
srv.RoutePutContactpoint,
|
||||||
m,
|
m,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
// 202: Accepted
|
// 202: Accepted
|
||||||
// 400: ValidationError
|
// 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.
|
// Update an existing contact point.
|
||||||
//
|
//
|
||||||
@ -48,7 +48,7 @@ import (
|
|||||||
// 202: Accepted
|
// 202: Accepted
|
||||||
// 400: ValidationError
|
// 400: ValidationError
|
||||||
|
|
||||||
// swagger:parameters RoutePostContactpoints RoutePutContactpoints
|
// swagger:parameters RoutePostContactpoints RoutePutContactpoint
|
||||||
type ContactPointPayload struct {
|
type ContactPointPayload struct {
|
||||||
// in:body
|
// in:body
|
||||||
Body EmbeddedContactPoint
|
Body EmbeddedContactPoint
|
||||||
|
@ -3391,12 +3391,11 @@
|
|||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
"gettableSilences": {
|
"gettableSilences": {
|
||||||
|
"description": "GettableSilences gettable silences",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
},
|
},
|
||||||
"type": "array",
|
"type": "array"
|
||||||
"x-go-name": "GettableSilences",
|
|
||||||
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
|
|
||||||
},
|
},
|
||||||
"labelSet": {
|
"labelSet": {
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
@ -4851,12 +4850,35 @@
|
|||||||
"tags": [
|
"tags": [
|
||||||
"provisioning"
|
"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": {
|
"put": {
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"operationId": "RoutePutContactpoints",
|
"operationId": "RoutePutContactpoint",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"in": "body",
|
"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": {
|
"/api/provisioning/policies": {
|
||||||
"get": {
|
"get": {
|
||||||
"operationId": "RouteGetPolicyTree",
|
"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": {
|
"post": {
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@ -1206,6 +1176,36 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"/api/provisioning/contact-points/{ID}": {
|
"/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": {
|
"delete": {
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@ -5375,12 +5375,11 @@
|
|||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
},
|
},
|
||||||
"gettableSilences": {
|
"gettableSilences": {
|
||||||
|
"description": "GettableSilences gettable silences",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/definitions/gettableSilence"
|
"$ref": "#/definitions/gettableSilence"
|
||||||
},
|
},
|
||||||
"x-go-name": "GettableSilences",
|
|
||||||
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
|
|
||||||
"$ref": "#/definitions/gettableSilences"
|
"$ref": "#/definitions/gettableSilences"
|
||||||
},
|
},
|
||||||
"labelSet": {
|
"labelSet": {
|
||||||
|
Loading…
Reference in New Issue
Block a user