Skip to content

[public-api] Define TeamService.AdminListTeams #14592

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

Closed
wants to merge 1 commit into from
Closed
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
36 changes: 36 additions & 0 deletions components/gitpod-protocol/go/gitpod-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type APIInterface interface {

GetTeam(ctx context.Context, teamID string) (*Team, error)
GetTeams(ctx context.Context) ([]*Team, error)
AdminGetTeams(ctx context.Context, options *AdminGetTeamsOptions) (*AdminGetTeamsResult, error)
CreateTeam(ctx context.Context, teamName string) (*Team, error)
DeleteTeam(ctx context.Context, teamID string) error
GetTeamMembers(ctx context.Context, teamID string) ([]*TeamMemberInfo, error)
Expand Down Expand Up @@ -219,6 +220,8 @@ const (
FunctionGetTeam FunctionName = "getTeam"
// FunctionGetTeams is the name of the getTeams function
FunctionGetTeams FunctionName = "getTeams"
// FunctionAdminGetTeams is the name of the adminGetTeams function
FunctionAdminGetTeams FunctionName = "adminGetTeams"
// FunctionCreateTeam is the name of the createTeam function
FunctionCreateTeam FunctionName = "createTeam"
// FunctionJoinTeam is the name of the joinTeam function
Expand Down Expand Up @@ -1440,6 +1443,19 @@ func (gp *APIoverJSONRPC) GetTeams(ctx context.Context) (res []*Team, err error)
return
}

func (gp *APIoverJSONRPC) AdminGetTeams(ctx context.Context, options *AdminGetTeamsOptions) (res *AdminGetTeamsResult, err error) {
if gp == nil {
err = errNotConnected
return
}

var _params []interface{}
_params = append(_params, options)

err = gp.C.Call(ctx, string(FunctionAdminGetTeams), _params, &res)
return
}

func (gp *APIoverJSONRPC) CreateTeam(ctx context.Context, teamName string) (res *Team, err error) {
if gp == nil {
err = errNotConnected
Expand Down Expand Up @@ -2247,3 +2263,23 @@ type TeamMembershipInvite struct {
InvalidationTime string `json:"invalidationTime,omitempty"`
InvitedEmail string `json:"invitedEmail,omitempty"`
}

type Ordering string

const (
Ordering_Ascending Ordering = "asc"
Ordering_Descending Ordering = "desc"
)

type AdminGetTeamsOptions struct {
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
OrderBy int `json:"orderBy,omitempty"`
Order Ordering `json:"orderDir,omitempty"`
SearchTerm string `json:"searchTerm,omitempty"`
}

type AdminGetTeamsResult struct {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make this a generic type, but sadly our mock codegen does not yet support generics - it's worked on in golang/mock#669

Total int `json:"total,omitempty"`
Rows []*Team `json:"rows,omitempty"`
}
15 changes: 15 additions & 0 deletions components/gitpod-protocol/go/mock.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ package gitpod.experimental.v1;
option go_package = "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1";

message Pagination {
// page_size is the maximum number of results we expect
// page_size is the maximum number of results to retrieve per page
int32 page_size = 1;

// page_token points to a specific page of the results
string page_token = 2;
// page is the page number of results to retrieve.
string page = 2;
}
20 changes: 18 additions & 2 deletions components/public-api/gitpod/experimental/v1/teams.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package gitpod.experimental.v1;

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

import "gitpod/experimental/v1/pagination.proto";
import "google/protobuf/timestamp.proto";

message Team {
Expand Down Expand Up @@ -44,7 +45,7 @@ message TeamMember {
}

enum TeamRole {
// TEAM_ROLE_UNKNOWN is the unkwnon state.
// TEAM_ROLE_UNSPECIFIED is the unkwnon state.
TEAM_ROLE_UNSPECIFIED = 0;

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

// ListTeams lists the caller has access to.
// ListTeams lists teams the caller has access to.
rpc ListTeams(ListTeamsRequest) returns (ListTeamsResponse) {};

// AdminListTeams lists all teams that exist on the installation. Admin permissions are required.
rpc AdminListTeams(AdminListTeamsRequest) returns (AdminListTeamsResponse) {};

// DeleteTeam deletes the specified team.
rpc DeleteTeam(DeleteTeamRequest) returns (DeleteTeamResponse) {};

Expand Down Expand Up @@ -112,6 +116,18 @@ message ListTeamsResponse {
repeated Team teams = 1;
}

message AdminListTeamsRequest {
Pagination pagination = 1;
string order_by = 2;
}

message AdminListTeamsResponse {
repeated Team teams = 1;

// total_results is the total number of results available
int32 total_results = 2;
}

message DeleteTeamRequest {
// team_id is the ID of the team to delete
string team_id = 1;
Expand Down
27 changes: 13 additions & 14 deletions components/public-api/go/experimental/v1/pagination.pb.go

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

Loading