gitea/routers/api/v1
Michael B. a90af22003
Let API create and edit system webhooks, attempt 2 (#33180)
This PR fixes inconsistencies between system and default webhooks in the
Gitea API. (See also #26418)
- A system webhook is a webhook that captures events for all
repositories.
- A default webhook is copied to a new repository when it is created. 

Before this PR `POST /api/v1/admin/hooks/` creates default webhooks (if
not configured otherwise) and `GET /api/v1/admin/hooks/` returns system
webhooks.

The PR introduces an optional query parameter to `GET
/api/v1/admin/hooks/` to enable selecting if either default, system or
both kind of webhooks should be retrieved. By default the flag is set to
return system webhooks keep current behaviour.

## Examples

### System Webhooks

#### Create

```
POST /api/v1/admin/hooks/

{
  "type": "gitea",
  "active": false,
  "branch_filter": "*",
  "events": [ "create", "..." ],
  "config": {
    "url": "http://...",
    "content_type": "json",
    "secret": "secret",
    "is_system_webhook": true // <-- controls hook type
  }
}
```

#### List
```
GET/api/v1/admin/hooks?type=system //type argument is optional here since it's the default
```

#### Others
The other relevant endpoints work as expected by referencing the hook by
id
```
GET /api/v1/admin/hooks/:id
PATCH /api/v1/admin/hooks/:id
DELETE /api/v1/admin/hooks/:id
```


### Default Webhooks

#### Create
```
POST /api/v1/admin/hooks/

{
  "type": "gitea",
  "active": false,
  "branch_filter": "*",
  "events": [ "create", "..." ],
  "config": {
    "url": "http://...",
    "content_type": "json",
    "secret": "secret",
    "is_system_webhook": false // optional, as false is the default value
  }
}
```

#### List
```
GET/api/v1/admin/hooks?type=default
```

#### Others
The other relevant endpoints work as expected by referencing the hook by
id
```
GET /api/v1/admin/hooks/:id
PATCH /api/v1/admin/hooks/:id
DELETE /api/v1/admin/hooks/:id
```
2025-01-13 17:17:39 +00:00
..
activitypub Remove SHA1 for support for ssh rsa signing (#31857) 2024-09-07 18:05:18 -04:00
admin Let API create and edit system webhooks, attempt 2 (#33180) 2025-01-13 17:17:39 +00:00
misc Fix markup render regression and fix some tests (#32640) 2024-11-26 03:04:55 +08:00
notify Clarify path param naming (#32969) 2024-12-24 13:47:45 +00:00
org Clarify path param naming (#32969) 2024-12-24 13:47:45 +00:00
packages remove util.OptionalBool and related functions (#29513) 2024-03-02 16:42:31 +01:00
repo Refactor context RefName and RepoAssignment (#33226) 2025-01-13 01:07:05 +00:00
settings Move context from modules to services (#29440) 2024-02-27 08:12:22 +01:00
shared Refactor names (#31405) 2024-06-19 06:32:45 +08:00
swagger Fix sync fork for consistency (#33147) 2025-01-10 05:29:55 +00:00
user Clarify path param naming (#32969) 2024-12-24 13:47:45 +00:00
utils Move admin routers from /admin to /-/admin (#32189) 2024-10-10 04:56:49 +00:00
api.go Fix sync fork for consistency (#33147) 2025-01-10 05:29:55 +00:00