forked from kothar/asana-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.go
68 lines (58 loc) · 1.34 KB
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"github.com/OP-Solutions/asana-go"
)
func ListWorkspaces(c *asana.Client) error {
// List workspaces
workspaces, nextPage, err := c.Workspaces()
if err != nil {
return err
}
_ = nextPage
for _, workspace := range workspaces {
if workspace.IsOrganization {
fmt.Printf(" Organization %s %q\n", workspace.ID, workspace.Name)
} else {
fmt.Printf(" Workspace %s %q\n", workspace.ID, workspace.Name)
}
}
return nil
}
func ListProjects(w *asana.Workspace) error {
// List projects
projects, err := w.AllProjects(&asana.Options{
Fields: []string{"name", "section_migration_status", "layout"},
})
if err != nil {
return err
}
for _, project := range projects {
fmt.Printf(" Project %s %q\n", project.ID, project.Name)
}
return nil
}
func ListTasks(p *asana.Project) error {
// List projects
tasks, nextPage, err := p.Tasks(asana.Fields(asana.Task{}))
if err != nil {
return err
}
_ = nextPage
for _, task := range tasks {
fmt.Printf(" Task %s %q (separator: %v)\n", task.ID, task.Name, task.IsRenderedAsSeparator)
}
return nil
}
func ListSections(p *asana.Project) error {
// List sections
sections, nextPage, err := p.Sections()
if err != nil {
return err
}
_ = nextPage
for _, section := range sections {
fmt.Printf(" Section %s %q\n", section.ID, section.Name)
}
return nil
}