diff --git a/scnserver/api/handler/apiChannel.go b/scnserver/api/handler/apiChannel.go index e9d8ece..50cf78f 100644 --- a/scnserver/api/handler/apiChannel.go +++ b/scnserver/api/handler/apiChannel.go @@ -1,19 +1,20 @@ package handler import ( + "database/sql" + "errors" + "fmt" + "net/http" + "strings" + "blackforestbytes.com/simplecloudnotifier/api/apierr" "blackforestbytes.com/simplecloudnotifier/api/ginresp" ct "blackforestbytes.com/simplecloudnotifier/db/cursortoken" "blackforestbytes.com/simplecloudnotifier/logic" "blackforestbytes.com/simplecloudnotifier/models" - "database/sql" - "errors" - "fmt" "git.blackforestbytes.com/BlackForestBytes/goext/ginext" "git.blackforestbytes.com/BlackForestBytes/goext/langext" "git.blackforestbytes.com/BlackForestBytes/goext/mathext" - "net/http" - "strings" ) // ListChannels swaggerdoc @@ -487,7 +488,7 @@ func (h APIHandler) ListChannelMessages(pctx ginext.PreContext) ginext.HTTPRespo // @Failure 404 {object} ginresp.apiError "channel not found" // @Failure 500 {object} ginresp.apiError "internal server error" // -// @Router /api/v2/users/{uid}/channels/{cid} [PATCH] +// @Router /api/v2/users/{uid}/channels/{cid} [DELETE] func (h APIHandler) DeleteChannel(pctx ginext.PreContext) ginext.HTTPResponse { type uri struct { UserID models.UserID `uri:"uid" binding:"entityid"` diff --git a/scnserver/api/handler/apiSenderNames.go b/scnserver/api/handler/apiSenderNames.go index b89d8a5..74a48fb 100644 --- a/scnserver/api/handler/apiSenderNames.go +++ b/scnserver/api/handler/apiSenderNames.go @@ -1,12 +1,13 @@ package handler import ( + "net/http" + "blackforestbytes.com/simplecloudnotifier/api/apierr" "blackforestbytes.com/simplecloudnotifier/api/ginresp" "blackforestbytes.com/simplecloudnotifier/logic" "blackforestbytes.com/simplecloudnotifier/models" "git.blackforestbytes.com/BlackForestBytes/goext/ginext" - "net/http" ) // ListUserSenderNames swaggerdoc @@ -23,7 +24,7 @@ import ( // @Failure 404 {object} ginresp.apiError "message not found" // @Failure 500 {object} ginresp.apiError "internal server error" // -// @Router /api/v2/users/{uid}/keys [GET] +// @Router /api/v2/users/{uid}/sender-names [GET] func (h APIHandler) ListUserSenderNames(pctx ginext.PreContext) ginext.HTTPResponse { type uri struct { UserID models.UserID `uri:"uid" binding:"entityid"` diff --git a/scnserver/swagger/swagger.json b/scnserver/swagger/swagger.json index 9b5633f..68cdfdc 100644 --- a/scnserver/swagger/swagger.json +++ b/scnserver/swagger/swagger.json @@ -1656,7 +1656,7 @@ } } }, - "patch": { + "delete": { "tags": [ "API-v2" ], @@ -1710,6 +1710,85 @@ } } } + }, + "patch": { + "tags": [ + "API-v2" + ], + "summary": "(Partially) update a channel", + "operationId": "api-channels-update", + "parameters": [ + { + "type": "string", + "description": "UserID", + "name": "uid", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "ChannelID", + "name": "cid", + "in": "path", + "required": true + }, + { + "description": "Send `true` to create a new subscribe_key", + "name": "subscribe_key", + "in": "body", + "schema": { + "type": "string" + } + }, + { + "description": "Send `true` to create a new send_key", + "name": "send_key", + "in": "body", + "schema": { + "type": "string" + } + }, + { + "description": "Change the cahnnel display-name (only chnages to lowercase/uppercase are allowed - internal_name must stay the same)", + "name": "display_name", + "in": "body", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/models.ChannelWithSubscription" + } + }, + "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/users/{uid}/channels/{cid}/messages": { @@ -2122,11 +2201,12 @@ }, "/api/v2/users/{uid}/keys": { "get": { + "description": "The request must be done with an ADMIN key, the returned keys are without their token.", "tags": [ "API-v2" ], - "summary": "List sender-names (of allthe messages of this user)", - "operationId": "api-usersendernames-list", + "summary": "List keys of the user", + "operationId": "api-tokenkeys-list", "parameters": [ { "type": "string", @@ -2461,6 +2541,56 @@ } } }, + "/api/v2/users/{uid}/sender-names": { + "get": { + "tags": [ + "API-v2" + ], + "summary": "List sender-names (of allthe messages of this user)", + "operationId": "api-usersendernames-list", + "parameters": [ + { + "type": "string", + "description": "UserID", + "name": "uid", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/handler.ListUserKeys.response" + } + }, + "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/users/{uid}/subscriptions": { "get": { "description": "The possible values for 'direction' are:\n- \"outgoing\" Subscriptions with the user as subscriber (= subscriptions he can use to read channels)\n- \"incoming\" Subscriptions to channels of this user (= incoming subscriptions and subscription requests)\n- \"both\" Combines \"outgoing\" and \"incoming\" (default)\n\nThe possible values for 'confirmation' are:\n- \"confirmed\" Confirmed (active) subscriptions\n- \"unconfirmed\" Unconfirmed (pending) subscriptions\n- \"all\" Combines \"confirmed\" and \"unconfirmed\" (default)\n\nThe possible values for 'external' are:\n- \"true\" Subscriptions with subscriber_user_id != channel_owner_user_id (subscriptions from other users)\n- \"false\" Subscriptions with subscriber_user_id == channel_owner_user_id (subscriptions from this user to his own channels)\n- \"all\" Combines \"external\" and \"internal\" (default)\n\nThe `subscriber_user_id` parameter can be used to additionally filter the subscriber_user_id (return subscribtions from a specific user)\n\nThe `channel_owner_user_id` parameter can be used to additionally filter the channel_owner_user_id (return subscribtions to a specific user)", diff --git a/scnserver/swagger/swagger.yaml b/scnserver/swagger/swagger.yaml index 9c64061..2160307 100644 --- a/scnserver/swagger/swagger.yaml +++ b/scnserver/swagger/swagger.yaml @@ -1954,6 +1954,43 @@ paths: tags: - API-v2 /api/v2/users/{uid}/channels/{cid}: + delete: + operationId: api-channels-delete + parameters: + - description: UserID + in: path + name: uid + required: true + type: string + - description: ChannelID + in: path + name: cid + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/models.Channel' + "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: delete a channel (including all messages, subscriptions, etc) + tags: + - API-v2 get: operationId: api-channels-get parameters: @@ -1992,7 +2029,7 @@ paths: tags: - API-v2 patch: - operationId: api-channels-delete + operationId: api-channels-update parameters: - description: UserID in: path @@ -2004,11 +2041,27 @@ paths: name: cid required: true type: string + - description: Send `true` to create a new subscribe_key + in: body + name: subscribe_key + schema: + type: string + - description: Send `true` to create a new send_key + in: body + name: send_key + schema: + type: string + - description: Change the cahnnel display-name (only chnages to lowercase/uppercase + are allowed - internal_name must stay the same) + in: body + name: display_name + schema: + type: string responses: "200": description: OK schema: - $ref: '#/definitions/models.Channel' + $ref: '#/definitions/models.ChannelWithSubscription' "400": description: supplied values/parameters cannot be parsed / are invalid schema: @@ -2025,7 +2078,7 @@ paths: description: internal server error schema: $ref: '#/definitions/ginresp.apiError' - summary: delete a channel (including all messages, subscriptions, etc) + summary: (Partially) update a channel tags: - API-v2 /api/v2/users/{uid}/channels/{cid}/messages: @@ -2305,7 +2358,9 @@ paths: - API-v2 /api/v2/users/{uid}/keys: get: - operationId: api-usersendernames-list + description: The request must be done with an ADMIN key, the returned keys are + without their token. + operationId: api-tokenkeys-list parameters: - description: UserID in: path @@ -2333,7 +2388,7 @@ paths: description: internal server error schema: $ref: '#/definitions/ginresp.apiError' - summary: List sender-names (of allthe messages of this user) + summary: List keys of the user tags: - API-v2 post: @@ -2533,6 +2588,39 @@ paths: summary: Get the key currently used by this request tags: - API-v2 + /api/v2/users/{uid}/sender-names: + get: + operationId: api-usersendernames-list + parameters: + - description: UserID + in: path + name: uid + required: true + type: string + responses: + "200": + description: OK + schema: + $ref: '#/definitions/handler.ListUserKeys.response' + "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: List sender-names (of allthe messages of this user) + tags: + - API-v2 /api/v2/users/{uid}/subscriptions: get: description: |-