-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from sinamics/backend_api
Restfull API
- Loading branch information
Showing
37 changed files
with
6,582 additions
and
1,258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
id: create-a-new-user | ||
title: "Create a new user" | ||
description: "If no users have been created yet, no API key is required. Otherwise, an API key must be included in the request header." | ||
sidebar_label: "Create a new user" | ||
hide_title: true | ||
hide_table_of_contents: true | ||
api: {"description":"If no users have been created yet, no API key is required. Otherwise, an API key must be included in the request header.\nKeep in mind that first user created will be the admin user.\n","security":[{"x-ztnet-auth":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["email","password","name"],"properties":{"email":{"type":"string"},"password":{"type":"string"},"name":{"type":"string"},"expiresAt":{"type":"string | null","description":"The date and time at which the user's account will expire. If null, the account will never expire.\nMust be in ISO 8601 format (e.g. 2023-10-28T00:00:00Z).\n\nNot applicable if the user is an admin (first user). Admin accounts never expire.\n"}}},"example":{"email":"test@example.com","password":"password123","name":"Test User","expiresAt":"2023-10-28T00:00:00Z"}}}},"responses":{"200":{"description":"User successfully created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"email":{"type":"string"},"name":{"type":"string"},"expiresAt":{"type":"string"}},"example":{"id":"12345","email":"test@example.com","name":"Test User","expiresAt":"2023-10-28T00:00:00Z"}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}},"method":"post","path":"/api/v1/user","securitySchemes":{"x-ztnet-auth":{"type":"apiKey","required":true,"in":"header","name":"x-ztnet-auth","description":"API key can be generated from the ZTNet admin section."}},"jsonRequestBodyExample":{"email":"string","password":"string","name":"string"},"info":{"title":"ZTNet Web API","info_path":"restapi/ztnet-web-api","version":"1.0.0","description":"Public API for ZTNet. Available from ztnet version 0.4.0 onwards.\n\nThis API is rate-limited to 10 requests per minute\n"},"postman":{"name":"Create a new user","description":{"content":"If no users have been created yet, no API key is required. Otherwise, an API key must be included in the request header.\nKeep in mind that first user created will be the admin user.\n","type":"text/plain"},"url":{"path":["api","v1","user"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}},"auth":{"type":"apikey","apikey":[{"type":"any","value":"x-ztnet-auth","key":"key"},{"type":"any","value":"<API Key>","key":"value"},{"type":"any","value":"header","key":"in"}]}}} | ||
sidebar_class_name: "post api-method" | ||
info_path: Rest Api/ztnet-web-api | ||
custom_edit_url: null | ||
--- | ||
|
||
import ApiTabs from "@theme/ApiTabs"; | ||
import MimeTabs from "@theme/MimeTabs"; | ||
import ParamsItem from "@theme/ParamsItem"; | ||
import ResponseSamples from "@theme/ResponseSamples"; | ||
import SchemaItem from "@theme/SchemaItem"; | ||
import SchemaTabs from "@theme/SchemaTabs"; | ||
import DiscriminatorTabs from "@theme/DiscriminatorTabs"; | ||
import TabItem from "@theme/TabItem"; | ||
|
||
## Create a new user | ||
|
||
|
||
|
||
If no users have been created yet, no API key is required. Otherwise, an API key must be included in the request header. | ||
Keep in mind that first user created will be the admin user. | ||
|
||
|
||
<MimeTabs><TabItem label={"application/json"} value={"application/json-schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Request Body</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"email"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"password"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"expiresAt"} required={false} schemaName={"string | null"} qualifierMessage={undefined} schema={{"type":"string | null","description":"The date and time at which the user's account will expire. If null, the account will never expire.\nMust be in ISO 8601 format (e.g. 2023-10-28T00:00:00Z).\n\nNot applicable if the user is an admin (first user). Admin accounts never expire.\n"}}></SchemaItem></ul></details></TabItem></MimeTabs><div><ApiTabs><TabItem label={"200"} value={"200"}><div> | ||
|
||
User successfully created | ||
|
||
</div><div><MimeTabs schemaType={"response"}><TabItem label={"application/json"} value={"application/json"}><SchemaTabs><TabItem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"id"} required={false} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"email"} required={false} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={false} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"expiresAt"} required={false} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem></ul></details></TabItem><TabItem label={"Example (from schema)"} value={"Example (from schema)"}><ResponseSamples responseExample={"{\n \"id\": \"12345\",\n \"email\": \"test@example.com\",\n \"name\": \"Test User\",\n \"expiresAt\": \"2023-10-28T00:00:00Z\"\n}"} language={"json"}></ResponseSamples></TabItem></SchemaTabs></TabItem></MimeTabs></div></TabItem><TabItem label={"401"} value={"401"}><div> | ||
|
||
Unauthorized | ||
|
||
</div><div><MimeTabs schemaType={"response"}><TabItem label={"application/json"} value={"application/json"}><SchemaTabs><TabItem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"error"} required={false} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem></ul></details></TabItem><TabItem label={"Example (from schema)"} value={"Example (from schema)"}><ResponseSamples responseExample={"{\n \"error\": \"string\"\n}"} language={"json"}></ResponseSamples></TabItem></SchemaTabs></TabItem></MimeTabs></div></TabItem><TabItem label={"429"} value={"429"}><div> | ||
|
||
Rate limit exceeded | ||
|
||
</div><div><MimeTabs schemaType={"response"}><TabItem label={"application/json"} value={"application/json"}><SchemaTabs><TabItem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"error"} required={false} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem></ul></details></TabItem><TabItem label={"Example (from schema)"} value={"Example (from schema)"}><ResponseSamples responseExample={"{\n \"error\": \"string\"\n}"} language={"json"}></ResponseSamples></TabItem></SchemaTabs></TabItem></MimeTabs></div></TabItem><TabItem label={"500"} value={"500"}><div> | ||
|
||
Internal server error | ||
|
||
</div><div><MimeTabs schemaType={"response"}><TabItem label={"application/json"} value={"application/json"}><SchemaTabs><TabItem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><SchemaItem collapsible={false} name={"message"} required={false} schemaName={"string"} qualifierMessage={undefined} schema={{"type":"string"}}></SchemaItem></ul></details></TabItem><TabItem label={"Example (from schema)"} value={"Example (from schema)"}><ResponseSamples responseExample={"{\n \"message\": \"string\"\n}"} language={"json"}></ResponseSamples></TabItem></SchemaTabs></TabItem></MimeTabs></div></TabItem></ApiTabs></div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
openapi: 3.1.0 | ||
info: | ||
title: ZTNet Web API | ||
info_path: restapi/ztnet-web-api | ||
version: 1.0.0 | ||
description: | | ||
Public API for ZTNet. Available from ztnet version 0.4.0 onwards. | ||
This API is rate-limited to 10 requests per minute | ||
paths: | ||
/api/v1/user: | ||
post: | ||
summary: Create a new user | ||
description: | | ||
If no users have been created yet, no API key is required. Otherwise, an API key must be included in the request header. | ||
Keep in mind that first user created will be the admin user. | ||
security: | ||
- x-ztnet-auth: [] | ||
requestBody: | ||
# required: true | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
required: | ||
- password | ||
- name | ||
properties: | ||
email: | ||
type: string | ||
password: | ||
type: string | ||
name: | ||
type: string | ||
expiresAt: | ||
type: string | null | ||
description: | | ||
The date and time at which the user's account will expire. If null, the account will never expire. | ||
Must be in ISO 8601 format (e.g. 2023-10-28T00:00:00Z). | ||
Not applicable if the user is an admin (first user). Admin accounts never expire. | ||
example: | ||
email: "test@example.com" | ||
password: "password123" | ||
name: "Test User" | ||
expiresAt: "2023-10-28T00:00:00Z" | ||
# parameters: | ||
# - name: x-ztnet-auth | ||
# in: header | ||
# required: true | ||
# schema: | ||
# type: string | ||
# description: API key required if any users have been created. | ||
|
||
responses: | ||
200: | ||
description: User successfully created | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
email: | ||
type: string | ||
name: | ||
type: string | ||
expiresAt: | ||
type: string | ||
example: | ||
id: "12345" | ||
email: "test@example.com" | ||
name: "Test User" | ||
expiresAt: "2023-10-28T00:00:00Z" | ||
|
||
401: | ||
description: Unauthorized | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
error: | ||
type: string | ||
429: | ||
description: Rate limit exceeded | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
error: | ||
type: string | ||
500: | ||
description: Internal server error | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
message: | ||
type: string | ||
components: | ||
securitySchemes: | ||
x-ztnet-auth: | ||
type: apiKey | ||
required: true | ||
in: header | ||
name: x-ztnet-auth | ||
description: API key can be generated from the ZTNet admin section. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
id: ztnet-web-api | ||
title: "ZTNet Web API" | ||
description: "Public API for ZTNet. Available from ztnet version 0.4.0 onwards." | ||
sidebar_label: Introduction | ||
sidebar_position: 0 | ||
hide_title: true | ||
custom_edit_url: null | ||
--- | ||
|
||
import ApiLogo from "@theme/ApiLogo"; | ||
import SchemaTabs from "@theme/SchemaTabs"; | ||
import TabItem from "@theme/TabItem"; | ||
import Export from "@theme/ApiDemoPanel/Export"; | ||
|
||
<span className={"theme-doc-version-badge badge badge--secondary"}>Version: 1.0.0</span> | ||
|
||
# ZTNet Web API | ||
|
||
|
||
|
||
Public API for ZTNet. Available from ztnet version 0.4.0 onwards. | ||
|
||
This API is rate-limited to 10 requests per minute | ||
|
||
|
||
<div style={{"marginBottom":"2rem"}}><h2 id={"authentication"} style={{"marginBottom":"1rem"}}>Authentication</h2><SchemaTabs className={"openapi-tabs__security-schemes"}><TabItem label={"API Key: x-ztnet-auth"} value={"x-ztnet-auth"}> | ||
|
||
API key can be generated from the ZTNet admin section. | ||
|
||
<div><table><tbody><tr><th>Security Scheme Type:</th><td>apiKey</td></tr><tr><th>Header parameter name:</th><td>x-ztnet-auth</td></tr></tbody></table></div></TabItem></SchemaTabs></div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.