feat: adding resource write endpoints (#30)

This commit is contained in:
paranarimasu
2022-06-11 09:34:50 -05:00
committed by GitHub
parent 73145b6ad2
commit 16aefdf447
7 changed files with 369 additions and 114 deletions
+18 -2
View File
@@ -251,12 +251,28 @@ module.exports = {
to: '/resource',
children: [
{
title: 'Show',
to: '/resource/show/',
title: 'Destroy',
to: '/resource/destroy/'
},
{
title: 'Force Delete',
to: '/resource/forceDelete/'
},
{
title: 'Index',
to: '/resource/index/'
},
{
title: 'Show',
to: '/resource/show/',
},
{
title: 'Store',
to: '/resource/store/',
},
{
title: 'Update',
to: '/resource/update/',
}
]
},
+18 -2
View File
@@ -31,10 +31,26 @@ For example, the Bakemonogatari anime has MyAnimeList, AniList and AniDB resourc
### Endpoints
**[Resource Destroy](/resource/destroy/)**
The resource destroy endpoint soft deletes an external resource and returns the deleted external resource.
**[Resource Force Delete](/resource/forceDelete/)**
The resource force delete endpoint hard deletes an external resource and returns a confirmation message.
**[Resource Index](/resource/index/)**
The resource index endpoint returns a listing of external resources.
**[Resource Show](/resource/show/)**
The resource show endpoint returns an external resource.
**[Resource Index](/resource/index/)**
**[Resource Store](/resource/store/)**
The resource index endpoint displays a listing of external resources.
The resource store endpoint creates a new external resource and returns the new external resource.
**[Resource Update](/resource/update/)**
The resource update endpoint updates an external resource and returns the updated external resource.
+56
View File
@@ -0,0 +1,56 @@
---
title: Resource Destroy
---
<Block>
# Resource Destroy Endpoint
The resource destroy endpoint soft deletes an external resource and returns the deleted external resource.
For example, the `/api/resource/1083` endpoint will soft delete the MyAnimeList resource for the Bakemonogatari anime and return the deleted MyAnimeList resource.
## URL
```sh
DELETE /api/resource/{id}
```
## Authentication
**Required Permission**: delete external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
None
## Response
```json
{
resource: {
id: id,
link: "link",
external_id: external_id,
site: "site",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at",
link: "link"
}
}
```
<Example>
<CURL>
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/resource/1083
```
</CURL>
</Example>
</Block>
+47
View File
@@ -0,0 +1,47 @@
---
title: Resource Force Delete
---
<Block>
# Resource Force Delete Endpoint
The resource force delete endpoint hard deletes an external resource and returns a confirmation message.
For example, the `/api/forceDelete/resource/1083` endpoint will hard delete the MyAnimeList resource for the Bakemonogatari anime and return a confirmation message.
## URL
```sh
DELETE /api/forceDelete/resource/{id}
```
## Authentication
**Required Permission**: force delete external resource
**Roles with Permission**: Admin
## Parameters
None
## Response
```json
{
message: "The ExternalResource 'https://myanimelist.net/anime/5081/' was deleted.",
}
```
<Example>
<CURL>
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/forceDelete/resource/1083
```
</CURL>
</Example>
</Block>
+60
View File
@@ -0,0 +1,60 @@
---
title: Resource Store
---
<Block>
# Resource Store Endpoint
The resource store endpoint creates a new external resource and returns the new external resource.
For example, the `/api/resource?link=https%3A%2F%2Fmyanimelist.net%2Fanime%2F5081%2F&site=MyAnimeList` endpoint will create a new MyAnimeList resource for the Bakemonogatari anime and return the new MyAnimeList resource.
## URL
```sh
POST /api/resource
```
## Authentication
**Required Permission**: create external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :---------: | :------: | :--------------------------------------------------------------------------------------------------------------------- |
| link | Yes | max:192, url, link matches site |
| external_id | No | integer, min:0 |
| site | Yes | EnumValue {Official Website, Twitter, AniDB, Anilist, Anime-Planet, Anime News Network, Kitsu, MyAnimeList, Wikipedia} |
## Response
```json
{
resource: {
id: id,
link: "link",
external_id: external_id,
site: "site",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at",
link: "link"
}
}
```
<Example>
<CURL>
```bash
curl -X POST -H "Authorization: Bearer {token}" https://api.animethemes.moe/resource/
```
</CURL>
</Example>
</Block>
+60
View File
@@ -0,0 +1,60 @@
---
title: Resource Update
---
<Block>
# Resource Update Endpoint
The resource update endpoint updates an external resource and returns the updated external resource.
For example, the `/api/resource/1083?external_id=5081` endpoint will update the external resource external_id attribute and return the updated external resource.
## URL
```sh
PUT|PATCH /api/resource/{id}
```
## Authentication
**Required Permission**: update external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :---------: | :------: | :--------------------------------------------------------------------------------------------------------------------- |
| link | No | max:192, url, link matches site |
| external_id | No | integer, min:0 |
| site | No | EnumValue {Official Website, Twitter, AniDB, Anilist, Anime-Planet, Anime News Network, Kitsu, MyAnimeList, Wikipedia} |
## Response
```json
{
resource: {
id: id,
link: "link",
external_id: external_id,
site: "site",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at",
link: "link"
}
}
```
<Example>
<CURL>
```bash
curl -X PATCH -H "Authorization: Bearer {token}" https://api.animethemes.moe/resource/1083
```
</CURL>
</Example>
</Block>