Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate invites api #551

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2063,6 +2063,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 @@ -2077,6 +2086,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