mirror of
https://github.com/harness/drone.git
synced 2025-05-11 14:40:05 +08:00
[Swagger] Update Webhook URLs to webhook_identifier and add retrigger execution operation (#1019)
This commit is contained in:
parent
f482ec08c4
commit
b173a7cbec
@ -44,7 +44,7 @@ type listWebhooksRequest struct {
|
|||||||
|
|
||||||
type webhookRequest struct {
|
type webhookRequest struct {
|
||||||
repoRequest
|
repoRequest
|
||||||
ID int64 `path:"webhook_id"`
|
ID int64 `path:"webhook_identifier"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type getWebhookRequest struct {
|
type getWebhookRequest struct {
|
||||||
@ -146,7 +146,7 @@ func webhookOperations(reflector *openapi3.Reflector) {
|
|||||||
_ = reflector.SetJSONResponse(&getWebhook, new(usererror.Error), http.StatusInternalServerError)
|
_ = reflector.SetJSONResponse(&getWebhook, new(usererror.Error), http.StatusInternalServerError)
|
||||||
_ = reflector.SetJSONResponse(&getWebhook, new(usererror.Error), http.StatusUnauthorized)
|
_ = reflector.SetJSONResponse(&getWebhook, new(usererror.Error), http.StatusUnauthorized)
|
||||||
_ = reflector.SetJSONResponse(&getWebhook, new(usererror.Error), http.StatusForbidden)
|
_ = reflector.SetJSONResponse(&getWebhook, new(usererror.Error), http.StatusForbidden)
|
||||||
_ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repo_ref}/webhooks/{webhook_id}", getWebhook)
|
_ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repo_ref}/webhooks/{webhook_identifier}", getWebhook)
|
||||||
|
|
||||||
updateWebhook := openapi3.Operation{}
|
updateWebhook := openapi3.Operation{}
|
||||||
updateWebhook.WithTags("webhook")
|
updateWebhook.WithTags("webhook")
|
||||||
@ -157,7 +157,7 @@ func webhookOperations(reflector *openapi3.Reflector) {
|
|||||||
_ = reflector.SetJSONResponse(&updateWebhook, new(usererror.Error), http.StatusInternalServerError)
|
_ = reflector.SetJSONResponse(&updateWebhook, new(usererror.Error), http.StatusInternalServerError)
|
||||||
_ = reflector.SetJSONResponse(&updateWebhook, new(usererror.Error), http.StatusUnauthorized)
|
_ = reflector.SetJSONResponse(&updateWebhook, new(usererror.Error), http.StatusUnauthorized)
|
||||||
_ = reflector.SetJSONResponse(&updateWebhook, new(usererror.Error), http.StatusForbidden)
|
_ = reflector.SetJSONResponse(&updateWebhook, new(usererror.Error), http.StatusForbidden)
|
||||||
_ = reflector.Spec.AddOperation(http.MethodPatch, "/repos/{repo_ref}/webhooks/{webhook_id}", updateWebhook)
|
_ = reflector.Spec.AddOperation(http.MethodPatch, "/repos/{repo_ref}/webhooks/{webhook_identifier}", updateWebhook)
|
||||||
|
|
||||||
deleteWebhook := openapi3.Operation{}
|
deleteWebhook := openapi3.Operation{}
|
||||||
deleteWebhook.WithTags("webhook")
|
deleteWebhook.WithTags("webhook")
|
||||||
@ -168,7 +168,7 @@ func webhookOperations(reflector *openapi3.Reflector) {
|
|||||||
_ = reflector.SetJSONResponse(&deleteWebhook, new(usererror.Error), http.StatusInternalServerError)
|
_ = reflector.SetJSONResponse(&deleteWebhook, new(usererror.Error), http.StatusInternalServerError)
|
||||||
_ = reflector.SetJSONResponse(&deleteWebhook, new(usererror.Error), http.StatusUnauthorized)
|
_ = reflector.SetJSONResponse(&deleteWebhook, new(usererror.Error), http.StatusUnauthorized)
|
||||||
_ = reflector.SetJSONResponse(&deleteWebhook, new(usererror.Error), http.StatusForbidden)
|
_ = reflector.SetJSONResponse(&deleteWebhook, new(usererror.Error), http.StatusForbidden)
|
||||||
_ = reflector.Spec.AddOperation(http.MethodDelete, "/repos/{repo_ref}/webhooks/{webhook_id}", deleteWebhook)
|
_ = reflector.Spec.AddOperation(http.MethodDelete, "/repos/{repo_ref}/webhooks/{webhook_identifier}", deleteWebhook)
|
||||||
|
|
||||||
listWebhookExecutions := openapi3.Operation{}
|
listWebhookExecutions := openapi3.Operation{}
|
||||||
listWebhookExecutions.WithTags("webhook")
|
listWebhookExecutions.WithTags("webhook")
|
||||||
@ -181,7 +181,7 @@ func webhookOperations(reflector *openapi3.Reflector) {
|
|||||||
_ = reflector.SetJSONResponse(&listWebhookExecutions, new(usererror.Error), http.StatusUnauthorized)
|
_ = reflector.SetJSONResponse(&listWebhookExecutions, new(usererror.Error), http.StatusUnauthorized)
|
||||||
_ = reflector.SetJSONResponse(&listWebhookExecutions, new(usererror.Error), http.StatusForbidden)
|
_ = reflector.SetJSONResponse(&listWebhookExecutions, new(usererror.Error), http.StatusForbidden)
|
||||||
_ = reflector.Spec.AddOperation(http.MethodGet,
|
_ = reflector.Spec.AddOperation(http.MethodGet,
|
||||||
"/repos/{repo_ref}/webhooks/{webhook_id}/executions", listWebhookExecutions)
|
"/repos/{repo_ref}/webhooks/{webhook_identifier}/executions", listWebhookExecutions)
|
||||||
|
|
||||||
getWebhookExecution := openapi3.Operation{}
|
getWebhookExecution := openapi3.Operation{}
|
||||||
getWebhookExecution.WithTags("webhook")
|
getWebhookExecution.WithTags("webhook")
|
||||||
@ -194,5 +194,17 @@ func webhookOperations(reflector *openapi3.Reflector) {
|
|||||||
_ = reflector.SetJSONResponse(&getWebhookExecution, new(usererror.Error), http.StatusUnauthorized)
|
_ = reflector.SetJSONResponse(&getWebhookExecution, new(usererror.Error), http.StatusUnauthorized)
|
||||||
_ = reflector.SetJSONResponse(&getWebhookExecution, new(usererror.Error), http.StatusForbidden)
|
_ = reflector.SetJSONResponse(&getWebhookExecution, new(usererror.Error), http.StatusForbidden)
|
||||||
_ = reflector.Spec.AddOperation(http.MethodGet,
|
_ = reflector.Spec.AddOperation(http.MethodGet,
|
||||||
"/repos/{repo_ref}/webhooks/{webhook_id}/executions/{webhook_execution_id}", getWebhookExecution)
|
"/repos/{repo_ref}/webhooks/{webhook_identifier}/executions/{webhook_execution_id}", getWebhookExecution)
|
||||||
|
|
||||||
|
retriggerWebhookExecution := openapi3.Operation{}
|
||||||
|
retriggerWebhookExecution.WithTags("webhook")
|
||||||
|
retriggerWebhookExecution.WithMapOfAnything(map[string]interface{}{"operationId": "retriggerWebhookExecution"})
|
||||||
|
_ = reflector.SetRequest(&retriggerWebhookExecution, nil, http.MethodPost)
|
||||||
|
_ = reflector.SetJSONResponse(&retriggerWebhookExecution, new(types.WebhookExecution), http.StatusOK)
|
||||||
|
_ = reflector.SetJSONResponse(&retriggerWebhookExecution, new(usererror.Error), http.StatusBadRequest)
|
||||||
|
_ = reflector.SetJSONResponse(&retriggerWebhookExecution, new(usererror.Error), http.StatusInternalServerError)
|
||||||
|
_ = reflector.SetJSONResponse(&retriggerWebhookExecution, new(usererror.Error), http.StatusUnauthorized)
|
||||||
|
_ = reflector.SetJSONResponse(&retriggerWebhookExecution, new(usererror.Error), http.StatusForbidden)
|
||||||
|
_ = reflector.Spec.AddOperation(http.MethodGet,
|
||||||
|
"/repos/{repo_ref}/webhooks/{webhook_identifier}/executions/{webhook_execution_id}", retriggerWebhookExecution)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user