commit
97f180b650
|
|
@ -7,10 +7,10 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.19.x
|
||||
go-version: 1.21.x
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: '16'
|
||||
node-version: '20'
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
|
|
@ -28,7 +28,7 @@ jobs:
|
|||
- run: make build-js
|
||||
- uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.45
|
||||
version: v1.53
|
||||
args: --timeout=5m
|
||||
skip-cache: true
|
||||
- run: go mod download
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ run:
|
|||
linters:
|
||||
enable:
|
||||
- asciicheck
|
||||
- deadcode
|
||||
- depguard
|
||||
- exportloopref
|
||||
- godot
|
||||
- gofmt
|
||||
|
|
@ -23,12 +21,10 @@ linters:
|
|||
- nolintlint
|
||||
- sqlclosecheck
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- stylecheck
|
||||
- typecheck
|
||||
- unconvert
|
||||
- unused
|
||||
- varcheck
|
||||
- whitespace
|
||||
disable:
|
||||
- goerr113
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
1.19.1
|
||||
1.21.1
|
||||
|
|
|
|||
12
Makefile
12
Makefile
|
|
@ -7,8 +7,9 @@ DOCKER_BUILD_IMAGE=gotify/build
|
|||
DOCKER_WORKDIR=/proj
|
||||
DOCKER_RUN=docker run --rm -v "$$PWD/.:${DOCKER_WORKDIR}" -v "`go env GOPATH`/pkg/mod/.:/go/pkg/mod:ro" -w ${DOCKER_WORKDIR}
|
||||
DOCKER_GO_BUILD=go build -mod=readonly -a -installsuffix cgo -ldflags "$$LD_FLAGS"
|
||||
NODE_OPTIONS=$(shell if node --help | grep -q -- "--openssl-legacy-provider"; then echo --openssl-legacy-provider; fi)
|
||||
|
||||
test: test-coverage test-race test-js
|
||||
test: test-coverage test-js
|
||||
check: check-go check-swagger check-js
|
||||
check-ci: check-swagger check-js
|
||||
|
||||
|
|
@ -16,11 +17,8 @@ require-version:
|
|||
if [ -n ${VERSION} ] && [[ $$VERSION == "v"* ]]; then echo "The version may not start with v" && exit 1; fi
|
||||
if [ -z ${VERSION} ]; then echo "Need to set VERSION" && exit 1; fi;
|
||||
|
||||
test-race:
|
||||
go test -race ./...
|
||||
|
||||
test-coverage:
|
||||
go test -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
go test --race -coverprofile=coverage.txt -covermode=atomic ./...
|
||||
|
||||
format:
|
||||
goimports -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
|
||||
|
|
@ -38,7 +36,7 @@ check-js:
|
|||
(cd ui && yarn testformat)
|
||||
|
||||
download-tools:
|
||||
go install github.com/go-swagger/go-swagger/cmd/swagger@v0.26.1
|
||||
go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5
|
||||
|
||||
update-swagger:
|
||||
swagger generate spec --scan-models -o docs/spec.json
|
||||
|
|
@ -124,7 +122,7 @@ build-docker-riscv64: require-version
|
|||
build-docker: build-docker-amd64 build-docker-arm-7 build-docker-arm64 build-docker-riscv64
|
||||
|
||||
build-js:
|
||||
(cd ui && yarn build)
|
||||
(cd ui && NODE_OPTIONS="${NODE_OPTIONS}" yarn build)
|
||||
|
||||
build-linux-amd64:
|
||||
${DOCKER_RUN} ${DOCKER_BUILD_IMAGE}:$(GO_VERSION)-linux-amd64 ${DOCKER_GO_BUILD} -o ${BUILD_DIR}/gotify-linux-amd64 ${DOCKER_WORKDIR}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ type ApplicationAPI struct {
|
|||
|
||||
// Application Params Model
|
||||
//
|
||||
// Params allowed to create or update Applications
|
||||
// Params allowed to create or update Applications.
|
||||
//
|
||||
// swagger:model ApplicationParams
|
||||
type ApplicationParams struct {
|
||||
|
|
@ -55,34 +55,34 @@ type ApplicationParams struct {
|
|||
//
|
||||
// Create an application.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the application to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ApplicationParams"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the application to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ApplicationParams"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ApplicationAPI) CreateApplication(ctx *gin.Context) {
|
||||
applicationParams := ApplicationParams{}
|
||||
if err := ctx.Bind(&applicationParams); err == nil {
|
||||
|
|
@ -107,25 +107,25 @@ func (a *ApplicationAPI) CreateApplication(ctx *gin.Context) {
|
|||
//
|
||||
// Return all applications.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ApplicationAPI) GetApplications(ctx *gin.Context) {
|
||||
userID := auth.GetUserID(ctx)
|
||||
apps, err := a.DB.GetApplicationsByUser(userID)
|
||||
|
|
@ -143,36 +143,36 @@ func (a *ApplicationAPI) GetApplications(ctx *gin.Context) {
|
|||
//
|
||||
// Delete an application.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ApplicationAPI) DeleteApplication(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
app, err := a.DB.GetApplicationByID(id)
|
||||
|
|
@ -201,44 +201,44 @@ func (a *ApplicationAPI) DeleteApplication(ctx *gin.Context) {
|
|||
//
|
||||
// Update an application.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the application to update
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ApplicationParams"
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the application to update
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ApplicationParams"
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
app, err := a.DB.GetApplicationByID(id)
|
||||
|
|
@ -268,48 +268,48 @@ func (a *ApplicationAPI) UpdateApplication(ctx *gin.Context) {
|
|||
//
|
||||
// Upload an image for an application.
|
||||
//
|
||||
// ---
|
||||
// consumes:
|
||||
// - multipart/form-data
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: file
|
||||
// in: formData
|
||||
// description: the application image
|
||||
// required: true
|
||||
// type: file
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes:
|
||||
// - multipart/form-data
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: file
|
||||
// in: formData
|
||||
// description: the application image
|
||||
// required: true
|
||||
// type: file
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Application"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ApplicationAPI) UploadApplicationImage(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
app, err := a.DB.GetApplicationByID(id)
|
||||
|
|
@ -369,40 +369,40 @@ func (a *ApplicationAPI) UploadApplicationImage(ctx *gin.Context) {
|
|||
//
|
||||
// Deletes an image of an application.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ApplicationAPI) RemoveApplicationImage(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
app, err := a.DB.GetApplicationByID(id)
|
||||
|
|
|
|||
232
api/client.go
232
api/client.go
|
|
@ -27,7 +27,7 @@ type ClientAPI struct {
|
|||
|
||||
// Client Params Model
|
||||
//
|
||||
// Params allowed to create or update Clients
|
||||
// Params allowed to create or update Clients.
|
||||
//
|
||||
// swagger:model ClientParams
|
||||
type ClientParams struct {
|
||||
|
|
@ -43,44 +43,44 @@ type ClientParams struct {
|
|||
//
|
||||
// Update a client.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the client to update
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ClientParams"
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the client id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Client"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the client to update
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ClientParams"
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the client id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Client"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ClientAPI) UpdateClient(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
client, err := a.DB.GetClientByID(id)
|
||||
|
|
@ -108,34 +108,34 @@ func (a *ClientAPI) UpdateClient(ctx *gin.Context) {
|
|||
//
|
||||
// Create a client.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the client to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ClientParams"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Client"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the client to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/ClientParams"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Client"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ClientAPI) CreateClient(ctx *gin.Context) {
|
||||
clientParams := ClientParams{}
|
||||
if err := ctx.Bind(&clientParams); err == nil {
|
||||
|
|
@ -157,25 +157,25 @@ func (a *ClientAPI) CreateClient(ctx *gin.Context) {
|
|||
//
|
||||
// Return all clients.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/Client"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/Client"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ClientAPI) GetClients(ctx *gin.Context) {
|
||||
userID := auth.GetUserID(ctx)
|
||||
clients, err := a.DB.GetClientsByUser(userID)
|
||||
|
|
@ -190,36 +190,36 @@ func (a *ClientAPI) GetClients(ctx *gin.Context) {
|
|||
//
|
||||
// Delete a client.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the client id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the client id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *ClientAPI) DeleteClient(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
client, err := a.DB.GetClientByID(id)
|
||||
|
|
|
|||
|
|
@ -20,17 +20,17 @@ type HealthAPI struct {
|
|||
//
|
||||
// Get health information.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Health"
|
||||
// 500:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Health"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Health"
|
||||
// 500:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Health"
|
||||
func (a *HealthAPI) Health(ctx *gin.Context) {
|
||||
if err := a.DB.Ping(); err != nil {
|
||||
ctx.JSON(500, model.Health{
|
||||
|
|
|
|||
365
api/message.go
365
api/message.go
|
|
@ -50,42 +50,42 @@ type pagingParams struct {
|
|||
//
|
||||
// Return all messages.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: limit
|
||||
// in: query
|
||||
// description: the maximal amount of messages to return
|
||||
// required: false
|
||||
// maximum: 200
|
||||
// minimum: 1
|
||||
// default: 100
|
||||
// type: integer
|
||||
// - name: since
|
||||
// in: query
|
||||
// description: return all messages with an ID less than this value
|
||||
// minimum: 0
|
||||
// required: false
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/PagedMessages"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: limit
|
||||
// in: query
|
||||
// description: the maximal amount of messages to return
|
||||
// required: false
|
||||
// maximum: 200
|
||||
// minimum: 1
|
||||
// default: 100
|
||||
// type: integer
|
||||
// - name: since
|
||||
// in: query
|
||||
// description: return all messages with an ID less than this value
|
||||
// minimum: 0
|
||||
// required: false
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/PagedMessages"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *MessageAPI) GetMessages(ctx *gin.Context) {
|
||||
userID := auth.GetUserID(ctx)
|
||||
withPaging(ctx, func(params *pagingParams) {
|
||||
|
|
@ -131,52 +131,52 @@ func withPaging(ctx *gin.Context, f func(pagingParams *pagingParams)) {
|
|||
//
|
||||
// Return all messages from a specific application.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// - name: limit
|
||||
// in: query
|
||||
// description: the maximal amount of messages to return
|
||||
// required: false
|
||||
// maximum: 200
|
||||
// minimum: 1
|
||||
// default: 100
|
||||
// type: integer
|
||||
// - name: since
|
||||
// in: query
|
||||
// description: return all messages with an ID less than this value
|
||||
// minimum: 0
|
||||
// required: false
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/PagedMessages"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// - name: limit
|
||||
// in: query
|
||||
// description: the maximal amount of messages to return
|
||||
// required: false
|
||||
// maximum: 200
|
||||
// minimum: 1
|
||||
// default: 100
|
||||
// type: integer
|
||||
// - name: since
|
||||
// in: query
|
||||
// description: return all messages with an ID less than this value
|
||||
// minimum: 0
|
||||
// required: false
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/PagedMessages"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *MessageAPI) GetMessagesWithApplication(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
withPaging(ctx, func(params *pagingParams) {
|
||||
|
|
@ -203,20 +203,20 @@ func (a *MessageAPI) GetMessagesWithApplication(ctx *gin.Context) {
|
|||
//
|
||||
// Delete all messages.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *MessageAPI) DeleteMessages(ctx *gin.Context) {
|
||||
userID := auth.GetUserID(ctx)
|
||||
successOrAbort(ctx, 500, a.DB.DeleteMessagesByUser(userID))
|
||||
|
|
@ -227,35 +227,35 @@ func (a *MessageAPI) DeleteMessages(ctx *gin.Context) {
|
|||
//
|
||||
// Delete all messages from a specific application.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the application id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
application, err := a.DB.GetApplicationByID(id)
|
||||
|
|
@ -275,35 +275,35 @@ func (a *MessageAPI) DeleteMessageWithApplication(ctx *gin.Context) {
|
|||
//
|
||||
// Deletes a message with an id.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the message id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the message id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *MessageAPI) DeleteMessage(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
msg, err := a.DB.GetMessageByID(id)
|
||||
|
|
@ -332,34 +332,35 @@ func (a *MessageAPI) DeleteMessage(ctx *gin.Context) {
|
|||
// Create a message.
|
||||
//
|
||||
// __NOTE__: This API ONLY accepts an application token as authentication.
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [appTokenAuthorizationHeader: [], appTokenHeader: [], appTokenQuery: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the message to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/Message"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Message"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [appTokenAuthorizationHeader: [], appTokenHeader: [], appTokenQuery: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the message to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/Message"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Message"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *MessageAPI) CreateMessage(ctx *gin.Context) {
|
||||
message := model.MessageExternal{}
|
||||
if err := ctx.Bind(&message); err == nil {
|
||||
|
|
|
|||
380
api/plugin.go
380
api/plugin.go
|
|
@ -33,33 +33,33 @@ type PluginAPI struct {
|
|||
//
|
||||
// Return all plugins.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/PluginConf"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/PluginConf"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (c *PluginAPI) GetPlugins(ctx *gin.Context) {
|
||||
userID := auth.GetUserID(ctx)
|
||||
plugins, err := c.DB.GetPluginConfByUser(userID)
|
||||
|
|
@ -91,36 +91,36 @@ func (c *PluginAPI) GetPlugins(ctx *gin.Context) {
|
|||
//
|
||||
// Enable a plugin.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (c *PluginAPI) EnablePlugin(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
conf, err := c.DB.GetPluginConfByID(id)
|
||||
|
|
@ -149,36 +149,36 @@ func (c *PluginAPI) EnablePlugin(ctx *gin.Context) {
|
|||
//
|
||||
// Disable a plugin.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (c *PluginAPI) DisablePlugin(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
conf, err := c.DB.GetPluginConfByID(id)
|
||||
|
|
@ -207,38 +207,38 @@ func (c *PluginAPI) DisablePlugin(ctx *gin.Context) {
|
|||
//
|
||||
// Get display info for a Displayer plugin.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: string
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: string
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (c *PluginAPI) GetDisplay(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
conf, err := c.DB.GetPluginConfByID(id)
|
||||
|
|
@ -263,43 +263,43 @@ func (c *PluginAPI) GetDisplay(ctx *gin.Context) {
|
|||
//
|
||||
// Get YAML configuration for Configurer plugin.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/x-yaml]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: object
|
||||
// description: plugin configuration
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/x-yaml]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: object
|
||||
// description: plugin configuration
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (c *PluginAPI) GetConfig(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
conf, err := c.DB.GetPluginConfByID(id)
|
||||
|
|
@ -330,40 +330,40 @@ func (c *PluginAPI) GetConfig(ctx *gin.Context) {
|
|||
//
|
||||
// Update YAML configuration for Configurer plugin.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/x-yaml]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/x-yaml]
|
||||
// produces: [application/json]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the plugin id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Internal Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (c *PluginAPI) UpdateConfig(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
conf, err := c.DB.GetPluginConfByID(id)
|
||||
|
|
|
|||
|
|
@ -115,31 +115,31 @@ func (a *API) register(client *client) {
|
|||
//
|
||||
// Websocket, return newly created messages.
|
||||
//
|
||||
// ---
|
||||
// schema: ws, wss
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Message"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// schema: ws, wss
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/Message"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 500:
|
||||
// description: Server Error
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *API) Handle(ctx *gin.Context) {
|
||||
conn, err := a.upgrader.Upgrade(ctx.Writer, ctx.Request, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
387
api/user.go
387
api/user.go
|
|
@ -69,24 +69,24 @@ type UserAPI struct {
|
|||
//
|
||||
// Return all users.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/User"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// type: array
|
||||
// items:
|
||||
// $ref: "#/definitions/User"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) GetUsers(ctx *gin.Context) {
|
||||
users, err := a.DB.GetUsers()
|
||||
if success := successOrAbort(ctx, 500, err); !success {
|
||||
|
|
@ -105,22 +105,22 @@ func (a *UserAPI) GetUsers(ctx *gin.Context) {
|
|||
//
|
||||
// Return the current user.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) GetCurrentUser(ctx *gin.Context) {
|
||||
user, err := a.DB.GetUserByID(auth.GetUserID(ctx))
|
||||
if success := successOrAbort(ctx, 500, err); !success {
|
||||
|
|
@ -137,34 +137,34 @@ func (a *UserAPI) GetCurrentUser(ctx *gin.Context) {
|
|||
// With enabled registration: non admin users can be created without authentication.
|
||||
// With disabled registrations: users can only be created by admin users.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the user to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/CreateUserExternal"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the user to add
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/CreateUserExternal"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) CreateUser(ctx *gin.Context) {
|
||||
user := model.CreateUserExternal{}
|
||||
if err := ctx.Bind(&user); err == nil {
|
||||
|
|
@ -223,38 +223,38 @@ func (a *UserAPI) CreateUser(ctx *gin.Context) {
|
|||
//
|
||||
// Get a user.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the user id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the user id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) GetUserByID(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
user, err := a.DB.GetUserByID(id)
|
||||
|
|
@ -274,35 +274,35 @@ func (a *UserAPI) GetUserByID(ctx *gin.Context) {
|
|||
//
|
||||
// Deletes a user.
|
||||
//
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the user id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the user id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) DeleteUserByID(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
user, err := a.DB.GetUserByID(id)
|
||||
|
|
@ -334,32 +334,32 @@ func (a *UserAPI) DeleteUserByID(ctx *gin.Context) {
|
|||
//
|
||||
// Update the password of the current user.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the user
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/UserPass"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the user
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/UserPass"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) ChangePassword(ctx *gin.Context) {
|
||||
pw := model.UserExternalPass{}
|
||||
if err := ctx.Bind(&pw); err == nil {
|
||||
|
|
@ -377,44 +377,44 @@ func (a *UserAPI) ChangePassword(ctx *gin.Context) {
|
|||
//
|
||||
// Update a user.
|
||||
//
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the user id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the updated user
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/UpdateUserExternal"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// ---
|
||||
// consumes: [application/json]
|
||||
// produces: [application/json]
|
||||
// security: [clientTokenAuthorizationHeader: [], clientTokenHeader: [], clientTokenQuery: [], basicAuth: []]
|
||||
// parameters:
|
||||
// - name: id
|
||||
// in: path
|
||||
// description: the user id
|
||||
// required: true
|
||||
// type: integer
|
||||
// format: int64
|
||||
// - name: body
|
||||
// in: body
|
||||
// description: the updated user
|
||||
// required: true
|
||||
// schema:
|
||||
// $ref: "#/definitions/UpdateUserExternal"
|
||||
// responses:
|
||||
// 200:
|
||||
// description: Ok
|
||||
// schema:
|
||||
// $ref: "#/definitions/User"
|
||||
// 400:
|
||||
// description: Bad Request
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 401:
|
||||
// description: Unauthorized
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 403:
|
||||
// description: Forbidden
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
// 404:
|
||||
// description: Not Found
|
||||
// schema:
|
||||
// $ref: "#/definitions/Error"
|
||||
func (a *UserAPI) UpdateUserByID(ctx *gin.Context) {
|
||||
withID(ctx, "id", func(id uint) {
|
||||
var user *model.UpdateUserExternal
|
||||
|
|
@ -452,19 +452,6 @@ func (a *UserAPI) UpdateUserByID(ctx *gin.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
func (a *UserAPI) toInternalUser(response *model.UserExternal, newPass string, pw []byte) *model.User {
|
||||
user := &model.User{
|
||||
Name: response.Name,
|
||||
Admin: response.Admin,
|
||||
}
|
||||
if newPass != "" {
|
||||
user.Pass = password.CreatePassword(newPass, a.PasswordStrength)
|
||||
} else {
|
||||
user.Pass = pw
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
||||
func toExternalUser(internal *model.User) *model.UserExternal {
|
||||
return &model.UserExternal{
|
||||
Name: internal.Name,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
//go:build !race
|
||||
// +build !race
|
||||
|
||||
package auth
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
//go:build !race
|
||||
// +build !race
|
||||
|
||||
package password
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -2,61 +2,61 @@
|
|||
//
|
||||
// This is the documentation of the Gotify REST-API.
|
||||
//
|
||||
// # Authentication
|
||||
// In Gotify there are two token types:
|
||||
// __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app)
|
||||
// __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script)
|
||||
// # Authentication
|
||||
// In Gotify there are two token types:
|
||||
// __clientToken__: a client is something that receives message and manages stuff like creating new tokens or delete messages. (f.ex this token should be used for an android app)
|
||||
// __appToken__: an application is something that sends messages (f.ex. this token should be used for a shell script)
|
||||
//
|
||||
// The token can be transmitted in a header named `X-Gotify-Key`, in a query parameter named `token` or
|
||||
// through a header named `Authorization` with the value prefixed with `Bearer` (Ex. `Bearer randomtoken`).
|
||||
// There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken.
|
||||
// The token can be transmitted in a header named `X-Gotify-Key`, in a query parameter named `token` or
|
||||
// through a header named `Authorization` with the value prefixed with `Bearer` (Ex. `Bearer randomtoken`).
|
||||
// There is also the possibility to authenticate through basic auth, this should only be used for creating a clientToken.
|
||||
//
|
||||
// \---
|
||||
// \---
|
||||
//
|
||||
// Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
// Found a bug or have some questions? [Create an issue on GitHub](https://github.com/gotify/server/issues)
|
||||
//
|
||||
// Schemes: http, https
|
||||
// Host: localhost
|
||||
// Version: 2.0.2
|
||||
// License: MIT https://github.com/gotify/server/blob/master/LICENSE
|
||||
// Schemes: http, https
|
||||
// Host: localhost
|
||||
// Version: 2.0.2
|
||||
// License: MIT https://github.com/gotify/server/blob/master/LICENSE
|
||||
//
|
||||
// Consumes:
|
||||
// - application/json
|
||||
// Consumes:
|
||||
// - application/json
|
||||
//
|
||||
// Produces:
|
||||
// - application/json
|
||||
// Produces:
|
||||
// - application/json
|
||||
//
|
||||
// SecurityDefinitions:
|
||||
// appTokenQuery:
|
||||
// type: apiKey
|
||||
// name: token
|
||||
// in: query
|
||||
// clientTokenQuery:
|
||||
// type: apiKey
|
||||
// name: token
|
||||
// in: query
|
||||
// appTokenHeader:
|
||||
// type: apiKey
|
||||
// name: X-Gotify-Key
|
||||
// in: header
|
||||
// clientTokenHeader:
|
||||
// type: apiKey
|
||||
// name: X-Gotify-Key
|
||||
// in: header
|
||||
// appTokenAuthorizationHeader:
|
||||
// type: apiKey
|
||||
// name: Authorization
|
||||
// in: header
|
||||
// description: >-
|
||||
// Enter an application token with the `Bearer` prefix, e.g. `Bearer Axxxxxxxxxx`.
|
||||
// clientTokenAuthorizationHeader:
|
||||
// type: apiKey
|
||||
// name: Authorization
|
||||
// in: header
|
||||
// description: >-
|
||||
// Enter a client token with the `Bearer` prefix, e.g. `Bearer Cxxxxxxxxxx`.
|
||||
// basicAuth:
|
||||
// type: basic
|
||||
// SecurityDefinitions:
|
||||
// appTokenQuery:
|
||||
// type: apiKey
|
||||
// name: token
|
||||
// in: query
|
||||
// clientTokenQuery:
|
||||
// type: apiKey
|
||||
// name: token
|
||||
// in: query
|
||||
// appTokenHeader:
|
||||
// type: apiKey
|
||||
// name: X-Gotify-Key
|
||||
// in: header
|
||||
// clientTokenHeader:
|
||||
// type: apiKey
|
||||
// name: X-Gotify-Key
|
||||
// in: header
|
||||
// appTokenAuthorizationHeader:
|
||||
// type: apiKey
|
||||
// name: Authorization
|
||||
// in: header
|
||||
// description: >-
|
||||
// Enter an application token with the `Bearer` prefix, e.g. `Bearer Axxxxxxxxxx`.
|
||||
// clientTokenAuthorizationHeader:
|
||||
// type: apiKey
|
||||
// name: Authorization
|
||||
// in: header
|
||||
// description: >-
|
||||
// Enter a client token with the `Bearer` prefix, e.g. `Bearer Cxxxxxxxxxx`.
|
||||
// basicAuth:
|
||||
// type: basic
|
||||
//
|
||||
// swagger:meta
|
||||
// swagger:meta
|
||||
package docs
|
||||
|
|
|
|||
|
|
@ -2123,7 +2123,7 @@
|
|||
"x-go-package": "github.com/gotify/server/v2/model"
|
||||
},
|
||||
"ApplicationParams": {
|
||||
"description": "Params allowed to create or update Applications",
|
||||
"description": "Params allowed to create or update Applications.",
|
||||
"type": "object",
|
||||
"title": "Application Params Model",
|
||||
"required": [
|
||||
|
|
@ -2195,7 +2195,7 @@
|
|||
"x-go-package": "github.com/gotify/server/v2/model"
|
||||
},
|
||||
"ClientParams": {
|
||||
"description": "Params allowed to create or update Clients",
|
||||
"description": "Params allowed to create or update Clients.",
|
||||
"type": "object",
|
||||
"title": "Client Params Model",
|
||||
"required": [
|
||||
|
|
@ -2328,9 +2328,7 @@
|
|||
"extras": {
|
||||
"description": "The extra data sent along the message.\n\nThe extra fields are stored in a key-value scheme. Only accepted in CreateMessage requests with application/json content-type.\n\nThe keys should be in the following format: \u0026lt;top-namespace\u0026gt;::[\u0026lt;sub-namespace\u0026gt;::]\u0026lt;action\u0026gt;\n\nThese namespaces are reserved and might be used in the official clients: gotify android ios web server client. Do not use them for other purposes.",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "object"
|
||||
},
|
||||
"additionalProperties": {},
|
||||
"x-go-name": "Extras",
|
||||
"example": {
|
||||
"home::appliances::lighting::on": {
|
||||
|
|
@ -2373,7 +2371,7 @@
|
|||
"x-go-package": "github.com/gotify/server/v2/model"
|
||||
},
|
||||
"PagedMessages": {
|
||||
"description": "Wrapper for the paging and the messages",
|
||||
"description": "Wrapper for the paging and the messages.",
|
||||
"type": "object",
|
||||
"title": "PagedMessages Model",
|
||||
"required": [
|
||||
|
|
|
|||
8
go.mod
8
go.mod
|
|
@ -5,7 +5,7 @@ require (
|
|||
github.com/gin-contrib/cors v1.4.0
|
||||
github.com/gin-contrib/gzip v0.0.6
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/go-playground/validator/v10 v10.14.1
|
||||
github.com/go-playground/validator/v10 v10.15.4
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/gotify/configor v1.0.2
|
||||
github.com/gotify/location v0.0.0-20170722210143-03bc4ad20437
|
||||
|
|
@ -14,7 +14,7 @@ require (
|
|||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/robfig/cron v1.2.0
|
||||
github.com/stretchr/testify v1.8.4
|
||||
golang.org/x/crypto v0.11.0
|
||||
golang.org/x/crypto v0.13.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
||||
|
|
@ -46,8 +46,8 @@ require (
|
|||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.10.0 // indirect
|
||||
golang.org/x/text v0.11.0 // indirect
|
||||
golang.org/x/sys v0.12.0 // indirect
|
||||
golang.org/x/text v0.13.0 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
|
|||
16
go.sum
16
go.sum
|
|
@ -41,8 +41,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl
|
|||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
|
||||
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
|
||||
github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-yaml/yaml v2.1.0+incompatible h1:RYi2hDdss1u4YE7GwixGzWwVo47T8UQwnTLB6vQiq+o=
|
||||
|
|
@ -147,8 +147,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
|
|||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
|
||||
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
|
||||
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190110200230-915654e7eabc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
|
|
@ -168,14 +168,14 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
|
||||
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ type Paging struct {
|
|||
|
||||
// PagedMessages Model
|
||||
//
|
||||
// Wrapper for the paging and the messages
|
||||
// Wrapper for the paging and the messages.
|
||||
//
|
||||
// swagger:model PagedMessages
|
||||
type PagedMessages struct {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
//go:build (linux || darwin) && !race
|
||||
//go:build linux || darwin
|
||||
// +build linux darwin
|
||||
// +build !race
|
||||
|
||||
package plugin
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue