Skip to content

Commit 0693812

Browse files
committed
[public-api] Define TeamService.AdminListTeams
1 parent f4eb948 commit 0693812

File tree

11 files changed

+659
-263
lines changed

11 files changed

+659
-263
lines changed

components/gitpod-protocol/go/gitpod-service.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type APIInterface interface {
8686

8787
GetTeam(ctx context.Context, teamID string) (*Team, error)
8888
GetTeams(ctx context.Context) ([]*Team, error)
89+
AdminGetTeams(ctx context.Context, options *AdminGetTeamsOptions) (*AdminGetTeamsResult, error)
8990
CreateTeam(ctx context.Context, teamName string) (*Team, error)
9091
DeleteTeam(ctx context.Context, teamID string) error
9192
GetTeamMembers(ctx context.Context, teamID string) ([]*TeamMemberInfo, error)
@@ -219,6 +220,8 @@ const (
219220
FunctionGetTeam FunctionName = "getTeam"
220221
// FunctionGetTeams is the name of the getTeams function
221222
FunctionGetTeams FunctionName = "getTeams"
223+
// FunctionAdminGetTeams is the name of the adminGetTeams function
224+
FunctionAdminGetTeams FunctionName = "adminGetTeams"
222225
// FunctionCreateTeam is the name of the createTeam function
223226
FunctionCreateTeam FunctionName = "createTeam"
224227
// FunctionJoinTeam is the name of the joinTeam function
@@ -1440,6 +1443,19 @@ func (gp *APIoverJSONRPC) GetTeams(ctx context.Context) (res []*Team, err error)
14401443
return
14411444
}
14421445

1446+
func (gp *APIoverJSONRPC) AdminGetTeams(ctx context.Context, options *AdminGetTeamsOptions) (res *AdminGetTeamsResult, err error) {
1447+
if gp == nil {
1448+
err = errNotConnected
1449+
return
1450+
}
1451+
1452+
var _params []interface{}
1453+
_params = append(_params, options)
1454+
1455+
err = gp.C.Call(ctx, string(FunctionAdminGetTeams), _params, &res)
1456+
return
1457+
}
1458+
14431459
func (gp *APIoverJSONRPC) CreateTeam(ctx context.Context, teamName string) (res *Team, err error) {
14441460
if gp == nil {
14451461
err = errNotConnected
@@ -2247,3 +2263,23 @@ type TeamMembershipInvite struct {
22472263
InvalidationTime string `json:"invalidationTime,omitempty"`
22482264
InvitedEmail string `json:"invitedEmail,omitempty"`
22492265
}
2266+
2267+
type Ordering string
2268+
2269+
const (
2270+
Ordering_Ascending Ordering = "asc"
2271+
Ordering_Descending Ordering = "desc"
2272+
)
2273+
2274+
type AdminGetTeamsOptions struct {
2275+
Offset int `json:"offset,omitempty"`
2276+
Limit int `json:"limit,omitempty"`
2277+
OrderBy int `json:"orderBy,omitempty"`
2278+
Order Ordering `json:"orderDir,omitempty"`
2279+
SearchTerm string `json:"searchTerm,omitempty"`
2280+
}
2281+
2282+
type AdminGetTeamsResult struct {
2283+
Total int `json:"total,omitempty"`
2284+
Rows []*Team `json:"rows,omitempty"`
2285+
}

components/gitpod-protocol/go/mock.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/public-api/gitpod/experimental/v1/pagination.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ package gitpod.experimental.v1;
55
option go_package = "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1";
66

77
message Pagination {
8-
// page_size is the maximum number of results we expect
8+
// page_size is the maximum number of results to retrieve per page
99
int32 page_size = 1;
1010

11-
// page_token points to a specific page of the results
12-
string page_token = 2;
11+
// page is the page number of results to retrieve.
12+
string page = 2;
1313
}

components/public-api/gitpod/experimental/v1/teams.proto

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package gitpod.experimental.v1;
44

55
option go_package = "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1";
66

7+
import "gitpod/experimental/v1/pagination.proto";
78
import "google/protobuf/timestamp.proto";
89

910
message Team {
@@ -44,7 +45,7 @@ message TeamMember {
4445
}
4546

4647
enum TeamRole {
47-
// TEAM_ROLE_UNKNOWN is the unkwnon state.
48+
// TEAM_ROLE_UNSPECIFIED is the unkwnon state.
4849
TEAM_ROLE_UNSPECIFIED = 0;
4950

5051
// TEAM_ROLE_OWNER is the owner of the team.
@@ -67,9 +68,12 @@ service TeamsService {
6768
// GetTeam retrieves a single Team.
6869
rpc GetTeam(GetTeamRequest) returns (GetTeamResponse) {}
6970

70-
// ListTeams lists the caller has access to.
71+
// ListTeams lists teams the caller has access to.
7172
rpc ListTeams(ListTeamsRequest) returns (ListTeamsResponse) {};
7273

74+
// AdminListTeams lists all teams that exist on the installation. Admin permissions are required.
75+
rpc AdminListTeams(AdminListTeamsRequest) returns (AdminListTeamsResponse) {};
76+
7377
// DeleteTeam deletes the specified team.
7478
rpc DeleteTeam(DeleteTeamRequest) returns (DeleteTeamResponse) {};
7579

@@ -112,6 +116,18 @@ message ListTeamsResponse {
112116
repeated Team teams = 1;
113117
}
114118

119+
message AdminListTeamsRequest {
120+
Pagination pagination = 1;
121+
string order_by = 2;
122+
}
123+
124+
message AdminListTeamsResponse {
125+
repeated Team teams = 1;
126+
127+
// total_results is the total number of results available
128+
int32 total_results = 2;
129+
}
130+
115131
message DeleteTeamRequest {
116132
// team_id is the ID of the team to delete
117133
string team_id = 1;

components/public-api/go/experimental/v1/pagination.pb.go

Lines changed: 13 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)