From 3cd96205d856b04649371faee37cf65e66d26ee4 Mon Sep 17 00:00:00 2001 From: paranarimasu <33796518+paranarimasu@users.noreply.github.com> Date: Sun, 5 Mar 2023 01:37:04 -0600 Subject: [PATCH] feat: adding studio resource endpoints (#71) --- docs/.vitepress/config.js | 13 ++++ docs/wiki/index.md | 4 ++ docs/wiki/studioresource/destroy/index.md | 39 +++++++++++ docs/wiki/studioresource/index.md | 44 +++++++++++++ docs/wiki/studioresource/index/index.md | 79 +++++++++++++++++++++++ docs/wiki/studioresource/show/index.md | 41 ++++++++++++ docs/wiki/studioresource/store/index.md | 47 ++++++++++++++ docs/wiki/studioresource/update/index.md | 45 +++++++++++++ 8 files changed, 312 insertions(+) create mode 100644 docs/wiki/studioresource/destroy/index.md create mode 100644 docs/wiki/studioresource/index.md create mode 100644 docs/wiki/studioresource/index/index.md create mode 100644 docs/wiki/studioresource/show/index.md create mode 100644 docs/wiki/studioresource/store/index.md create mode 100644 docs/wiki/studioresource/update/index.md diff --git a/docs/.vitepress/config.js b/docs/.vitepress/config.js index c7b253a..b6d85ce 100644 --- a/docs/.vitepress/config.js +++ b/docs/.vitepress/config.js @@ -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, diff --git a/docs/wiki/index.md b/docs/wiki/index.md index 9913f59..a155904 100644 --- a/docs/wiki/index.md +++ b/docs/wiki/index.md @@ -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. diff --git a/docs/wiki/studioresource/destroy/index.md b/docs/wiki/studioresource/destroy/index.md new file mode 100644 index 0000000..f03f7bd --- /dev/null +++ b/docs/wiki/studioresource/destroy/index.md @@ -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 +``` diff --git a/docs/wiki/studioresource/index.md b/docs/wiki/studioresource/index.md new file mode 100644 index 0000000..cc6ab4e --- /dev/null +++ b/docs/wiki/studioresource/index.md @@ -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. \ No newline at end of file diff --git a/docs/wiki/studioresource/index/index.md b/docs/wiki/studioresource/index/index.md new file mode 100644 index 0000000..1ae4259 --- /dev/null +++ b/docs/wiki/studioresource/index/index.md @@ -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/ +``` diff --git a/docs/wiki/studioresource/show/index.md b/docs/wiki/studioresource/show/index.md new file mode 100644 index 0000000..f7e0212 --- /dev/null +++ b/docs/wiki/studioresource/show/index.md @@ -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 +``` diff --git a/docs/wiki/studioresource/store/index.md b/docs/wiki/studioresource/store/index.md new file mode 100644 index 0000000..ebb6c01 --- /dev/null +++ b/docs/wiki/studioresource/store/index.md @@ -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/ +``` diff --git a/docs/wiki/studioresource/update/index.md b/docs/wiki/studioresource/update/index.md new file mode 100644 index 0000000..d70f20d --- /dev/null +++ b/docs/wiki/studioresource/update/index.md @@ -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/ +```