Split the client up into resource-specific files

This commit is contained in:
Ian Gulliver
2021-09-23 04:30:50 +00:00
parent 31985ee5c6
commit e85fbd5df9
10 changed files with 459 additions and 432 deletions

30
client/project.go Normal file
View File

@@ -0,0 +1,30 @@
package client
import "fmt"
type Project struct {
GID string `json:"gid"`
Name string `json:"name"`
}
type projectResponse struct {
Data *Project `json:"data"`
}
type projectsResponse struct {
Data []*Project `json:"data"`
}
func (wc *WorkspaceClient) GetProjects() ([]*Project, error) {
path := fmt.Sprintf("workspaces/%s/projects", wc.workspace.GID)
resp := &projectsResponse{}
err := wc.client.get(path, nil, resp)
if err != nil {
return nil, err
}
return resp.Data, nil
}
func (p *Project) String() string {
return fmt.Sprintf("%s (%s)", p.GID, p.Name)
}