Skip to content

Commit

Permalink
Merge pull request #551 from application-research/gabe/annotate-invit…
Browse files Browse the repository at this point in the history
…es-api

Annotate invites api
  • Loading branch information
en0ma committed Nov 21, 2022
2 parents b5b388f + 02b0653 commit 969b9a7
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 0 deletions.
70 changes: 70 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,76 @@ const docTemplate = `{
}
}
},
"/admin/invites": {
"get": {
"description": "This endpoint is used to list all estuary invites.",
"produces": [
"application/json"
],
"tags": [
"content"
],
"summary": "Get Estuary invites",
"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 is used to create an estuary invite.",
"produces": [
"application/json"
],
"tags": [
"content"
],
"summary": "Create an Estuary invite",
"parameters": [
{
"type": "string",
"description": "Invite code to be created",
"name": "code",
"in": "path"
}
],
"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/peers": {
"get": {
"description": "This endpoint can be used to list all peers on Peering Service",
Expand Down
70 changes: 70 additions & 0 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,76 @@
}
}
},
"/admin/invites": {
"get": {
"description": "This endpoint is used to list all estuary invites.",
"produces": [
"application/json"
],
"tags": [
"content"
],
"summary": "Get Estuary invites",
"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 is used to create an estuary invite.",
"produces": [
"application/json"
],
"tags": [
"content"
],
"summary": "Create an Estuary invite",
"parameters": [
{
"type": "string",
"description": "Invite code to be created",
"name": "code",
"in": "path"
}
],
"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/peers": {
"get": {
"description": "This endpoint can be used to list all peers on Peering Service",
Expand Down
46 changes: 46 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,52 @@ paths:
summary: List autoretrieve servers
tags:
- autoretrieve
/admin/invites:
get:
description: This endpoint is used to list all estuary invites.
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: Get Estuary invites
tags:
- content
post:
description: This endpoint is used to create an estuary invite.
parameters:
- description: Invite code to be created
in: path
name: code
type: string
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: Create an Estuary invite
tags:
- content
/admin/peering/peers:
delete:
description: This endpoint can be used to remove a Peer from the Peering Service
Expand Down
19 changes: 19 additions & 0 deletions handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1955,6 +1955,15 @@ type getInvitesResp struct {
CreatedAt string `json:"createdAt"`
}

// handleAdminGetInvites godoc
// @Summary Get Estuary invites
// @Description This endpoint is used to list all estuary invites.
// @Tags content
// @Produce json
// @Success 200 {object} string
// @Failure 400 {object} util.HttpError
// @Failure 500 {object} util.HttpError
// @Router /admin/invites [get]
func (s *Server) handleAdminGetInvites(c echo.Context) error {
var invites []getInvitesResp
if err := s.DB.Model(&util.InviteCode{}).
Expand All @@ -1969,6 +1978,16 @@ func (s *Server) handleAdminGetInvites(c echo.Context) error {
return c.JSON(http.StatusOK, invites)
}

// handleAdminCreateInvite godoc
// @Summary Create an Estuary invite
// @Description This endpoint is used to create an estuary invite.
// @Tags content
// @Produce json
// @Success 200 {object} string
// @Failure 400 {object} util.HttpError
// @Failure 500 {object} util.HttpError
// @Param code path string false "Invite code to be created"
// @Router /admin/invites [post]
func (s *Server) handleAdminCreateInvite(c echo.Context, u *util.User) error {
code := c.Param("code")
invite := &util.InviteCode{
Expand Down

0 comments on commit 969b9a7

Please sign in to comment.