Add /preview/* routes
This commit is contained in:
parent
64709920f7
commit
80b1351bd2
127
scnserver/api/handler/apiPreview.go
Normal file
127
scnserver/api/handler/apiPreview.go
Normal file
@ -0,0 +1,127 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"blackforestbytes.com/simplecloudnotifier/api/apierr"
|
||||
"blackforestbytes.com/simplecloudnotifier/api/ginresp"
|
||||
"blackforestbytes.com/simplecloudnotifier/models"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// GetUserPreview swaggerdoc
|
||||
//
|
||||
// @Summary Get a user (similar to api-user-get, but can be called from anyone and only returns a subset of fields)
|
||||
// @ID api-user-get-preview
|
||||
// @Tags API-v2
|
||||
//
|
||||
// @Param uid path string true "UserID"
|
||||
//
|
||||
// @Success 200 {object} models.UserPreviewJSON
|
||||
// @Failure 400 {object} ginresp.apiError "supplied values/parameters cannot be parsed / are invalid"
|
||||
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
|
||||
// @Failure 404 {object} ginresp.apiError "user not found"
|
||||
// @Failure 500 {object} ginresp.apiError "internal server error"
|
||||
//
|
||||
// @Router /api/v2/preview/users/{uid} [GET]
|
||||
func (h APIHandler) GetUserPreview(g *gin.Context) ginresp.HTTPResponse {
|
||||
type uri struct {
|
||||
UserID models.UserID `uri:"uid" binding:"entityid"`
|
||||
}
|
||||
|
||||
var u uri
|
||||
ctx, errResp := h.app.StartRequest(g, &u, nil, nil, nil)
|
||||
if errResp != nil {
|
||||
return *errResp
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
user, err := h.database.GetUser(ctx, u.UserID)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.APIError(g, 404, apierr.USER_NOT_FOUND, "User not found", err)
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.APIError(g, 500, apierr.DATABASE_ERROR, "Failed to query user", err)
|
||||
}
|
||||
|
||||
return ctx.FinishSuccess(ginresp.JSON(http.StatusOK, user.JSONPreview()))
|
||||
}
|
||||
|
||||
// GetChannelPreview swaggerdoc
|
||||
//
|
||||
// @Summary Get a single channel (similar to api-channels-get, but can be called from anyone and only returns a subset of fields)
|
||||
// @ID api-channels-get-preview
|
||||
// @Tags API-v2
|
||||
//
|
||||
// @Param cid path string true "ChannelID"
|
||||
//
|
||||
// @Success 200 {object} models.ChannelPreviewJSON
|
||||
// @Failure 400 {object} ginresp.apiError "supplied values/parameters cannot be parsed / are invalid"
|
||||
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
|
||||
// @Failure 404 {object} ginresp.apiError "channel not found"
|
||||
// @Failure 500 {object} ginresp.apiError "internal server error"
|
||||
//
|
||||
// @Router /api/v2/preview/channels/{cid} [GET]
|
||||
func (h APIHandler) GetChannelPreview(g *gin.Context) ginresp.HTTPResponse {
|
||||
type uri struct {
|
||||
UserID models.UserID `uri:"uid" binding:"entityid"`
|
||||
ChannelID models.ChannelID `uri:"cid" binding:"entityid"`
|
||||
}
|
||||
|
||||
var u uri
|
||||
ctx, errResp := h.app.StartRequest(g, &u, nil, nil, nil)
|
||||
if errResp != nil {
|
||||
return *errResp
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
channel, err := h.database.GetChannelByID(ctx, u.ChannelID)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.APIError(g, 404, apierr.CHANNEL_NOT_FOUND, "Channel not found", err)
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.APIError(g, 500, apierr.DATABASE_ERROR, "Failed to query channel", err)
|
||||
}
|
||||
|
||||
return ctx.FinishSuccess(ginresp.JSON(http.StatusOK, channel.JSONPreview()))
|
||||
}
|
||||
|
||||
// GetUserKeyPreview swaggerdoc
|
||||
//
|
||||
// @Summary Get a single key (similar to api-tokenkeys-get, but can be called from anyone and only returns a subset of fields)
|
||||
// @ID api-tokenkeys-get-preview
|
||||
// @Tags API-v2
|
||||
//
|
||||
// @Param kid path string true "TokenKeyID"
|
||||
//
|
||||
// @Success 200 {object} models.KeyTokenPreviewJSON
|
||||
// @Failure 400 {object} ginresp.apiError "supplied values/parameters cannot be parsed / are invalid"
|
||||
// @Failure 401 {object} ginresp.apiError "user is not authorized / has missing permissions"
|
||||
// @Failure 404 {object} ginresp.apiError "message not found"
|
||||
// @Failure 500 {object} ginresp.apiError "internal server error"
|
||||
//
|
||||
// @Router /api/v2/preview/keys/{kid} [GET]
|
||||
func (h APIHandler) GetUserKeyPreview(g *gin.Context) ginresp.HTTPResponse {
|
||||
type uri struct {
|
||||
UserID models.UserID `uri:"uid" binding:"entityid"`
|
||||
KeyID models.KeyTokenID `uri:"kid" binding:"entityid"`
|
||||
}
|
||||
|
||||
var u uri
|
||||
ctx, errResp := h.app.StartRequest(g, &u, nil, nil, nil)
|
||||
if errResp != nil {
|
||||
return *errResp
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
keytoken, err := h.database.GetKeyToken(ctx, u.UserID, u.KeyID)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return ginresp.APIError(g, 404, apierr.KEY_NOT_FOUND, "Key not found", err)
|
||||
}
|
||||
if err != nil {
|
||||
return ginresp.APIError(g, 500, apierr.DATABASE_ERROR, "Failed to query client", err)
|
||||
}
|
||||
|
||||
return ctx.FinishSuccess(ginresp.JSON(http.StatusOK, keytoken.JSONPreview()))
|
||||
}
|
@ -157,6 +157,10 @@ func (r *Router) Init(e *gin.Engine) error {
|
||||
apiv2.GET("/messages", r.Wrap(r.apiHandler.ListMessages))
|
||||
apiv2.GET("/messages/:mid", r.Wrap(r.apiHandler.GetMessage))
|
||||
apiv2.DELETE("/messages/:mid", r.Wrap(r.apiHandler.DeleteMessage))
|
||||
|
||||
apiv2.GET("/preview/users/:uid", r.Wrap(r.apiHandler.GetUserPreview))
|
||||
apiv2.GET("/preview/keys/:kid", r.Wrap(r.apiHandler.GetUserKeyPreview))
|
||||
apiv2.GET("/preview/channels/:cid", r.Wrap(r.apiHandler.GetChannelPreview))
|
||||
}
|
||||
|
||||
// ================ Send API (unversioned) ================
|
||||
|
@ -41,6 +41,16 @@ func (c Channel) WithSubscription(sub *Subscription) ChannelWithSubscription {
|
||||
}
|
||||
}
|
||||
|
||||
func (c Channel) JSONPreview() ChannelPreviewJSON {
|
||||
return ChannelPreviewJSON{
|
||||
ChannelID: c.ChannelID,
|
||||
OwnerUserID: c.OwnerUserID,
|
||||
InternalName: c.InternalName,
|
||||
DisplayName: c.DisplayName,
|
||||
DescriptionName: c.DescriptionName,
|
||||
}
|
||||
}
|
||||
|
||||
type ChannelWithSubscription struct {
|
||||
Channel
|
||||
Subscription *Subscription
|
||||
@ -74,6 +84,14 @@ type ChannelWithSubscriptionJSON struct {
|
||||
Subscription *SubscriptionJSON `json:"subscription"`
|
||||
}
|
||||
|
||||
type ChannelPreviewJSON struct {
|
||||
ChannelID ChannelID `json:"channel_id"`
|
||||
OwnerUserID UserID `json:"owner_user_id"`
|
||||
InternalName string `json:"internal_name"`
|
||||
DisplayName string `json:"display_name"`
|
||||
DescriptionName *string `json:"description_name"`
|
||||
}
|
||||
|
||||
type ChannelDB struct {
|
||||
ChannelID ChannelID `db:"channel_id"`
|
||||
OwnerUserID UserID `db:"owner_user_id"`
|
||||
|
@ -5,7 +5,7 @@ package models
|
||||
import "gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||
import "gogs.mikescher.com/BlackForestBytes/goext/enums"
|
||||
|
||||
const ChecksumEnumGenerator = "5b115c5f107801af608630d2c5adce57cd4b050d176c8cd3db5c132020bf153c" // GoExtVersion: 0.0.463
|
||||
const ChecksumEnumGenerator = "e500346e3f60b3abf78558ec3df128c3be2a1cefa71c4f1feba9293d14eb85d1" // GoExtVersion: 0.0.463
|
||||
|
||||
// ================================ ClientType ================================
|
||||
//
|
||||
|
@ -15,7 +15,7 @@ import "reflect"
|
||||
import "regexp"
|
||||
import "strings"
|
||||
|
||||
const ChecksumCharsetIDGenerator = "5b115c5f107801af608630d2c5adce57cd4b050d176c8cd3db5c132020bf153c" // GoExtVersion: 0.0.463
|
||||
const ChecksumCharsetIDGenerator = "e500346e3f60b3abf78558ec3df128c3be2a1cefa71c4f1feba9293d14eb85d1" // GoExtVersion: 0.0.463
|
||||
|
||||
const idlen = 24
|
||||
|
||||
|
@ -92,6 +92,17 @@ func (k KeyToken) JSON() KeyTokenJSON {
|
||||
}
|
||||
}
|
||||
|
||||
func (k KeyToken) JSONPreview() KeyTokenPreviewJSON {
|
||||
return KeyTokenPreviewJSON{
|
||||
KeyTokenID: k.KeyTokenID,
|
||||
Name: k.Name,
|
||||
OwnerUserID: k.OwnerUserID,
|
||||
AllChannels: k.AllChannels,
|
||||
Channels: k.Channels,
|
||||
Permissions: k.Permissions.String(),
|
||||
}
|
||||
}
|
||||
|
||||
type KeyTokenJSON struct {
|
||||
KeyTokenID KeyTokenID `json:"keytoken_id"`
|
||||
Name string `json:"name"`
|
||||
@ -109,6 +120,15 @@ type KeyTokenWithTokenJSON struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type KeyTokenPreviewJSON struct {
|
||||
KeyTokenID KeyTokenID `json:"keytoken_id"`
|
||||
Name string `json:"name"`
|
||||
OwnerUserID UserID `json:"owner_user_id"`
|
||||
AllChannels bool `json:"all_channels"`
|
||||
Channels []ChannelID `json:"channels"`
|
||||
Permissions string `json:"permissions"`
|
||||
}
|
||||
|
||||
func (j KeyTokenJSON) WithToken(tok string) KeyTokenWithTokenJSON {
|
||||
return KeyTokenWithTokenJSON{
|
||||
KeyTokenJSON: j,
|
||||
|
@ -116,6 +116,13 @@ func (u User) MaxTimestampDiffHours() int {
|
||||
return 24
|
||||
}
|
||||
|
||||
func (u User) JSONPreview() UserPreviewJSON {
|
||||
return UserPreviewJSON{
|
||||
UserID: u.UserID,
|
||||
Username: u.Username,
|
||||
}
|
||||
}
|
||||
|
||||
type UserJSON struct {
|
||||
UserID UserID `json:"user_id"`
|
||||
Username *string `json:"username"`
|
||||
@ -137,6 +144,11 @@ type UserJSON struct {
|
||||
MaxUserMessageIDLength int `json:"max_user_message_id_length"`
|
||||
}
|
||||
|
||||
type UserPreviewJSON struct {
|
||||
UserID UserID `json:"user_id"`
|
||||
Username *string `json:"username"`
|
||||
}
|
||||
|
||||
type UserJSONWithClientsAndKeys struct {
|
||||
UserJSON
|
||||
Clients []ClientJSON `json:"clients"`
|
||||
|
@ -19,37 +19,61 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"example": "test",
|
||||
"name": "channel",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "This is a message",
|
||||
"name": "content",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "P3TNH8mvv14fm",
|
||||
"name": "key",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "db8b0e6a-a08c-4646",
|
||||
"name": "msg_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"type": "integer",
|
||||
"example": 1,
|
||||
"name": "priority",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "example-server",
|
||||
"name": "sender_name",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"example": 1669824037,
|
||||
"name": "timestamp",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "Hello World",
|
||||
"name": "title",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "user_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "user_key",
|
||||
"example": "7725",
|
||||
"name": "user_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
@ -62,37 +86,61 @@
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "test",
|
||||
"name": "channel",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "This is a message",
|
||||
"name": "content",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "P3TNH8mvv14fm",
|
||||
"name": "key",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "db8b0e6a-a08c-4646",
|
||||
"name": "msg_id",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"type": "integer",
|
||||
"example": 1,
|
||||
"name": "priority",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "example-server",
|
||||
"name": "sender_name",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"example": 1669824037,
|
||||
"name": "timestamp",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "Hello World",
|
||||
"name": "title",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "user_id",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "user_key",
|
||||
"example": "7725",
|
||||
"name": "user_id",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
@ -1009,6 +1057,156 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v2/preview/channels/{cid}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"API-v2"
|
||||
],
|
||||
"summary": "Get a single channel (similar to api-channels-get, but can be called from anyone and only returns a subset of fields)",
|
||||
"operationId": "api-channels-get-preview",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "ChannelID",
|
||||
"name": "cid",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.ChannelPreviewJSON"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "supplied values/parameters cannot be parsed / are invalid",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "user is not authorized / has missing permissions",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "channel not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v2/preview/keys/{kid}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"API-v2"
|
||||
],
|
||||
"summary": "Get a single key (similar to api-tokenkeys-get, but can be called from anyone and only returns a subset of fields)",
|
||||
"operationId": "api-tokenkeys-get-preview",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "TokenKeyID",
|
||||
"name": "kid",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.KeyTokenPreviewJSON"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "supplied values/parameters cannot be parsed / are invalid",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "user is not authorized / has missing permissions",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "message not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v2/preview/users/{uid}": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"API-v2"
|
||||
],
|
||||
"summary": "Get a user (similar to api-user-get, but can be called from anyone and only returns a subset of fields)",
|
||||
"operationId": "api-user-get-preview",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "UserID",
|
||||
"name": "uid",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.UserPreviewJSON"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "supplied values/parameters cannot be parsed / are invalid",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "user is not authorized / has missing permissions",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "user not found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
},
|
||||
"500": {
|
||||
"description": "internal server error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ginresp.apiError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v2/users": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@ -2567,37 +2765,61 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"example": "test",
|
||||
"name": "channel",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "This is a message",
|
||||
"name": "content",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "P3TNH8mvv14fm",
|
||||
"name": "key",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "db8b0e6a-a08c-4646",
|
||||
"name": "msg_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"type": "integer",
|
||||
"example": 1,
|
||||
"name": "priority",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "example-server",
|
||||
"name": "sender_name",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"example": 1669824037,
|
||||
"name": "timestamp",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "Hello World",
|
||||
"name": "title",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "user_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "user_key",
|
||||
"example": "7725",
|
||||
"name": "user_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
@ -2610,37 +2832,61 @@
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "test",
|
||||
"name": "channel",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "This is a message",
|
||||
"name": "content",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "P3TNH8mvv14fm",
|
||||
"name": "key",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "db8b0e6a-a08c-4646",
|
||||
"name": "msg_id",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"type": "integer",
|
||||
"example": 1,
|
||||
"name": "priority",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "example-server",
|
||||
"name": "sender_name",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"example": 1669824037,
|
||||
"name": "timestamp",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "Hello World",
|
||||
"name": "title",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "user_id",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "user_key",
|
||||
"example": "7725",
|
||||
"name": "user_id",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
@ -2689,72 +2935,120 @@
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"example": "test",
|
||||
"name": "channel",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "This is a message",
|
||||
"name": "content",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "P3TNH8mvv14fm",
|
||||
"name": "key",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "db8b0e6a-a08c-4646",
|
||||
"name": "msg_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"type": "integer",
|
||||
"example": 1,
|
||||
"name": "priority",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "example-server",
|
||||
"name": "sender_name",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"example": 1669824037,
|
||||
"name": "timestamp",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "Hello World",
|
||||
"name": "title",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"type": "string",
|
||||
"example": "7725",
|
||||
"name": "user_id",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "user_key",
|
||||
"in": "query"
|
||||
"example": "test",
|
||||
"name": "channel",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "This is a message",
|
||||
"name": "content",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "P3TNH8mvv14fm",
|
||||
"name": "key",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "db8b0e6a-a08c-4646",
|
||||
"name": "msg_id",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"type": "integer",
|
||||
"example": 1,
|
||||
"name": "priority",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "example-server",
|
||||
"name": "sender_name",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "number",
|
||||
"example": 1669824037,
|
||||
"name": "timestamp",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"example": "Hello World",
|
||||
"name": "title",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"name": "user_id",
|
||||
"in": "formData"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "user_key",
|
||||
"example": "7725",
|
||||
"name": "user_id",
|
||||
"in": "formData"
|
||||
}
|
||||
],
|
||||
@ -3251,26 +3545,46 @@
|
||||
"handler.SendMessage.combined": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"channel": {
|
||||
"type": "string",
|
||||
"example": "test"
|
||||
},
|
||||
"content": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"example": "This is a message"
|
||||
},
|
||||
"key": {
|
||||
"type": "string",
|
||||
"example": "P3TNH8mvv14fm"
|
||||
},
|
||||
"msg_id": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"example": "db8b0e6a-a08c-4646"
|
||||
},
|
||||
"priority": {
|
||||
"type": "integer"
|
||||
"type": "integer",
|
||||
"enum": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"example": 1
|
||||
},
|
||||
"sender_name": {
|
||||
"type": "string",
|
||||
"example": "example-server"
|
||||
},
|
||||
"timestamp": {
|
||||
"type": "number"
|
||||
"type": "number",
|
||||
"example": 1669824037
|
||||
},
|
||||
"title": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"example": "Hello World"
|
||||
},
|
||||
"user_id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"user_key": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"example": "7725"
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -3299,7 +3613,7 @@
|
||||
"type": "integer"
|
||||
},
|
||||
"scn_msg_id": {
|
||||
"type": "integer"
|
||||
"type": "string"
|
||||
},
|
||||
"success": {
|
||||
"type": "boolean"
|
||||
@ -3487,6 +3801,26 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ChannelPreviewJSON": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"channel_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"description_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"internal_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"owner_user_id": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ChannelWithSubscriptionJSON": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -3630,6 +3964,32 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.KeyTokenPreviewJSON": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"all_channels": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"channels": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"keytoken_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"owner_user_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.KeyTokenWithTokenJSON": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -3870,6 +4230,17 @@
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.UserPreviewJSON": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": [
|
||||
|
@ -327,19 +327,36 @@ definitions:
|
||||
type: object
|
||||
handler.SendMessage.combined:
|
||||
properties:
|
||||
channel:
|
||||
example: test
|
||||
type: string
|
||||
content:
|
||||
example: This is a message
|
||||
type: string
|
||||
key:
|
||||
example: P3TNH8mvv14fm
|
||||
type: string
|
||||
msg_id:
|
||||
example: db8b0e6a-a08c-4646
|
||||
type: string
|
||||
priority:
|
||||
enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
example: 1
|
||||
type: integer
|
||||
sender_name:
|
||||
example: example-server
|
||||
type: string
|
||||
timestamp:
|
||||
example: 1669824037
|
||||
type: number
|
||||
title:
|
||||
example: Hello World
|
||||
type: string
|
||||
user_id:
|
||||
type: integer
|
||||
user_key:
|
||||
example: "7725"
|
||||
type: string
|
||||
type: object
|
||||
handler.SendMessage.response:
|
||||
@ -359,7 +376,7 @@ definitions:
|
||||
quota_max:
|
||||
type: integer
|
||||
scn_msg_id:
|
||||
type: integer
|
||||
type: string
|
||||
success:
|
||||
type: boolean
|
||||
suppress_send:
|
||||
@ -480,6 +497,19 @@ definitions:
|
||||
uri:
|
||||
type: string
|
||||
type: object
|
||||
models.ChannelPreviewJSON:
|
||||
properties:
|
||||
channel_id:
|
||||
type: string
|
||||
description_name:
|
||||
type: string
|
||||
display_name:
|
||||
type: string
|
||||
internal_name:
|
||||
type: string
|
||||
owner_user_id:
|
||||
type: string
|
||||
type: object
|
||||
models.ChannelWithSubscriptionJSON:
|
||||
properties:
|
||||
channel_id:
|
||||
@ -577,6 +607,23 @@ definitions:
|
||||
timestamp_lastused:
|
||||
type: string
|
||||
type: object
|
||||
models.KeyTokenPreviewJSON:
|
||||
properties:
|
||||
all_channels:
|
||||
type: boolean
|
||||
channels:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
keytoken_id:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
owner_user_id:
|
||||
type: string
|
||||
permissions:
|
||||
type: string
|
||||
type: object
|
||||
models.KeyTokenWithTokenJSON:
|
||||
properties:
|
||||
all_channels:
|
||||
@ -736,6 +783,13 @@ definitions:
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
models.UserPreviewJSON:
|
||||
properties:
|
||||
user_id:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
type: object
|
||||
host: simplecloudnotifier.de
|
||||
info:
|
||||
contact: {}
|
||||
@ -748,52 +802,90 @@ paths:
|
||||
description: All parameter can be set via query-parameter or the json body.
|
||||
Only UserID, UserKey and Title are required
|
||||
parameters:
|
||||
- in: query
|
||||
- example: test
|
||||
in: query
|
||||
name: channel
|
||||
type: string
|
||||
- example: This is a message
|
||||
in: query
|
||||
name: content
|
||||
type: string
|
||||
- in: query
|
||||
- example: P3TNH8mvv14fm
|
||||
in: query
|
||||
name: key
|
||||
type: string
|
||||
- example: db8b0e6a-a08c-4646
|
||||
in: query
|
||||
name: msg_id
|
||||
type: string
|
||||
- in: query
|
||||
- enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
example: 1
|
||||
in: query
|
||||
name: priority
|
||||
type: integer
|
||||
- in: query
|
||||
- example: example-server
|
||||
in: query
|
||||
name: sender_name
|
||||
type: string
|
||||
- example: 1669824037
|
||||
in: query
|
||||
name: timestamp
|
||||
type: number
|
||||
- in: query
|
||||
- example: Hello World
|
||||
in: query
|
||||
name: title
|
||||
type: string
|
||||
- in: query
|
||||
- example: "7725"
|
||||
in: query
|
||||
name: user_id
|
||||
type: integer
|
||||
- in: query
|
||||
name: user_key
|
||||
type: string
|
||||
- description: ' '
|
||||
in: body
|
||||
name: post_body
|
||||
schema:
|
||||
$ref: '#/definitions/handler.SendMessage.combined'
|
||||
- in: formData
|
||||
- example: test
|
||||
in: formData
|
||||
name: channel
|
||||
type: string
|
||||
- example: This is a message
|
||||
in: formData
|
||||
name: content
|
||||
type: string
|
||||
- in: formData
|
||||
- example: P3TNH8mvv14fm
|
||||
in: formData
|
||||
name: key
|
||||
type: string
|
||||
- example: db8b0e6a-a08c-4646
|
||||
in: formData
|
||||
name: msg_id
|
||||
type: string
|
||||
- in: formData
|
||||
- enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
example: 1
|
||||
in: formData
|
||||
name: priority
|
||||
type: integer
|
||||
- in: formData
|
||||
- example: example-server
|
||||
in: formData
|
||||
name: sender_name
|
||||
type: string
|
||||
- example: 1669824037
|
||||
in: formData
|
||||
name: timestamp
|
||||
type: number
|
||||
- in: formData
|
||||
- example: Hello World
|
||||
in: formData
|
||||
name: title
|
||||
type: string
|
||||
- in: formData
|
||||
- example: "7725"
|
||||
in: formData
|
||||
name: user_id
|
||||
type: integer
|
||||
- in: formData
|
||||
name: user_key
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
@ -1422,6 +1514,108 @@ paths:
|
||||
summary: Get a single message (untrimmed)
|
||||
tags:
|
||||
- API-v2
|
||||
/api/v2/preview/channels/{cid}:
|
||||
get:
|
||||
operationId: api-channels-get-preview
|
||||
parameters:
|
||||
- description: ChannelID
|
||||
in: path
|
||||
name: cid
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/models.ChannelPreviewJSON'
|
||||
"400":
|
||||
description: supplied values/parameters cannot be parsed / are invalid
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"401":
|
||||
description: user is not authorized / has missing permissions
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"404":
|
||||
description: channel not found
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"500":
|
||||
description: internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
summary: Get a single channel (similar to api-channels-get, but can be called
|
||||
from anyone and only returns a subset of fields)
|
||||
tags:
|
||||
- API-v2
|
||||
/api/v2/preview/keys/{kid}:
|
||||
get:
|
||||
operationId: api-tokenkeys-get-preview
|
||||
parameters:
|
||||
- description: TokenKeyID
|
||||
in: path
|
||||
name: kid
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/models.KeyTokenPreviewJSON'
|
||||
"400":
|
||||
description: supplied values/parameters cannot be parsed / are invalid
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"401":
|
||||
description: user is not authorized / has missing permissions
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"404":
|
||||
description: message not found
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"500":
|
||||
description: internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
summary: Get a single key (similar to api-tokenkeys-get, but can be called from
|
||||
anyone and only returns a subset of fields)
|
||||
tags:
|
||||
- API-v2
|
||||
/api/v2/preview/users/{uid}:
|
||||
get:
|
||||
operationId: api-user-get-preview
|
||||
parameters:
|
||||
- description: UserID
|
||||
in: path
|
||||
name: uid
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/models.UserPreviewJSON'
|
||||
"400":
|
||||
description: supplied values/parameters cannot be parsed / are invalid
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"401":
|
||||
description: user is not authorized / has missing permissions
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"404":
|
||||
description: user not found
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
"500":
|
||||
description: internal server error
|
||||
schema:
|
||||
$ref: '#/definitions/ginresp.apiError'
|
||||
summary: Get a user (similar to api-user-get, but can be called from anyone
|
||||
and only returns a subset of fields)
|
||||
tags:
|
||||
- API-v2
|
||||
/api/v2/users:
|
||||
post:
|
||||
operationId: api-user-create
|
||||
@ -2491,52 +2685,90 @@ paths:
|
||||
description: All parameter can be set via query-parameter or the json body.
|
||||
Only UserID, UserKey and Title are required
|
||||
parameters:
|
||||
- in: query
|
||||
- example: test
|
||||
in: query
|
||||
name: channel
|
||||
type: string
|
||||
- example: This is a message
|
||||
in: query
|
||||
name: content
|
||||
type: string
|
||||
- in: query
|
||||
- example: P3TNH8mvv14fm
|
||||
in: query
|
||||
name: key
|
||||
type: string
|
||||
- example: db8b0e6a-a08c-4646
|
||||
in: query
|
||||
name: msg_id
|
||||
type: string
|
||||
- in: query
|
||||
- enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
example: 1
|
||||
in: query
|
||||
name: priority
|
||||
type: integer
|
||||
- in: query
|
||||
- example: example-server
|
||||
in: query
|
||||
name: sender_name
|
||||
type: string
|
||||
- example: 1669824037
|
||||
in: query
|
||||
name: timestamp
|
||||
type: number
|
||||
- in: query
|
||||
- example: Hello World
|
||||
in: query
|
||||
name: title
|
||||
type: string
|
||||
- in: query
|
||||
- example: "7725"
|
||||
in: query
|
||||
name: user_id
|
||||
type: integer
|
||||
- in: query
|
||||
name: user_key
|
||||
type: string
|
||||
- description: ' '
|
||||
in: body
|
||||
name: post_body
|
||||
schema:
|
||||
$ref: '#/definitions/handler.SendMessage.combined'
|
||||
- in: formData
|
||||
- example: test
|
||||
in: formData
|
||||
name: channel
|
||||
type: string
|
||||
- example: This is a message
|
||||
in: formData
|
||||
name: content
|
||||
type: string
|
||||
- in: formData
|
||||
- example: P3TNH8mvv14fm
|
||||
in: formData
|
||||
name: key
|
||||
type: string
|
||||
- example: db8b0e6a-a08c-4646
|
||||
in: formData
|
||||
name: msg_id
|
||||
type: string
|
||||
- in: formData
|
||||
- enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
example: 1
|
||||
in: formData
|
||||
name: priority
|
||||
type: integer
|
||||
- in: formData
|
||||
- example: example-server
|
||||
in: formData
|
||||
name: sender_name
|
||||
type: string
|
||||
- example: 1669824037
|
||||
in: formData
|
||||
name: timestamp
|
||||
type: number
|
||||
- in: formData
|
||||
- example: Hello World
|
||||
in: formData
|
||||
name: title
|
||||
type: string
|
||||
- in: formData
|
||||
- example: "7725"
|
||||
in: formData
|
||||
name: user_id
|
||||
type: integer
|
||||
- in: formData
|
||||
name: user_key
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
@ -2569,47 +2801,85 @@ paths:
|
||||
description: All parameter can be set via query-parameter or form-data body.
|
||||
Only UserID, UserKey and Title are required
|
||||
parameters:
|
||||
- in: query
|
||||
- example: test
|
||||
in: query
|
||||
name: channel
|
||||
type: string
|
||||
- example: This is a message
|
||||
in: query
|
||||
name: content
|
||||
type: string
|
||||
- in: query
|
||||
- example: P3TNH8mvv14fm
|
||||
in: query
|
||||
name: key
|
||||
type: string
|
||||
- example: db8b0e6a-a08c-4646
|
||||
in: query
|
||||
name: msg_id
|
||||
type: string
|
||||
- in: query
|
||||
- enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
example: 1
|
||||
in: query
|
||||
name: priority
|
||||
type: integer
|
||||
- in: query
|
||||
- example: example-server
|
||||
in: query
|
||||
name: sender_name
|
||||
type: string
|
||||
- example: 1669824037
|
||||
in: query
|
||||
name: timestamp
|
||||
type: number
|
||||
- in: query
|
||||
- example: Hello World
|
||||
in: query
|
||||
name: title
|
||||
type: string
|
||||
- in: query
|
||||
- example: "7725"
|
||||
in: query
|
||||
name: user_id
|
||||
type: integer
|
||||
- in: query
|
||||
name: user_key
|
||||
type: string
|
||||
- in: formData
|
||||
- example: test
|
||||
in: formData
|
||||
name: channel
|
||||
type: string
|
||||
- example: This is a message
|
||||
in: formData
|
||||
name: content
|
||||
type: string
|
||||
- in: formData
|
||||
- example: P3TNH8mvv14fm
|
||||
in: formData
|
||||
name: key
|
||||
type: string
|
||||
- example: db8b0e6a-a08c-4646
|
||||
in: formData
|
||||
name: msg_id
|
||||
type: string
|
||||
- in: formData
|
||||
- enum:
|
||||
- 0
|
||||
- 1
|
||||
- 2
|
||||
example: 1
|
||||
in: formData
|
||||
name: priority
|
||||
type: integer
|
||||
- in: formData
|
||||
- example: example-server
|
||||
in: formData
|
||||
name: sender_name
|
||||
type: string
|
||||
- example: 1669824037
|
||||
in: formData
|
||||
name: timestamp
|
||||
type: number
|
||||
- in: formData
|
||||
- example: Hello World
|
||||
in: formData
|
||||
name: title
|
||||
type: string
|
||||
- in: formData
|
||||
- example: "7725"
|
||||
in: formData
|
||||
name: user_id
|
||||
type: integer
|
||||
- in: formData
|
||||
name: user_key
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
|
Loading…
Reference in New Issue
Block a user