Skip to content

Commit 71ccb9a

Browse files
committed
fix team after merge
1 parent ee04f28 commit 71ccb9a

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

pkg/api/client.go

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,12 @@ func (c *Client) ListWorkspacePlans() ([]WorkspacePlan, error) {
5555

5656
func (c *Client) ListTeams() ([]Team, error) {
5757
teams, _, err := c.api.TeamsAPI.TeamsListTeams(c.ctx).Execute()
58-
59-
mapped := make([]Team, len(teams))
60-
for i, t := range teams {
61-
mapped[i] = Team{
62-
Id: t.Id,
63-
DefaultDataCenterId: t.DefaultDataCenterId,
64-
Name: t.Name,
65-
Description: t.Description,
66-
AvatarId: t.AvatarId,
67-
AvatarUrl: t.AvatarUrl,
68-
IsFirst: t.IsFirst,
69-
}
70-
}
71-
return mapped, err
58+
return teams, err
7259
}
7360

7461
func (c *Client) GetTeam(teamId int) (*Team, error) {
7562
team, _, err := c.api.TeamsAPI.TeamsGetTeam(c.ctx, float32(teamId)).Execute()
76-
return team, err
63+
return ConvertToTeam(team), err
7764
}
7865

7966
func (c *Client) CreateTeam(name string, dc int) (*Team, error) {
@@ -83,7 +70,7 @@ func (c *Client) CreateTeam(name string, dc int) (*Team, error) {
8370
Dc: dc,
8471
}).
8572
Execute()
86-
return team, err
73+
return ConvertToTeam(team), err
8774
}
8875

8976
func (c *Client) DeleteTeam(teamId int) error {
@@ -96,18 +83,18 @@ func (c *Client) ListDomains(teamId int) ([]Domain, error) {
9683
return domains, err
9784
}
9885

99-
func (c *Client) GetDomain(teamId int, name string) (*Domain, error) {
100-
domain, _, err := c.api.DomainsAPI.DomainsGetDomain(c.ctx, float32(teamId), name).Execute()
86+
func (c *Client) GetDomain(teamId int, domainName string) (*Domain, error) {
87+
domain, _, err := c.api.DomainsAPI.DomainsGetDomain(c.ctx, float32(teamId), domainName).Execute()
10188
return domain, err
10289
}
10390

104-
func (c *Client) CreateDomain(teamId int, name string) (*Domain, error) {
105-
domain, _, err := c.api.DomainsAPI.DomainsCreateDomain(c.ctx, float32(teamId), name).Execute()
91+
func (c *Client) CreateDomain(teamId int, domainName string) (*Domain, error) {
92+
domain, _, err := c.api.DomainsAPI.DomainsCreateDomain(c.ctx, float32(teamId), domainName).Execute()
10693
return domain, err
10794
}
10895

109-
func (c *Client) DeleteDomain(teamId int, name string) error {
110-
_, err := c.api.DomainsAPI.DomainsDeleteDomain(c.ctx, float32(teamId), name).Execute()
96+
func (c *Client) DeleteDomain(teamId int, domainName string) error {
97+
_, err := c.api.DomainsAPI.DomainsDeleteDomain(c.ctx, float32(teamId), domainName).Execute()
11198
return err
11299
}
113100

pkg/api/types.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,25 @@ import (
55
)
66

77
type DataCenter = openapi.MetadataGetDatacenters200ResponseInner
8-
type Team = openapi.TeamsGetTeam200Response
8+
type Team = openapi.TeamsListTeams200ResponseInner
99
type Domain = openapi.DomainsGetDomain200Response
1010
type DomainVerificationStatus = openapi.DomainsGetDomain200ResponseDomainVerificationStatus
1111
type UpdateDomainArgs = openapi.DomainsGetDomain200ResponseCustomConfig
1212
type PathToWorkspaces = map[string][]*Workspace
1313
type Workspace = openapi.WorkspacesGetWorkspace200Response
1414
type WorkspacePlan = openapi.MetadataGetWorkspacePlans200ResponseInner
15+
16+
// TODO: remove the conversion once the api is fixed
17+
func ConvertToTeam(t *openapi.TeamsGetTeam200Response) *Team {
18+
return &Team{
19+
Id: t.Id,
20+
DefaultDataCenterId: t.DefaultDataCenterId,
21+
Name: t.Name,
22+
Description: t.Description,
23+
AvatarId: t.AvatarId,
24+
AvatarUrl: t.AvatarUrl,
25+
IsFirst: t.IsFirst,
26+
27+
Role: 0,
28+
}
29+
}

0 commit comments

Comments
 (0)