1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 11:34:18 +00:00

Update to 5.11.0

This commit is contained in:
Steffo 2020-08-19 02:31:34 +02:00
parent 3f419bf6db
commit 76c7020d79
2 changed files with 46 additions and 15 deletions

View file

@ -15,25 +15,37 @@ class EchoStar(rca.ApiStar):
NOTE: This method can only be used by Royalnet Admins. NOTE: This method can only be used by Royalnet Admins.
""" """
# The HTTP methods that can be used with this ApiStar.
methods = ["GET", "POST"]
# You can disambiguate between methods using the `data.method` variable.
# The HTTP path this ApiStar should bind to. # The HTTP path this ApiStar should bind to.
path = "/api/example/echo/v1" path = "/api/example/echo/v1"
# Does this method require any auth? # Does this method require any auth?
# Only for documentation purposes, it doesn't do any check on it's own. # Only for documentation purposes, it doesn't do any check on it's own.
requires_auth = True auth = {
"get": True,
"post": False,
"put": False,
"delete": False,
}
# To authenticate an user through their token, use the `await data.user()` method. # To authenticate an user through their token, use the `await data.user()` method.
# If the user isn't logged in, the method authomatically returns 403 Forbidden, unless `rcae.ForbiddenError` # If the user isn't logged in, the method authomatically returns 403 Forbidden, unless `rcae.ForbiddenError`
# is caught. # is caught.
# A dict of paramenters accepted by this method, with a description of their purpose. # A dict of paramenters accepted by this method, with a description of their purpose.
parameters = { parameters = {
"echo": "What should the method return? " "get": {
"(Optional: if nothing is passed, the ApiStar will return the username of the caller.)", "echo": "What should the method return? "
"error": "Should the method return a sample error?" "(Optional: if nothing is passed, the ApiStar will return the username of the caller.)",
"error": "Should the method return a sample error?"
},
"post": {
},
"put": {
},
"delete": {
},
} }
# You can access parameters by using `data` as a dict with the parameter name as key. # You can access parameters by using `data` as a dict with the parameter name as key.
# If a missing parameter is accessed, a `rcae.MissingParameterError` will be raised, which will lead to a # If a missing parameter is accessed, a `rcae.MissingParameterError` will be raised, which will lead to a
@ -42,9 +54,14 @@ class EchoStar(rca.ApiStar):
# The autodoc categories this ApiStar should fall in. # The autodoc categories this ApiStar should fall in.
tags = ["example"] tags = ["example"]
# The actual method called when the ApiStar received a HTTP request. # The methods called when the ApiStar received a HTTP request.
# It must return a JSON-compatible object, such as a str, a int, a float, a list, a dict or None. # They must return a JSON-compatible object, such as a str, a int, a float, a list, a dict or None.
async def api(self, data: rca.ApiData) -> ru.JSON: # They also must be wrapped with the @rca.magic decorator.
# You are free to not add them if you don't want the methods to be available
# Called on a GET request
@rca.magic
async def get(self, data: rca.ApiData) -> ru.JSON:
# If "true" is passed as the "error" parameter in the query string... # If "true" is passed as the "error" parameter in the query string...
if data["error"] == "true": if data["error"] == "true":
@ -67,4 +84,19 @@ class EchoStar(rca.ApiStar):
echo = user.username echo = user.username
# Return a 200 OK successful response containing the value of the echo variable and the HTTP method used # Return a 200 OK successful response containing the value of the echo variable and the HTTP method used
return {"echo": echo, "method_used": data.method} return {"echo": echo, "method_used": "GET"}
# Called on a POST request
@rca.magic
async def post(self, data: rca.ApiData) -> ru.JSON:
return "This is a response to a POST."
# Called on a PUT request
@rca.magic
async def put(self, data: rca.ApiData) -> ru.JSON:
return data
# Called on a DELETE request
@rca.magic
async def post(self, data: rca.ApiData) -> ru.JSON:
return None

View file

@ -14,7 +14,7 @@
# TODO: Set this to the GitHub page of your pack (or another website) # TODO: Set this to the GitHub page of your pack (or another website)
homepage = "https://github.com/your-username/" homepage = "https://github.com/your-username/"
# TODO: Set this to a link to the Pack documentation (if there's any) # TODO: Set this to a link to the Pack documentation (if there's any)
documentation = "https://gh.steffo.eu/royalpack/" documentation = "https://gh.steffo.eu/royalnet-pack-template/"
# TODO: Pick some classifiers to include your Pack in: https://pypi.org/classifiers/ # TODO: Pick some classifiers to include your Pack in: https://pypi.org/classifiers/
classifiers = [ classifiers = [
"Development Status :: 3 - Alpha", "Development Status :: 3 - Alpha",
@ -29,13 +29,12 @@
python = "^3.8" python = "^3.8"
[tool.poetry.dependencies.royalnet] [tool.poetry.dependencies.royalnet]
version = "~5.10.3" version = "~5.11.0"
# TODO: select the Royalnet modules required by your pack # TODO: select the Royalnet modules required by your pack
extras = [ extras = [
"telegram", "telegram",
"discord", "discord",
"alchemy_easy", "alchemy_easy",
"bard",
"constellation", "constellation",
"sentry", "sentry",
"herald", "herald",