Skip to content

Commit

Permalink
feat: /teams API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
moul committed Oct 3, 2019
1 parent 6457c52 commit 045c18f
Show file tree
Hide file tree
Showing 14 changed files with 219 additions and 87 deletions.
3 changes: 1 addition & 2 deletions api/pwengine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ service Engine {
rpc Ping(Void) returns (Void) { option (google.api.http) = {get: "/ping"}; };
// Get current user session, based on JWT token
rpc GetUserSession(Void) returns (UserSessionOutput) { option (google.api.http) = {get: "/user-session"}; };
// List users
rpc ListLevels(Void) returns (pathwar.db.LevelList) { option (google.api.http) = {get: "/levels"}; };
// List teams
rpc ListTeams(Void) returns (pathwar.db.TeamList) { option (google.api.http) = {get: "/teams"}; };
rpc GetStatus(Void) returns (Status) { option (google.api.http) = {get: "/status"}; }

//
Expand Down
2 changes: 1 addition & 1 deletion docs/gen.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
03acd307b08ec4c03ccfb8c4c0620f573612a5b2 ../api/pwlevel.proto
2fe5355fb9e8a9c8603bb5ab13c9ffa51fb6501d ../api/pwengine.proto
30302d31bca0924719daf9e95a0ea15dfbcfb131 ../api/pwhypervisor.proto
58eb4b1d9b5be40a69ffdab1a13b9fb90b669839 ../api/pwsso.proto
5d333f98cfbafd36ddc97b3c7c364bf94b898384 ../api/pwcompose.proto
6de212ad63b45da5e9d57a1b293a0ec8b73b7b35 ../api/pwdb.proto
71351a6ac01962fbeaeeeafd431d481e6c1f288b Makefile
8a27b6e5aac7ffa15f686c6c1b9b741659f0acfd ../api/pwengine.proto
2 changes: 1 addition & 1 deletion go/gen.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
03acd307b08ec4c03ccfb8c4c0620f573612a5b2 ../api/pwlevel.proto
2fe5355fb9e8a9c8603bb5ab13c9ffa51fb6501d ../api/pwengine.proto
30302d31bca0924719daf9e95a0ea15dfbcfb131 ../api/pwhypervisor.proto
58eb4b1d9b5be40a69ffdab1a13b9fb90b669839 ../api/pwsso.proto
5d333f98cfbafd36ddc97b3c7c364bf94b898384 ../api/pwcompose.proto
6de212ad63b45da5e9d57a1b293a0ec8b73b7b35 ../api/pwdb.proto
8a27b6e5aac7ffa15f686c6c1b9b741659f0acfd ../api/pwengine.proto
ddfce445bab91ac60acbcda4fe9f2524e0b2e50d Makefile
4 changes: 2 additions & 2 deletions go/pkg/pwengine/api_dev_dbdump.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package pwengine

import (
context "context"
"context"

pwdb "pathwar.land/go/pkg/pwdb"
"pathwar.land/go/pkg/pwdb"
)

func (c *client) DBDump(context.Context, *Void) (*pwdb.Dump, error) {
Expand Down
4 changes: 2 additions & 2 deletions go/pkg/pwengine/api_dev_generatefakedata.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package pwengine

import (
context "context"
"context"

pwdb "pathwar.land/go/pkg/pwdb"
"pathwar.land/go/pkg/pwdb"
)

func (c *client) GenerateFakeData(context.Context, *Void) (*Void, error) {
Expand Down
2 changes: 1 addition & 1 deletion go/pkg/pwengine/api_dev_getinfo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pwengine

import (
context "context"
"context"
"time"

"pathwar.land/go/pkg/pwversion"
Expand Down
2 changes: 1 addition & 1 deletion go/pkg/pwengine/api_pub_getstatus.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pwengine

import context "context"
import "context"

func (c *client) GetStatus(context.Context, *Void) (*Status, error) {
return &Status{
Expand Down
4 changes: 2 additions & 2 deletions go/pkg/pwengine/api_pub_listlevels.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package pwengine

import (
context "context"
"context"

pwdb "pathwar.land/go/pkg/pwdb"
"pathwar.land/go/pkg/pwdb"
)

func (c *client) ListLevels(context.Context, *Void) (*pwdb.LevelList, error) {
Expand Down
16 changes: 16 additions & 0 deletions go/pkg/pwengine/api_pub_listteams.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pwengine

import (
"context"

"pathwar.land/go/pkg/pwdb"
)

func (c *client) ListTeams(context.Context, *Void) (*pwdb.TeamList, error) {
var teams pwdb.TeamList
if err := c.db.Set("gorm:auto_preload", true).Find(&teams.Items).Error; err != nil {
return nil, err
}

return &teams, nil
}
4 changes: 1 addition & 3 deletions go/pkg/pwengine/api_pub_ping.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package pwengine

import (
context "context"
)
import "context"

func (c *client) Ping(context.Context, *Void) (*Void, error) {
return &Void{}, nil
Expand Down
2 changes: 1 addition & 1 deletion go/pkg/pwengine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/jinzhu/gorm"
"go.uber.org/zap"
pwsso "pathwar.land/go/pkg/pwsso"
"pathwar.land/go/pkg/pwsso"
)

var _ Client = (*client)(nil)
Expand Down
171 changes: 102 additions & 69 deletions go/pkg/pwengine/pwengine.pb.go

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions go/pkg/pwengine/pwengine.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ definitions:
format: date-time
type: string
type: object
dbTeamList:
properties:
items:
items:
$ref: '#/definitions/dbTeam'
type: array
type: object
dbTeamMember:
properties:
created_at:
Expand Down Expand Up @@ -896,7 +903,6 @@ paths:
schema:
format: string
type: string
summary: List users
tags:
- Engine
/ping:
Expand Down Expand Up @@ -936,7 +942,25 @@ paths:
schema:
format: string
type: string
summary: List teams
tags:
- Engine
/teams:
get:
operationId: ListTeams
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/dbTeamList'
"403":
description: Returned when the user does not have permission to access the
resource.
schema: {}
"404":
description: Returned when the resource does not exist.
schema:
format: string
type: string
tags:
- Engine
/user-session:
Expand Down

0 comments on commit 045c18f

Please sign in to comment.