From 47ae7d7dcaba59ee604da224ad54fd8f85a3e35b Mon Sep 17 00:00:00 2001 From: toast Date: Wed, 30 Nov 2022 03:14:44 -0700 Subject: [PATCH 1/5] peering/peers to peering-peers --- handlers.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/handlers.go b/handlers.go index f464ae87..5dddc459 100644 --- a/handlers.go +++ b/handlers.go @@ -282,15 +282,19 @@ func (s *Server) ServeAPI() error { admin.POST("/cm/transfer/restart/:chanid", s.handleTransferRestart) admin.POST("/cm/repinall/:shuttle", s.handleShuttleRepinAll) - // peering + // peering endpoints that manage the service itself adminPeering := admin.Group("/peering") - adminPeering.POST("/peers", s.handlePeeringPeersAdd) - adminPeering.DELETE("/peers", s.handlePeeringPeersRemove) - adminPeering.GET("/peers", s.handlePeeringPeersList) adminPeering.POST("/start", s.handlePeeringStart) adminPeering.POST("/stop", s.handlePeeringStop) adminPeering.GET("/status", s.handlePeeringStatus) + // peering endpoints that manage peers connected to the service + adminPeers := e.Group("/peering-peers") + adminPeers.Use(s.AuthRequired(util.PermLevelAdmin)) + adminPeers.POST("", s.handlePeeringPeersAdd) + adminPeers.DELETE("", s.handlePeeringPeersRemove) + adminPeers.GET("", s.handlePeeringPeersList) + admnetw := admin.Group("/net") admnetw.GET("/peers", s.handleNetPeers) @@ -1635,8 +1639,8 @@ func (s *Server) handleMakeDeal(c echo.Context, u *util.User) error { }) } -//from datatransfer.ChannelID and used for swagger docs -//if we don't redefine this here, we'll need to enable parse dependences for swagger and it will take a really long time +// from datatransfer.ChannelID and used for swagger docs +// if we don't redefine this here, we'll need to enable parse dependences for swagger and it will take a really long time type ChannelIDParam struct { Initiator string Responder string From 22d2e504bcaa1de9cfef327ed191d12fba2f6d0d Mon Sep 17 00:00:00 2001 From: toast Date: Wed, 30 Nov 2022 03:15:53 -0700 Subject: [PATCH 2/5] updated godocs for new peering-peers route --- handlers.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/handlers.go b/handlers.go index 5dddc459..5e94ee7d 100644 --- a/handlers.go +++ b/handlers.go @@ -460,7 +460,7 @@ func (s *Server) handleStats(c echo.Context, u *util.User) error { // @Success 200 {object} string // @Failure 400 {object} util.HttpError // @Failure 500 {object} util.HttpError -// @Router /admin/peering/peers [post] +// @Router /peering-peers [post] func (s *Server) handlePeeringPeersAdd(c echo.Context) error { var params []peering.PeeringPeer if err := c.Bind(¶ms); err != nil { @@ -524,7 +524,7 @@ type peerIDs []peerID // used for swagger // @Failure 400 {object} util.HttpError // @Failure 500 {object} util.HttpError // @Param peerIds body peerIDs true "Peer ids" -// @Router /admin/peering/peers [delete] +// @Router /peering-peers [delete] func (s *Server) handlePeeringPeersRemove(c echo.Context) error { var params []peer.ID @@ -549,7 +549,7 @@ func (s *Server) handlePeeringPeersRemove(c echo.Context) error { // @Success 200 {object} string // @Failure 400 {object} util.HttpError // @Failure 500 {object} util.HttpError -// @Router /admin/peering/peers [get] +// @Router /peering-peers [get] func (s *Server) handlePeeringPeersList(c echo.Context) error { var connectionCheck []peering.PeeringPeer for _, peerAddrInfo := range s.Node.Peering.ListPeers() { From 3f0b0f14045e4e0f1c8d49a5c6fbd0e789aab425 Mon Sep 17 00:00:00 2001 From: toast Date: Wed, 30 Nov 2022 03:17:07 -0700 Subject: [PATCH 3/5] moved GET to first so GET POST DELETE is maintained --- handlers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers.go b/handlers.go index 5e94ee7d..7cdfaed7 100644 --- a/handlers.go +++ b/handlers.go @@ -291,9 +291,9 @@ func (s *Server) ServeAPI() error { // peering endpoints that manage peers connected to the service adminPeers := e.Group("/peering-peers") adminPeers.Use(s.AuthRequired(util.PermLevelAdmin)) + adminPeers.GET("", s.handlePeeringPeersList) adminPeers.POST("", s.handlePeeringPeersAdd) adminPeers.DELETE("", s.handlePeeringPeersRemove) - adminPeers.GET("", s.handlePeeringPeersList) admnetw := admin.Group("/net") admnetw.GET("/peers", s.handleNetPeers) From c9e5208d366f4e94a5554c2f2d6d12a6fe66d26e Mon Sep 17 00:00:00 2001 From: toastts Date: Wed, 30 Nov 2022 10:18:43 +0000 Subject: [PATCH 4/5] docs: update swagger docs --- docs/docs.go | 224 +++++++++++++++++++++++----------------------- docs/swagger.json | 224 +++++++++++++++++++++++----------------------- docs/swagger.yaml | 152 +++++++++++++++---------------- 3 files changed, 300 insertions(+), 300 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index ca01a25e..a2e537a3 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -174,118 +174,6 @@ const docTemplate = `{ } } }, - "/admin/peering/peers": { - "get": { - "description": "This endpoint can be used to list all peers on Peering Service", - "produces": [ - "application/json" - ], - "tags": [ - "admin", - "peering", - "peers" - ], - "summary": "List all Peering peers", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - } - } - }, - "post": { - "description": "This endpoint can be used to add a Peer from the Peering Service", - "produces": [ - "application/json" - ], - "tags": [ - "admin", - "peering", - "peers" - ], - "summary": "Add peers on Peering Service", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - } - } - }, - "delete": { - "description": "This endpoint can be used to remove a Peer from the Peering Service", - "produces": [ - "application/json" - ], - "tags": [ - "admin", - "peering", - "peers" - ], - "summary": "Remove peers on Peering Service", - "parameters": [ - { - "description": "Peer ids", - "name": "peerIds", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "boolean" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - } - } - } - }, "/admin/peering/start": { "post": { "description": "This endpoint can be used to start the Peering Service", @@ -2124,6 +2012,118 @@ const docTemplate = `{ } } }, + "/peering-peers": { + "get": { + "description": "This endpoint can be used to list all peers on Peering Service", + "produces": [ + "application/json" + ], + "tags": [ + "admin", + "peering", + "peers" + ], + "summary": "List all Peering peers", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + } + } + }, + "post": { + "description": "This endpoint can be used to add a Peer from the Peering Service", + "produces": [ + "application/json" + ], + "tags": [ + "admin", + "peering", + "peers" + ], + "summary": "Add peers on Peering Service", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + } + } + }, + "delete": { + "description": "This endpoint can be used to remove a Peer from the Peering Service", + "produces": [ + "application/json" + ], + "tags": [ + "admin", + "peering", + "peers" + ], + "summary": "Remove peers on Peering Service", + "parameters": [ + { + "description": "Peer ids", + "name": "peerIds", + "in": "body", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "boolean" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + } + } + } + }, "/pinning/pins": { "get": { "description": "This endpoint lists all pin status objects", diff --git a/docs/swagger.json b/docs/swagger.json index 172ace5c..fd9d11e3 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -167,118 +167,6 @@ } } }, - "/admin/peering/peers": { - "get": { - "description": "This endpoint can be used to list all peers on Peering Service", - "produces": [ - "application/json" - ], - "tags": [ - "admin", - "peering", - "peers" - ], - "summary": "List all Peering peers", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - } - } - }, - "post": { - "description": "This endpoint can be used to add a Peer from the Peering Service", - "produces": [ - "application/json" - ], - "tags": [ - "admin", - "peering", - "peers" - ], - "summary": "Add peers on Peering Service", - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - } - } - }, - "delete": { - "description": "This endpoint can be used to remove a Peer from the Peering Service", - "produces": [ - "application/json" - ], - "tags": [ - "admin", - "peering", - "peers" - ], - "summary": "Remove peers on Peering Service", - "parameters": [ - { - "description": "Peer ids", - "name": "peerIds", - "in": "body", - "required": true, - "schema": { - "type": "array", - "items": { - "type": "boolean" - } - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - }, - "500": { - "description": "Internal Server Error", - "schema": { - "$ref": "#/definitions/util.HttpError" - } - } - } - } - }, "/admin/peering/start": { "post": { "description": "This endpoint can be used to start the Peering Service", @@ -2117,6 +2005,118 @@ } } }, + "/peering-peers": { + "get": { + "description": "This endpoint can be used to list all peers on Peering Service", + "produces": [ + "application/json" + ], + "tags": [ + "admin", + "peering", + "peers" + ], + "summary": "List all Peering peers", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + } + } + }, + "post": { + "description": "This endpoint can be used to add a Peer from the Peering Service", + "produces": [ + "application/json" + ], + "tags": [ + "admin", + "peering", + "peers" + ], + "summary": "Add peers on Peering Service", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + } + } + }, + "delete": { + "description": "This endpoint can be used to remove a Peer from the Peering Service", + "produces": [ + "application/json" + ], + "tags": [ + "admin", + "peering", + "peers" + ], + "summary": "Remove peers on Peering Service", + "parameters": [ + { + "description": "Peer ids", + "name": "peerIds", + "in": "body", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "boolean" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/util.HttpError" + } + } + } + } + }, "/pinning/pins": { "get": { "description": "This endpoint lists all pin status objects", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 674327de..3fc28808 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -280,82 +280,6 @@ paths: summary: Create an Estuary invite tags: - content - /admin/peering/peers: - delete: - description: This endpoint can be used to remove a Peer from the Peering Service - parameters: - - description: Peer ids - in: body - name: peerIds - required: true - schema: - items: - type: boolean - type: array - produces: - - application/json - responses: - "200": - description: OK - schema: - type: string - "400": - description: Bad Request - schema: - $ref: '#/definitions/util.HttpError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/util.HttpError' - summary: Remove peers on Peering Service - tags: - - admin - - peering - - peers - get: - description: This endpoint can be used to list all peers on Peering Service - produces: - - application/json - responses: - "200": - description: OK - schema: - type: string - "400": - description: Bad Request - schema: - $ref: '#/definitions/util.HttpError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/util.HttpError' - summary: List all Peering peers - tags: - - admin - - peering - - peers - post: - description: This endpoint can be used to add a Peer from the Peering Service - produces: - - application/json - responses: - "200": - description: OK - schema: - type: string - "400": - description: Bad Request - schema: - $ref: '#/definitions/util.HttpError' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/util.HttpError' - summary: Add peers on Peering Service - tags: - - admin - - peering - - peers /admin/peering/start: post: description: This endpoint can be used to start the Peering Service @@ -1569,6 +1493,82 @@ paths: summary: Net Addrs tags: - net + /peering-peers: + delete: + description: This endpoint can be used to remove a Peer from the Peering Service + parameters: + - description: Peer ids + in: body + name: peerIds + required: true + schema: + items: + type: boolean + type: array + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + "400": + description: Bad Request + schema: + $ref: '#/definitions/util.HttpError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/util.HttpError' + summary: Remove peers on Peering Service + tags: + - admin + - peering + - peers + get: + description: This endpoint can be used to list all peers on Peering Service + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + "400": + description: Bad Request + schema: + $ref: '#/definitions/util.HttpError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/util.HttpError' + summary: List all Peering peers + tags: + - admin + - peering + - peers + post: + description: This endpoint can be used to add a Peer from the Peering Service + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + "400": + description: Bad Request + schema: + $ref: '#/definitions/util.HttpError' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/util.HttpError' + summary: Add peers on Peering Service + tags: + - admin + - peering + - peers /pinning/pins: get: description: This endpoint lists all pin status objects From 86c49e14e8965947ea810b95c2103e672c9400b0 Mon Sep 17 00:00:00 2001 From: toastts <60305597+toastts@users.noreply.github.com> Date: Tue, 13 Dec 2022 08:39:06 -0700 Subject: [PATCH 5/5] change echo group name for clarity Co-authored-by: Gabriel Cruz <8129788+gmelodie@users.noreply.github.com> --- handlers.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/handlers.go b/handlers.go index 7cdfaed7..8dcf8bc9 100644 --- a/handlers.go +++ b/handlers.go @@ -289,11 +289,11 @@ func (s *Server) ServeAPI() error { adminPeering.GET("/status", s.handlePeeringStatus) // peering endpoints that manage peers connected to the service - adminPeers := e.Group("/peering-peers") - adminPeers.Use(s.AuthRequired(util.PermLevelAdmin)) - adminPeers.GET("", s.handlePeeringPeersList) - adminPeers.POST("", s.handlePeeringPeersAdd) - adminPeers.DELETE("", s.handlePeeringPeersRemove) + peeringPeers := e.Group("/peering-peers", s.AuthRequired(util.PermLevelAdmin)) + peeringPeers.GET("", s.handlePeeringPeersList) + peeringPeers.POST("", s.handlePeeringPeersAdd) + peeringPeers.DELETE("", s.handlePeeringPeersRemove) + admnetw := admin.Group("/net") admnetw.GET("/peers", s.handleNetPeers)