feat: adding studio resource endpoints (#71)

This commit is contained in:
paranarimasu
2023-03-05 01:37:04 -06:00
committed by Maniload
parent cfacf1c94f
commit 3cd96205d8
8 changed files with 312 additions and 0 deletions
+13
View File
@@ -109,6 +109,7 @@ export default {
{ text: 'Song', link: '/wiki/song/' },
{ text: 'Studio', link: '/wiki/studio/' },
{ text: 'Studio Image', link: '/wiki/studioimage/' },
{ text: 'Studio Resource', link: '/wiki/studioresource/' },
{ text: 'Video', link: '/wiki/video/' },
{ text: 'Video Script', link: '/wiki/videoscript/' }
]
@@ -513,6 +514,18 @@ export default {
{ text: 'Store', link: '/wiki/studioimage/store/' }
]
},
{
text: 'Studio Resource',
collapsible: true,
items: [
{ text: 'Resource', link: '/wiki/studioresource/' },
{ text: 'Destroy', link: '/wiki/studioresource/destroy/' },
{ text: 'Index', link: '/wiki/studioresource/index/' },
{ text: 'Show', link: '/wiki/studioresource/show/' },
{ text: 'Store', link: '/wiki/studioresource/store/' },
{ text: 'Update', link: '/wiki/studioresource/update/' }
]
},
{
text: 'Video',
collapsible: true,
+4
View File
@@ -82,6 +82,10 @@ A studio API resource represents a company that produces anime.
A studio image API resource represents the association between a studio and an image.
**[Studio Resource](/wiki/studioresource/)**
A studio resource API resource represents the association between a studio and an external resource.
**[Video](/wiki/video/)**
A video API resource represents a WebM of an anime theme.
+39
View File
@@ -0,0 +1,39 @@
---
title: Studio Resource Destroy
---
# Studio Resource Destroy Endpoint
The studio resource destroy endpoint deletes a studio resource and returns the deleted studio resource resource.
For example, the `/studioresource/shaft/14891` endpoint will delete the association between the Shaft studio and the external resource of id 14891.
## URL
```sh
DELETE /studioresource/{studio:slug}/{resource:id}
```
## Authentication
**Required Permission**: delete studio, delete external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
None
## Response
```json
{
message: "Resource 'https://myanimelist.net/anime/producer/44' has been detached from Studio 'Shaft'.",
}
```
## Example
```bash
curl -X DELETE -H "Authorization: Bearer {token}" https://api.animethemes.moe/studioresource/shaft/14891
```
+44
View File
@@ -0,0 +1,44 @@
---
title: Studio Resource
---
# Studio Resource
---
A studio resource API resource represents the association between a studio and an external resource.
## Fields
| Name | Type | Nullable | Description |
| :--------: | :-----: | :------: | :-------------------------------------------------------- |
| created_at | Date | No | The date that the resource was created |
| updated_at | Date | No | The date that the resource was last modified |
| as | String | No | Used to distinguish resources that map to the same studio |
## Allowed Include Paths
* studio
* resource
## Endpoints
**[Studio Resource Destroy](/wiki/studioresource/destroy/)**
The studio resource destroy endpoint deletes a studio resource and returns the deleted studio resource resource.
**[Studio Resource Index](/wiki/studioresource/index/)**
The studio resource index endpoint displays a listing of studio resource resources.
**[Studio Resource Show](/wiki/studioresource/show/)**
The studio resource show endpoint returns a studio resource resource.
**[Studio Resource Store](/wiki/studioresource/store/)**
The studio resource store endpoint creates a new studio resource and returns the new studio resource resource.
**[Studio Resource Update](/wiki/studioresource/update/)**
The studio update endpoint updates a studio resource and returns the updated studio resource resource.
+79
View File
@@ -0,0 +1,79 @@
---
title: Studio Resource Index
---
# Studio Resource Index Endpoint
The studio resource index endpoint returns a listing of studio resource resources.
## URL
```sh
GET /studioresource/
```
## Authentication
None
## Parameters
| Name | Required | Description |
| :----------: | :------: | :----------------------------------------------------------------------------- |
| fields | No | Sparse fieldsets for resource types |
| filter | No | Filters for studio resources & constraining the inclusion of related resources |
| include | No | Inclusion of related resources |
| page[number] | No | The page of studio resource resources to display |
| page[size] | No | The number of studio resource resources to display for the current page |
| sort | No | The list of fields to sort the resources |
## Allowed Sort Fields
| Name | Description |
| :--------: | :------------------------------------------------ |
| created_at | Sort resources on the resource creation date |
| updated_at | Sort resources on the resource last modified date |
| as | Sort resources on distinguishing label |
## Filters
| Name | Description |
| :--------: | :--------------------------------------------------------- |
| created_at | Filter resources on the resource creation date |
| updated_at | Filter resources on the resource last modified date |
| as | Filter resources on the resource distinguishing label |
| has | Filter resources on relations within allowed include paths |
## Response
```json
{
studioresources: [
{
created_at: "created_at",
updated_at: "updated_at",
as: "as"
},
...
],
links: {
first: "first",
last: "last",
prev: "prev",
next: "next"
},
meta: {
current_page: current_page,
from: from,
path: "path",
per_page: per_page,
to: to
}
}
```
## Example
```bash
curl https://api.animethemes.moe/studioresource/
```
+41
View File
@@ -0,0 +1,41 @@
---
title: Studio Resource Show
---
# Studio Resource Show Endpoint
The studio resource show endpoint returns a studio resource resource.
For example, the `/studioresource/shaft/14891` endpoint will return the studio resource resource for the association between the Shaft studio and the external resource of id 14891.
## URL
```sh
GET /studioresource/{studio:slug}/{resource:id}
```
## Authentication
None
## Parameters
None
## Response
```json
{
studioresource: {
created_at: "created_at",
updated_at: "updated_at",
as: "as"
}
}
```
## Example
```bash
curl https://api.animethemes.moe/studioresource/shaft/14891
```
+47
View File
@@ -0,0 +1,47 @@
---
title: Studio Resource Store
---
# Studio Resource Store Endpoint
The studio resource store endpoint creates a new studio resource and returns the new studio resource resource.
For example, the `/studioresource?studio_id=11&resource_id=14891` endpoint will create a new association between the Shaft studio and the external resource of id 14891.
## URL
```sh
POST /studioresource
```
## Authentication
**Required Permission**: create studio, create external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :---------: | :------: | :-------------------------- |
| studio_id | Yes | integer, Studio ID exists |
| resource_id | Yes | integer, Resource ID exists |
| as | No | string, max:192 |
## Response
```json
{
studioresource: {
created_at: "created_at",
updated_at: "updated_at",
as: "as"
}
}
```
## Example
```bash
curl -X POST -H "Authorization: Bearer {token}" https://api.animethemes.moe/studioresource/
```
+45
View File
@@ -0,0 +1,45 @@
---
title: Studio Resource Update
---
# Studio Resource Update Endpoint
The studio resource store endpoint updates a studio resource and returns the updated studio resource resource.
For example, the `/studioresource/shaft/14891?as=updated+label` endpoint will update the association between the Shaft studio and the external resource of id 14891.
## URL
```sh
PUT|PATCH /studioresource/{studio:slug}/{resource:id}
```
## Authentication
**Required Permission**: update studio, update external resource
**Roles with Permission**: Wiki Editor, Admin
## Parameters
| Name | Required | Rules |
| :---------: | :------: | :-------------- |
| as | No | string, max:192 |
## Response
```json
{
studioresource: {
created_at: "created_at",
updated_at: "updated_at",
as: "as"
}
}
```
## Example
```bash
curl -X PATCH -H "Authorization: Bearer {token}" https://api.animethemes.moe/studioresource/
```