docs(webhooks): add swagger docs for all webhook endpoints
This commit is contained in:
parent
35e8183f6a
commit
2c84cec044
@ -122,9 +122,9 @@ func HashToken(token, salt string) string {
|
|||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Security JWTKeyAuth
|
// @Security JWTKeyAuth
|
||||||
// @Param page query int false "The page number for tasks. Used for pagination. If not provided, the first page of results is returned."
|
// @Param page query int false "The page number, used for pagination. If not provided, the first page of results is returned."
|
||||||
// @Param per_page query int false "The maximum number of tasks per bucket per page. This parameter is limited by the configured maximum of items per page."
|
// @Param per_page query int false "The maximum number of tokens per page. This parameter is limited by the configured maximum of items per page."
|
||||||
// @Param s query string false "Search tasks by task text."
|
// @Param s query string false "Search tokens by their title."
|
||||||
// @Success 200 {array} models.APIToken "The list of all tokens"
|
// @Success 200 {array} models.APIToken "The list of all tokens"
|
||||||
// @Failure 500 {object} models.Message "Internal server error"
|
// @Failure 500 {object} models.Message "Internal server error"
|
||||||
// @Router /tokens [get]
|
// @Router /tokens [get]
|
||||||
|
@ -40,11 +40,16 @@ import (
|
|||||||
var webhookClient *http.Client
|
var webhookClient *http.Client
|
||||||
|
|
||||||
type Webhook struct {
|
type Webhook struct {
|
||||||
ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"webhook"`
|
// The generated ID of this webhook target
|
||||||
TargetURL string `xorm:"not null" valid:"minstringlength(1)" minLength:"1" json:"target_url"`
|
ID int64 `xorm:"bigint autoincr not null unique pk" json:"id" param:"webhook"`
|
||||||
Events []string `xorm:"JSON not null" valid:"minstringlength(1)" minLength:"1" json:"events"`
|
// The target URL where the POST request with the webhook payload will be made
|
||||||
ProjectID int64 `xorm:"bigint not null index" json:"project_id" param:"project"`
|
TargetURL string `xorm:"not null" valid:"minstringlength(1)" minLength:"1" json:"target_url"`
|
||||||
Secret string `xorm:"null" json:"secret"`
|
// The webhook events which should fire this webhook target
|
||||||
|
Events []string `xorm:"JSON not null" valid:"minstringlength(1)" minLength:"1" json:"events"`
|
||||||
|
// The project ID of the project this webhook target belongs to
|
||||||
|
ProjectID int64 `xorm:"bigint not null index" json:"project_id" param:"project"`
|
||||||
|
// If provided, webhook requests will be signed using HMAC. Check out the docs about how to use this: https://vikunja.io/docs/webhooks/#signing
|
||||||
|
Secret string `xorm:"null" json:"secret"`
|
||||||
|
|
||||||
// The user who initially created the webhook target.
|
// The user who initially created the webhook target.
|
||||||
CreatedBy *user.User `xorm:"-" json:"created_by" valid:"-"`
|
CreatedBy *user.User `xorm:"-" json:"created_by" valid:"-"`
|
||||||
@ -92,6 +97,19 @@ func GetAvailableWebhookEvents() []string {
|
|||||||
return evts
|
return evts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create creates a webhook target
|
||||||
|
// @Summary Create a webhook target
|
||||||
|
// @Description Create a webhook target which recieves POST requests about specified events from a project.
|
||||||
|
// @tags webhooks
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Param id path int true "Project ID"
|
||||||
|
// @Param webhook body models.Webhook true "The webhook target object with required fields"
|
||||||
|
// @Success 200 {object} models.Webhook "The created webhook target."
|
||||||
|
// @Failure 400 {object} web.HTTPError "Invalid webhook object provided."
|
||||||
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
|
// @Router /projects/{id}/webhooks [put]
|
||||||
func (w *Webhook) Create(s *xorm.Session, a web.Auth) (err error) {
|
func (w *Webhook) Create(s *xorm.Session, a web.Auth) (err error) {
|
||||||
// TODO: check valid webhook events
|
// TODO: check valid webhook events
|
||||||
w.CreatedByID = a.GetID()
|
w.CreatedByID = a.GetID()
|
||||||
@ -99,6 +117,19 @@ func (w *Webhook) Create(s *xorm.Session, a web.Auth) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadAll returns all webhook targets for a project
|
||||||
|
// @Summary Get all api webhook targets for the specified project
|
||||||
|
// @Description Get all api webhook targets for the specified project.
|
||||||
|
// @tags webhooks
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Param page query int false "The page number. Used for pagination. If not provided, the first page of results is returned."
|
||||||
|
// @Param per_page query int false "The maximum number of items per bucket per page. This parameter is limited by the configured maximum of items per page."
|
||||||
|
// @Param id path int true "Project ID"
|
||||||
|
// @Success 200 {array} models.Webhook "The list of all webhook targets"
|
||||||
|
// @Failure 500 {object} models.Message "Internal server error"
|
||||||
|
// @Router /projects/{id}/webhooks [get]
|
||||||
func (w *Webhook) ReadAll(s *xorm.Session, a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) {
|
func (w *Webhook) ReadAll(s *xorm.Session, a web.Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error) {
|
||||||
p := &Project{ID: w.ProjectID}
|
p := &Project{ID: w.ProjectID}
|
||||||
can, _, err := p.CanRead(s, a)
|
can, _, err := p.CanRead(s, a)
|
||||||
@ -126,6 +157,19 @@ func (w *Webhook) ReadAll(s *xorm.Session, a web.Auth, search string, page int,
|
|||||||
return ws, len(ws), total, err
|
return ws, len(ws), total, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update updates a webhook target
|
||||||
|
// @Summary Change a webhook target's events.
|
||||||
|
// @Description Change a webhook target's events. You cannot change other values of a webhook.
|
||||||
|
// @tags webhooks
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Param id path int true "Project ID"
|
||||||
|
// @Param webhookID path int true "Webhook ID"
|
||||||
|
// @Success 200 {object} models.Webhook "Updated webhook target"
|
||||||
|
// @Failure 404 {object} web.HTTPError "The webhok target does not exist"
|
||||||
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
|
// @Router /projects/{id}/webhooks/{webhookID} [post]
|
||||||
func (w *Webhook) Update(s *xorm.Session, a web.Auth) (err error) {
|
func (w *Webhook) Update(s *xorm.Session, a web.Auth) (err error) {
|
||||||
// TODO validate webhook events
|
// TODO validate webhook events
|
||||||
_, err = s.Where("id = ?", w.ID).
|
_, err = s.Where("id = ?", w.ID).
|
||||||
@ -134,6 +178,19 @@ func (w *Webhook) Update(s *xorm.Session, a web.Auth) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete deletes a webhook target
|
||||||
|
// @Summary Deletes an existing webhook target
|
||||||
|
// @Description Delete any of the project's webhook targets.
|
||||||
|
// @tags webhooks
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Param id path int true "Project ID"
|
||||||
|
// @Param webhookID path int true "Webhook ID"
|
||||||
|
// @Success 200 {object} models.Message "Successfully deleted."
|
||||||
|
// @Failure 404 {object} web.HTTPError "The webhok target does not exist."
|
||||||
|
// @Failure 500 {object} models.Message "Internal error"
|
||||||
|
// @Router /projects/{id}/webhooks/{webhookID} [delete]
|
||||||
func (w *Webhook) Delete(s *xorm.Session, a web.Auth) (err error) {
|
func (w *Webhook) Delete(s *xorm.Session, a web.Auth) (err error) {
|
||||||
_, err = s.Where("id = ?", w.ID).Delete(&Webhook{})
|
_, err = s.Where("id = ?", w.ID).Delete(&Webhook{})
|
||||||
return
|
return
|
||||||
|
@ -22,6 +22,16 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetAvailableWebhookEvents returns a list of all possible webhook target events
|
||||||
|
// @Summary Get all possible webhook events
|
||||||
|
// @Description Get all possible webhook events to use when creating or updating a webhook target.
|
||||||
|
// @tags webhooks
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Security JWTKeyAuth
|
||||||
|
// @Success 200 {array} string "The list of all possible webhook events"
|
||||||
|
// @Failure 500 {object} models.Message "Internal server error"
|
||||||
|
// @Router /webhooks/events [get]
|
||||||
func GetAvailableWebhookEvents(c echo.Context) error {
|
func GetAvailableWebhookEvents(c echo.Context) error {
|
||||||
return c.JSON(http.StatusOK, models.GetAvailableWebhookEvents())
|
return c.JSON(http.StatusOK, models.GetAvailableWebhookEvents())
|
||||||
}
|
}
|
||||||
|
@ -2425,6 +2425,230 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/projects/{id}/webhooks": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Get all api webhook targets for the specified project.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Get all api webhook targets for the specified project",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The page number. Used for pagination. If not provided, the first page of results is returned.",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The maximum number of items per bucket per page. This parameter is limited by the configured maximum of items per page.",
|
||||||
|
"name": "per_page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "The list of all webhook targets",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Create a webhook target which recieves POST requests about specified events from a project.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Create a webhook target",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "The webhook target object with required fields",
|
||||||
|
"name": "webhook",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "The created webhook target.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Invalid webhook object provided.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/web.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/projects/{id}/webhooks/{webhookID}": {
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Change a webhook target's events. You cannot change other values of a webhook.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Change a webhook target's events.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Webhook ID",
|
||||||
|
"name": "webhookID",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Updated webhook target",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "The webhok target does not exist",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/web.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Delete any of the project's webhook targets.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Deletes an existing webhook target",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Webhook ID",
|
||||||
|
"name": "webhookID",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successfully deleted.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "The webhok target does not exist.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/web.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/projects/{projectID}/buckets/{bucketID}": {
|
"/projects/{projectID}/buckets/{bucketID}": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@ -5427,19 +5651,19 @@ const docTemplate = `{
|
|||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "The page number for tasks. Used for pagination. If not provided, the first page of results is returned.",
|
"description": "The page number, used for pagination. If not provided, the first page of results is returned.",
|
||||||
"name": "page",
|
"name": "page",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "The maximum number of tasks per bucket per page. This parameter is limited by the configured maximum of items per page.",
|
"description": "The maximum number of tokens per page. This parameter is limited by the configured maximum of items per page.",
|
||||||
"name": "per_page",
|
"name": "per_page",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Search tasks by task text.",
|
"description": "Search tokens by their title.",
|
||||||
"name": "s",
|
"name": "s",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
}
|
}
|
||||||
@ -6783,6 +7007,43 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/webhooks/events": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Get all possible webhook events to use when creating or updating a webhook target.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Get all possible webhook events",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "The list of all possible webhook events",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/{username}/avatar": {
|
"/{username}/avatar": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Returns the user avatar as image.",
|
"description": "Returns the user avatar as image.",
|
||||||
@ -8188,6 +8449,52 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"models.Webhook": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"created": {
|
||||||
|
"description": "A timestamp when this webhook target was created. You cannot change this value.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"created_by": {
|
||||||
|
"description": "The user who initially created the webhook target.",
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/user.User"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"events": {
|
||||||
|
"description": "The webhook events which should fire this webhook target",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"description": "The generated ID of this webhook target",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"project_id": {
|
||||||
|
"description": "The project ID of the project this webhook target belongs to",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"secret": {
|
||||||
|
"description": "If provided, webhook requests will be signed using HMAC. Check out the docs about how to use this: https://vikunja.io/docs/webhooks/#signing",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"target_url": {
|
||||||
|
"description": "The target URL where the POST request with the webhook payload will be made",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"updated": {
|
||||||
|
"description": "A timestamp when this webhook target was last updated. You cannot change this value.",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"notifications.DatabaseNotification": {
|
"notifications.DatabaseNotification": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -8618,6 +8925,9 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"webhooks_enabled": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2417,6 +2417,230 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/projects/{id}/webhooks": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Get all api webhook targets for the specified project.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Get all api webhook targets for the specified project",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The page number. Used for pagination. If not provided, the first page of results is returned.",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "The maximum number of items per bucket per page. This parameter is limited by the configured maximum of items per page.",
|
||||||
|
"name": "per_page",
|
||||||
|
"in": "query"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "The list of all webhook targets",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"put": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Create a webhook target which recieves POST requests about specified events from a project.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Create a webhook target",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "The webhook target object with required fields",
|
||||||
|
"name": "webhook",
|
||||||
|
"in": "body",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "The created webhook target.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Invalid webhook object provided.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/web.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/projects/{id}/webhooks/{webhookID}": {
|
||||||
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Change a webhook target's events. You cannot change other values of a webhook.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Change a webhook target's events.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Webhook ID",
|
||||||
|
"name": "webhookID",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Updated webhook target",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Webhook"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "The webhok target does not exist",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/web.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Delete any of the project's webhook targets.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Deletes an existing webhook target",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Project ID",
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Webhook ID",
|
||||||
|
"name": "webhookID",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "Successfully deleted.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "The webhok target does not exist.",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/web.HTTPError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/projects/{projectID}/buckets/{bucketID}": {
|
"/projects/{projectID}/buckets/{bucketID}": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@ -5419,19 +5643,19 @@
|
|||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "The page number for tasks. Used for pagination. If not provided, the first page of results is returned.",
|
"description": "The page number, used for pagination. If not provided, the first page of results is returned.",
|
||||||
"name": "page",
|
"name": "page",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "The maximum number of tasks per bucket per page. This parameter is limited by the configured maximum of items per page.",
|
"description": "The maximum number of tokens per page. This parameter is limited by the configured maximum of items per page.",
|
||||||
"name": "per_page",
|
"name": "per_page",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Search tasks by task text.",
|
"description": "Search tokens by their title.",
|
||||||
"name": "s",
|
"name": "s",
|
||||||
"in": "query"
|
"in": "query"
|
||||||
}
|
}
|
||||||
@ -6775,6 +6999,43 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/webhooks/events": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"JWTKeyAuth": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Get all possible webhook events to use when creating or updating a webhook target.",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"webhooks"
|
||||||
|
],
|
||||||
|
"summary": "Get all possible webhook events",
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "The list of all possible webhook events",
|
||||||
|
"schema": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"500": {
|
||||||
|
"description": "Internal server error",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/models.Message"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/{username}/avatar": {
|
"/{username}/avatar": {
|
||||||
"get": {
|
"get": {
|
||||||
"description": "Returns the user avatar as image.",
|
"description": "Returns the user avatar as image.",
|
||||||
@ -8180,6 +8441,52 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"models.Webhook": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"created": {
|
||||||
|
"description": "A timestamp when this webhook target was created. You cannot change this value.",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"created_by": {
|
||||||
|
"description": "The user who initially created the webhook target.",
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/user.User"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"events": {
|
||||||
|
"description": "The webhook events which should fire this webhook target",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
"description": "The generated ID of this webhook target",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"project_id": {
|
||||||
|
"description": "The project ID of the project this webhook target belongs to",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"secret": {
|
||||||
|
"description": "If provided, webhook requests will be signed using HMAC. Check out the docs about how to use this: https://vikunja.io/docs/webhooks/#signing",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"target_url": {
|
||||||
|
"description": "The target URL where the POST request with the webhook payload will be made",
|
||||||
|
"type": "string",
|
||||||
|
"minLength": 1
|
||||||
|
},
|
||||||
|
"updated": {
|
||||||
|
"description": "A timestamp when this webhook target was last updated. You cannot change this value.",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"notifications.DatabaseNotification": {
|
"notifications.DatabaseNotification": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -8610,6 +8917,9 @@
|
|||||||
},
|
},
|
||||||
"version": {
|
"version": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"webhooks_enabled": {
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1040,6 +1040,42 @@ definitions:
|
|||||||
minLength: 1
|
minLength: 1
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
models.Webhook:
|
||||||
|
properties:
|
||||||
|
created:
|
||||||
|
description: A timestamp when this webhook target was created. You cannot
|
||||||
|
change this value.
|
||||||
|
type: string
|
||||||
|
created_by:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/user.User'
|
||||||
|
description: The user who initially created the webhook target.
|
||||||
|
events:
|
||||||
|
description: The webhook events which should fire this webhook target
|
||||||
|
items:
|
||||||
|
minLength: 1
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
id:
|
||||||
|
description: The generated ID of this webhook target
|
||||||
|
type: integer
|
||||||
|
project_id:
|
||||||
|
description: The project ID of the project this webhook target belongs to
|
||||||
|
type: integer
|
||||||
|
secret:
|
||||||
|
description: 'If provided, webhook requests will be signed using HMAC. Check
|
||||||
|
out the docs about how to use this: https://vikunja.io/docs/webhooks/#signing'
|
||||||
|
type: string
|
||||||
|
target_url:
|
||||||
|
description: The target URL where the POST request with the webhook payload
|
||||||
|
will be made
|
||||||
|
minLength: 1
|
||||||
|
type: string
|
||||||
|
updated:
|
||||||
|
description: A timestamp when this webhook target was last updated. You cannot
|
||||||
|
change this value.
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
notifications.DatabaseNotification:
|
notifications.DatabaseNotification:
|
||||||
properties:
|
properties:
|
||||||
created:
|
created:
|
||||||
@ -1352,6 +1388,8 @@ definitions:
|
|||||||
type: boolean
|
type: boolean
|
||||||
version:
|
version:
|
||||||
type: string
|
type: string
|
||||||
|
webhooks_enabled:
|
||||||
|
type: boolean
|
||||||
type: object
|
type: object
|
||||||
web.HTTPError:
|
web.HTTPError:
|
||||||
properties:
|
properties:
|
||||||
@ -3004,6 +3042,154 @@ paths:
|
|||||||
summary: Add a user to a project
|
summary: Add a user to a project
|
||||||
tags:
|
tags:
|
||||||
- sharing
|
- sharing
|
||||||
|
/projects/{id}/webhooks:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Get all api webhook targets for the specified project.
|
||||||
|
parameters:
|
||||||
|
- description: The page number. Used for pagination. If not provided, the first
|
||||||
|
page of results is returned.
|
||||||
|
in: query
|
||||||
|
name: page
|
||||||
|
type: integer
|
||||||
|
- description: The maximum number of items per bucket per page. This parameter
|
||||||
|
is limited by the configured maximum of items per page.
|
||||||
|
in: query
|
||||||
|
name: per_page
|
||||||
|
type: integer
|
||||||
|
- description: Project ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: The list of all webhook targets
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/models.Webhook'
|
||||||
|
type: array
|
||||||
|
"500":
|
||||||
|
description: Internal server error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Message'
|
||||||
|
security:
|
||||||
|
- JWTKeyAuth: []
|
||||||
|
summary: Get all api webhook targets for the specified project
|
||||||
|
tags:
|
||||||
|
- webhooks
|
||||||
|
put:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Create a webhook target which recieves POST requests about specified
|
||||||
|
events from a project.
|
||||||
|
parameters:
|
||||||
|
- description: Project ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: The webhook target object with required fields
|
||||||
|
in: body
|
||||||
|
name: webhook
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Webhook'
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: The created webhook target.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Webhook'
|
||||||
|
"400":
|
||||||
|
description: Invalid webhook object provided.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/web.HTTPError'
|
||||||
|
"500":
|
||||||
|
description: Internal error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Message'
|
||||||
|
security:
|
||||||
|
- JWTKeyAuth: []
|
||||||
|
summary: Create a webhook target
|
||||||
|
tags:
|
||||||
|
- webhooks
|
||||||
|
/projects/{id}/webhooks/{webhookID}:
|
||||||
|
delete:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Delete any of the project's webhook targets.
|
||||||
|
parameters:
|
||||||
|
- description: Project ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: Webhook ID
|
||||||
|
in: path
|
||||||
|
name: webhookID
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Successfully deleted.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Message'
|
||||||
|
"404":
|
||||||
|
description: The webhok target does not exist.
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/web.HTTPError'
|
||||||
|
"500":
|
||||||
|
description: Internal error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Message'
|
||||||
|
security:
|
||||||
|
- JWTKeyAuth: []
|
||||||
|
summary: Deletes an existing webhook target
|
||||||
|
tags:
|
||||||
|
- webhooks
|
||||||
|
post:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Change a webhook target's events. You cannot change other values
|
||||||
|
of a webhook.
|
||||||
|
parameters:
|
||||||
|
- description: Project ID
|
||||||
|
in: path
|
||||||
|
name: id
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- description: Webhook ID
|
||||||
|
in: path
|
||||||
|
name: webhookID
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: Updated webhook target
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Webhook'
|
||||||
|
"404":
|
||||||
|
description: The webhok target does not exist
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/web.HTTPError'
|
||||||
|
"500":
|
||||||
|
description: Internal error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Message'
|
||||||
|
security:
|
||||||
|
- JWTKeyAuth: []
|
||||||
|
summary: Change a webhook target's events.
|
||||||
|
tags:
|
||||||
|
- webhooks
|
||||||
/projects/{project}/shares:
|
/projects/{project}/shares:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
@ -5018,17 +5204,17 @@ paths:
|
|||||||
- application/json
|
- application/json
|
||||||
description: Returns all api tokens the current user has created.
|
description: Returns all api tokens the current user has created.
|
||||||
parameters:
|
parameters:
|
||||||
- description: The page number for tasks. Used for pagination. If not provided,
|
- description: The page number, used for pagination. If not provided, the first
|
||||||
the first page of results is returned.
|
page of results is returned.
|
||||||
in: query
|
in: query
|
||||||
name: page
|
name: page
|
||||||
type: integer
|
type: integer
|
||||||
- description: The maximum number of tasks per bucket per page. This parameter
|
- description: The maximum number of tokens per page. This parameter is limited
|
||||||
is limited by the configured maximum of items per page.
|
by the configured maximum of items per page.
|
||||||
in: query
|
in: query
|
||||||
name: per_page
|
name: per_page
|
||||||
type: integer
|
type: integer
|
||||||
- description: Search tasks by task text.
|
- description: Search tokens by their title.
|
||||||
in: query
|
in: query
|
||||||
name: s
|
name: s
|
||||||
type: string
|
type: string
|
||||||
@ -5901,6 +6087,30 @@ paths:
|
|||||||
summary: Get users
|
summary: Get users
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
|
/webhooks/events:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: Get all possible webhook events to use when creating or updating
|
||||||
|
a webhook target.
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: The list of all possible webhook events
|
||||||
|
schema:
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
type: array
|
||||||
|
"500":
|
||||||
|
description: Internal server error
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/models.Message'
|
||||||
|
security:
|
||||||
|
- JWTKeyAuth: []
|
||||||
|
summary: Get all possible webhook events
|
||||||
|
tags:
|
||||||
|
- webhooks
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
BasicAuth:
|
BasicAuth:
|
||||||
type: basic
|
type: basic
|
||||||
|
Loading…
x
Reference in New Issue
Block a user