forked from galaxydi/go-loghub
-
Notifications
You must be signed in to change notification settings - Fork 113
/
log_project.go
59 lines (54 loc) · 1.33 KB
/
log_project.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
package main
import (
"fmt"
"time"
"github.com/aliyun/aliyun-log-go-sdk/example/util"
)
func main(){
fmt.Println("Create Project")
_, err := util.Client.CreateProject(util.ProjectName,"Project used for testing")
if err != nil {
fmt.Println(err)
}
project, err := util.Client.GetProject(util.ProjectName)
if err != nil {
panic(err)
}
fmt.Println("project created successfully:", project.Name)
project, err = util.Client.UpdateProject(util.ProjectName, "Updated description")
if err != nil{
panic(err)
}
fmt.Println("Modify the description of the project successfully")
fmt.Println("Prepare to delete the project after 20 seconds")
time.Sleep(20 * time.Second)
err = util.Client.DeleteProject(util.ProjectName)
if err != nil {
panic(err)
}
fmt.Println("Delete project sucessfully")
listAllProject()
}
// List all the projects below this region.
func listAllProject() {
offset := 0
fmt.Println("project list: ")
for {
projects, count, total, err := util.Client.ListProjectV2(offset, 100)
if err != nil {
panic(err)
}
for _, project := range projects {
fmt.Printf(" name : %s, description : %s, region : %s, ctime : %s, mtime : %s\n",
project.Name,
project.Description,
project.Region,
project.CreateTime,
project.LastModifyTime)
}
if offset+count >= total {
break
}
offset += count
}
}