[Swagger] Update Webhook URLs to webhook_identifier and add retrigger execution operation (#1019)

This commit is contained in:
Johannes Batzill 2024-02-03 01:59:47 +00:00 committed by Harness
parent f482ec08c4
commit b173a7cbec

View File

@ -44,7 +44,7 @@ type listWebhooksRequest struct {
type webhookRequest struct {
repoRequest
ID int64 `path:"webhook_id"`
ID int64 `path:"webhook_identifier"`
}
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.StatusUnauthorized)
_ = 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.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.StatusUnauthorized)
_ = 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.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.StatusUnauthorized)
_ = 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.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.StatusForbidden)
_ = 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.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.StatusForbidden)
_ = 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)
}