forked from magicsong/sonargo
/
client.go
83 lines (80 loc) · 3.11 KB
/
client.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package sonargo
import (
"net/http"
"net/url"
)
type Client struct {
baseURL *url.URL
username, password, token string
authType authType
httpClient *http.Client
Ce *CeService
Components *ComponentsService
Duplications *DuplicationsService
Favorites *FavoritesService
Issues *IssuesService
Languages *LanguagesService
Measures *MeasuresService
Metrics *MetricsService
Notifications *NotificationsService
Permissions *PermissionsService
Plugins *PluginsService
ProjectAnalyses *ProjectAnalysesService
ProjectBadges *ProjectBadgesService
ProjectBranches *ProjectBranchesService
ProjectLinks *ProjectLinksService
ProjectPullRequests *ProjectPullRequestsService
ProjectTags *ProjectTagsService
Projects *ProjectsService
Qualitygates *QualitygatesService
QualityProfiles *QualityProfilesService
Rules *RulesService
Server *ServerService
Settings *SettingsService
Sources *SourcesService
System *SystemService
UserGroups *UserGroupsService
UserTokens *UserTokensService
Users *UsersService
Webhooks *WebhooksService
}
func NewClient(endpoint, username, password string) (*Client, error) {
c := &Client{username: username, password: password, authType: basicAuth, httpClient: http.DefaultClient}
if endpoint == "" {
c.SetBaseURL(defaultBaseURL)
} else {
if err := c.SetBaseURL(endpoint); err != nil {
return nil, err
}
}
c.Ce = &CeService{client: c}
c.Components = &ComponentsService{client: c}
c.Duplications = &DuplicationsService{client: c}
c.Favorites = &FavoritesService{client: c}
c.Issues = &IssuesService{client: c}
c.Languages = &LanguagesService{client: c}
c.Measures = &MeasuresService{client: c}
c.Metrics = &MetricsService{client: c}
c.Notifications = &NotificationsService{client: c}
c.Permissions = &PermissionsService{client: c}
c.Plugins = &PluginsService{client: c}
c.ProjectAnalyses = &ProjectAnalysesService{client: c}
c.ProjectBadges = &ProjectBadgesService{client: c}
c.ProjectBranches = &ProjectBranchesService{client: c}
c.ProjectLinks = &ProjectLinksService{client: c}
c.ProjectPullRequests = &ProjectPullRequestsService{client: c}
c.ProjectTags = &ProjectTagsService{client: c}
c.Projects = &ProjectsService{client: c}
c.Qualitygates = &QualitygatesService{client: c}
c.QualityProfiles = &QualityProfilesService{client: c}
c.Rules = &RulesService{client: c}
c.Server = &ServerService{client: c}
c.Settings = &SettingsService{client: c}
c.Sources = &SourcesService{client: c}
c.System = &SystemService{client: c}
c.UserGroups = &UserGroupsService{client: c}
c.UserTokens = &UserTokensService{client: c}
c.Users = &UsersService{client: c}
c.Webhooks = &WebhooksService{client: c}
return c, nil
}