Commit b3618c7c authored by Sander van Harmelen's avatar Sander van Harmelen

Fix a couple of too quickly merged PR’s

parent 680b9eba
...@@ -17,8 +17,8 @@ incompatible changes that were needed to fully support the V4 Gitlab API. ...@@ -17,8 +17,8 @@ incompatible changes that were needed to fully support the V4 Gitlab API.
## Coverage ## Coverage
This API client package covers **67%** of the existing GitLab API calls! So this This API client package covers most of the existing Gitlab API calls and is updated regularly
includes all calls to the following services: to add new and/or missing endpoints. Currently the following services are supported:
- [x] Award Emojis - [x] Award Emojis
- [x] Branches - [x] Branches
...@@ -38,7 +38,7 @@ includes all calls to the following services: ...@@ -38,7 +38,7 @@ includes all calls to the following services:
- [ ] Group Access Requests - [ ] Group Access Requests
- [ ] Group Members - [ ] Group Members
- [x] Issues - [x] Issues
- [ ] Issue Boards - [x] Issue Boards
- [x] Jobs - [x] Jobs
- [ ] Keys - [ ] Keys
- [x] Labels - [x] Labels
...@@ -49,7 +49,7 @@ includes all calls to the following services: ...@@ -49,7 +49,7 @@ includes all calls to the following services:
- [x] Notes (comments) - [x] Notes (comments)
- [x] Notification settings - [x] Notification settings
- [ ] Open source license templates - [ ] Open source license templates
- [ ] Page Domains - [x] Page Domains
- [x] Pipelines - [x] Pipelines
- [x] Pipeline Triggers - [x] Pipeline Triggers
- [ ] Pipeline Schedules - [ ] Pipeline Schedules
......
This diff is collapsed.
...@@ -47,7 +47,7 @@ type Commit struct { ...@@ -47,7 +47,7 @@ type Commit struct {
Message string `json:"message"` Message string `json:"message"`
ParentIDs []string `json:"parent_ids"` ParentIDs []string `json:"parent_ids"`
Stats *CommitStats `json:"stats"` Stats *CommitStats `json:"stats"`
Status *BuildState `json:"status"` Status *BuildStateValue `json:"status"`
} }
// CommitStats represents the number of added and deleted files in a commit. // CommitStats represents the number of added and deleted files in a commit.
...@@ -368,7 +368,7 @@ func (s *CommitsService) GetCommitStatuses(pid interface{}, sha string, opt *Get ...@@ -368,7 +368,7 @@ func (s *CommitsService) GetCommitStatuses(pid interface{}, sha string, opt *Get
// //
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#post-the-status-to-commit // GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#post-the-status-to-commit
type SetCommitStatusOptions struct { type SetCommitStatusOptions struct {
State BuildState `url:"state" json:"state"` State BuildStateValue `url:"state" json:"state"`
Ref *string `url:"ref,omitempty" json:"ref,omitempty"` Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"` Name *string `url:"name,omitempty" json:"name,omitempty"`
Context *string `url:"context,omitempty" json:"context,omitempty"` Context *string `url:"context,omitempty" json:"context,omitempty"`
...@@ -376,19 +376,6 @@ type SetCommitStatusOptions struct { ...@@ -376,19 +376,6 @@ type SetCommitStatusOptions struct {
Description *string `url:"description,omitempty" json:"description,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"`
} }
// BuildState represents a GitLab build state.
type BuildState string
// These constants represent all valid build states.
const (
Pending BuildState = "pending"
Running BuildState = "running"
Success BuildState = "success"
Failed BuildState = "failed"
Canceled BuildState = "canceled"
Skipped BuildState = "skipped"
)
// SetCommitStatus sets the status of a commit in a project. // SetCommitStatus sets the status of a commit in a project.
// //
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#post-the-status-to-commit // GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#post-the-status-to-commit
......
...@@ -12,12 +12,12 @@ func pipelineExample() { ...@@ -12,12 +12,12 @@ func pipelineExample() {
opt := &gitlab.ListProjectPipelinesOptions{ opt := &gitlab.ListProjectPipelinesOptions{
Scope: gitlab.String("branches"), Scope: gitlab.String("branches"),
Status: gitlab.Build(gitlab.Running), Status: gitlab.BuildState(gitlab.Running),
Ref: gitlab.String("master"), Ref: gitlab.String("master"),
YamlErrors: gitlab.Bool(true), YamlErrors: gitlab.Bool(true),
Name: gitlab.String("name"), Name: gitlab.String("name"),
Username: gitlab.String("username"), Username: gitlab.String("username"),
OrderBy: gitlab.Order(gitlab.OrderByStatus), OrderBy: gitlab.OrderBy(gitlab.OrderByStatus),
Sort: gitlab.String("asc"), Sort: gitlab.String("asc"),
} }
......
...@@ -70,6 +70,19 @@ const ( ...@@ -70,6 +70,19 @@ const (
OwnerPermission AccessLevelValue = 50 OwnerPermission AccessLevelValue = 50
) )
// BuildStateValue represents a GitLab build state.
type BuildStateValue string
// These constants represent all valid build states.
const (
Pending BuildStateValue = "pending"
Running BuildStateValue = "running"
Success BuildStateValue = "success"
Failed BuildStateValue = "failed"
Canceled BuildStateValue = "canceled"
Skipped BuildStateValue = "skipped"
)
// ISOTime represents an ISO 8601 formatted date // ISOTime represents an ISO 8601 formatted date
type ISOTime time.Time type ISOTime time.Time
...@@ -166,6 +179,17 @@ var notificationLevelTypes = map[string]NotificationLevelValue{ ...@@ -166,6 +179,17 @@ var notificationLevelTypes = map[string]NotificationLevelValue{
"custom": CustomNotificationLevel, "custom": CustomNotificationLevel,
} }
// OrderByValue represent in which order to sort the item
type OrderByValue string
// These constants represent all valid order by values.
const (
OrderByID OrderByValue = "id"
OrderByStatus OrderByValue = "status"
OrderByRef OrderByValue = "ref"
OrderByUserID OrderByValue = "user_id"
)
// VisibilityValue represents a visibility level within GitLab. // VisibilityValue represents a visibility level within GitLab.
// //
// GitLab API docs: https://docs.gitlab.com/ce/api/ // GitLab API docs: https://docs.gitlab.com/ce/api/
...@@ -249,7 +273,7 @@ type Client struct { ...@@ -249,7 +273,7 @@ type Client struct {
Issues *IssuesService Issues *IssuesService
IssueLinks *IssueLinksService IssueLinks *IssueLinksService
Jobs *JobsService Jobs *JobsService
Boards *BoardsService Boards *IssueBoardsService
Labels *LabelsService Labels *LabelsService
MergeRequests *MergeRequestsService MergeRequests *MergeRequestsService
Milestones *MilestonesService Milestones *MilestonesService
...@@ -331,7 +355,7 @@ func newClient(httpClient *http.Client, tokenType tokenType, token string) *Clie ...@@ -331,7 +355,7 @@ func newClient(httpClient *http.Client, tokenType tokenType, token string) *Clie
c.Issues = &IssuesService{client: c, timeStats: timeStats} c.Issues = &IssuesService{client: c, timeStats: timeStats}
c.IssueLinks = &IssueLinksService{client: c} c.IssueLinks = &IssueLinksService{client: c}
c.Jobs = &JobsService{client: c} c.Jobs = &JobsService{client: c}
c.Boards = &BoardsService{client: c} c.Boards = &IssueBoardsService{client: c}
c.Labels = &LabelsService{client: c} c.Labels = &LabelsService{client: c}
c.MergeRequests = &MergeRequestsService{client: c, timeStats: timeStats} c.MergeRequests = &MergeRequestsService{client: c, timeStats: timeStats}
c.Milestones = &MilestonesService{client: c} c.Milestones = &MilestonesService{client: c}
...@@ -700,34 +724,34 @@ func AccessLevel(v AccessLevelValue) *AccessLevelValue { ...@@ -700,34 +724,34 @@ func AccessLevel(v AccessLevelValue) *AccessLevelValue {
return p return p
} }
// NotificationLevel is a helper routine that allocates a new NotificationLevelValue // BuildState is a helper routine that allocates a new BuildStateValue
// to store v and returns a pointer to it. // to store v and returns a pointer to it.
func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue { func BuildState(v BuildStateValue) *BuildStateValue {
p := new(NotificationLevelValue) p := new(BuildStateValue)
*p = v *p = v
return p return p
} }
// Visibility is a helper routine that allocates a new VisibilityValue // NotificationLevel is a helper routine that allocates a new NotificationLevelValue
// to store v and returns a pointer to it. // to store v and returns a pointer to it.
func Visibility(v VisibilityValue) *VisibilityValue { func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue {
p := new(VisibilityValue) p := new(NotificationLevelValue)
*p = v *p = v
return p return p
} }
// Order is a helper routine that allocates a new OrderBy // OrderBy is a helper routine that allocates a new OrderByValue
// to store v and returns a pointer to it. // to store v and returns a pointer to it.
func Order(v OrderBy) *OrderBy { func OrderBy(v OrderByValue) *OrderByValue {
p := new(OrderBy) p := new(OrderByValue)
*p = v *p = v
return p return p
} }
// Build is a helper routine that allocates a new BuildState // Visibility is a helper routine that allocates a new VisibilityValue
// to store v and returns a pointer to it. // to store v and returns a pointer to it.
func Build(v BuildState) *BuildState { func Visibility(v VisibilityValue) *VisibilityValue {
p := new(BuildState) p := new(VisibilityValue)
*p = v *p = v
return p return p
} }
...@@ -27,7 +27,7 @@ import ( ...@@ -27,7 +27,7 @@ import (
// ListJobsOptions are options for two list apis // ListJobsOptions are options for two list apis
type ListJobsOptions struct { type ListJobsOptions struct {
ListOptions ListOptions
Scope []BuildState `url:"scope,omitempty" json:"scope,omitempty"` Scope []BuildStateValue `url:"scope,omitempty" json:"scope,omitempty"`
} }
// JobsService handles communication with the ci builds related methods // JobsService handles communication with the ci builds related methods
......
...@@ -6,28 +6,25 @@ import ( ...@@ -6,28 +6,25 @@ import (
"time" "time"
) )
// PagesDomainsService handles Pages domains. // PagesDomainsService handles communication with the pages domains
// related methods of the GitLab API.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/pages_domains.html
// https://docs.gitlab.com/ce/api/pages_domains.html
type PagesDomainsService struct { type PagesDomainsService struct {
client *Client client *Client
} }
type Cert struct { // PagesDomain represents a pages domain.
Expired bool `json:"expired"`
Expiration *time.Time `json:"expiration"`
}
// PageDomain represents a pages domain.
// //
// GitLab API docs: // GitLab API docs: https://docs.gitlab.com/ce/api/pages_domains.html
// https://docs.gitlab.com/ce/api/pages_domains.html
type PagesDomain struct { type PagesDomain struct {
Domain string `json:"domain"` Domain string `json:"domain"`
URL string `json:"url"` URL string `json:"url"`
ProjectID int `json:"project_id"` ProjectID int `json:"project_id"`
Certificate *Cert `json:"certificate"` Certificate struct {
Expired bool `json:"expired"`
Expiration *time.Time `json:"expiration"`
} `json:"certificate"`
} }
// ListPagesDomainsOptions represents the available ListPagesDomains() options. // ListPagesDomainsOptions represents the available ListPagesDomains() options.
...@@ -38,7 +35,7 @@ type ListPagesDomainsOptions struct { ...@@ -38,7 +35,7 @@ type ListPagesDomainsOptions struct {
ListOptions ListOptions
} }
// ListPagesDomains gets a list of project Domains. // ListPagesDomains gets a list of project pages domains.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/pages_domains.html#list-pages-domains // https://docs.gitlab.com/ce/api/pages_domains.html#list-pages-domains
...@@ -54,55 +51,55 @@ func (s *PagesDomainsService) ListPagesDomains(pid interface{}, opt *ListPagesDo ...@@ -54,55 +51,55 @@ func (s *PagesDomainsService) ListPagesDomains(pid interface{}, opt *ListPagesDo
return nil, nil, err return nil, nil, err
} }
var pt []*PagesDomain var pd []*PagesDomain
resp, err := s.client.Do(req, &pt) resp, err := s.client.Do(req, &pd)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return pt, resp, err return pd, resp, err
} }
// GetPagesDomains gets a specific Pages Domains for a project. // GetPagesDomain get a specific pages domain for a project.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/Pages_Domainss.html#get-Domains-details // https://docs.gitlab.com/ce/api/pages_domains.html#single-pages-domain
func (s *PagesDomainsService) GetPagesDomains(pid interface{}, Domains int, options ...OptionFunc) (*PagesDomain, *Response, error) { func (s *PagesDomainsService) GetPagesDomain(pid interface{}, domain string, options ...OptionFunc) (*PagesDomain, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/pages/domains/%d", url.QueryEscape(project), Domains) u := fmt.Sprintf("projects/%s/pages/domains/%s", url.QueryEscape(project), domain)
req, err := s.client.NewRequest("GET", u, nil, options) req, err := s.client.NewRequest("GET", u, nil, options)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
pt := new(PagesDomain) pd := new(PagesDomain)
resp, err := s.client.Do(req, pt) resp, err := s.client.Do(req, pd)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return pt, resp, err return pd, resp, err
} }
// AddPagesDomainOptions represents the available AddPagesDomain() options. // CreatePagesDomainOptions represents the available CreatePagesDomain() options.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#create-a-project-trigger // // https://docs.gitlab.com/ce/api/pages_domains.html#create-new-pages-domain
type AddPagesDomainOptions struct { type CreatePagesDomainOptions struct {
Domain *string `url:"domain,omitempty" json:"domain,omitempty"` Domain *string `url:"domain,omitempty" json:"domain,omitempty"`
Certificate *string `url:"certifiate,omitempty" json:"certifiate,omitempty"` Certificate *string `url:"certifiate,omitempty" json:"certifiate,omitempty"`
Key *string `url:"key,omitempty" json:"key,omitempty"` Key *string `url:"key,omitempty" json:"key,omitempty"`
} }
// AddPagesDomain adds a pages domain to a specified project. // CreatePagesDomain creates a new project pages domain.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#create-a-project-trigger // https://docs.gitlab.com/ce/api/pages_domains.html#create-new-pages-domain
func (s *PagesDomainsService) AddPagesDomain(pid interface{}, opt *AddPagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) { func (s *PagesDomainsService) CreatePagesDomain(pid interface{}, opt *CreatePagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
...@@ -114,61 +111,59 @@ func (s *PagesDomainsService) AddPagesDomain(pid interface{}, opt *AddPagesDomai ...@@ -114,61 +111,59 @@ func (s *PagesDomainsService) AddPagesDomain(pid interface{}, opt *AddPagesDomai
return nil, nil, err return nil, nil, err
} }
pt := new(PagesDomain) pd := new(PagesDomain)
resp, err := s.client.Do(req, pt) resp, err := s.client.Do(req, pd)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return pt, resp, err return pd, resp, err
} }
// EditPagesDomainOptions represents the available EditPagesDomain() options. // UpdatePagesDomainOptions represents the available UpdatePagesDomain() options.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#update-a-project-trigger // https://docs.gitlab.com/ce/api/pages_domains.html#update-pages-domain
type EditPagesDomainOptions struct { type UpdatePagesDomainOptions struct {
ID *int `url:"id,omitempty" json:"id,omitempty"`
Domain *string `url:"domain,omitempty" json:"domain,omitempty"`
Cerificate *string `url:"certifiate" json:"certifiate"` Cerificate *string `url:"certifiate" json:"certifiate"`
Key *string `url:"key" json:"key"` Key *string `url:"key" json:"key"`
} }
// EditPagesDomain edits a domain for a specified project. // UpdatePagesDomain updates an existing project pages domain.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#update-a-project-trigger // https://docs.gitlab.com/ce/api/pages_domains.html#update-pages-domain
func (s *PagesDomainsService) EditPagesDomain(pid interface{}, trigger int, opt *EditPagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) { func (s *PagesDomainsService) UpdatePagesDomain(pid interface{}, domain string, opt *UpdatePagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
u := fmt.Sprintf("projects/%s/pages/domains/%d", url.QueryEscape(project), trigger) u := fmt.Sprintf("projects/%s/pages/domains/%s", url.QueryEscape(project), domain)
req, err := s.client.NewRequest("PUT", u, opt, options) req, err := s.client.NewRequest("PUT", u, opt, options)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
pt := new(PagesDomain) pd := new(PagesDomain)
resp, err := s.client.Do(req, pt) resp, err := s.client.Do(req, pd)
if err != nil { if err != nil {
return nil, resp, err return nil, resp, err
} }
return pt, resp, err return pd, resp, err
} }
// DeletePagesDomain removes a domain from a project. // DeletePagesDomain deletes an existing prject pages domain.
// //
// GitLab API docs: // GitLab API docs:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#remove-a-project-trigger // https://docs.gitlab.com/ce/api/pages_domains.html#delete-pages-domain
func (s *PagesDomainsService) DeletePagesDomain(pid interface{}, trigger int, options ...OptionFunc) (*Response, error) { func (s *PagesDomainsService) DeletePagesDomain(pid interface{}, domain string, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid) project, err := parseID(pid)
if err != nil { if err != nil {
return nil, err return nil, err
} }
u := fmt.Sprintf("projects/%s/pages/domains/%d", url.QueryEscape(project), trigger) u := fmt.Sprintf("projects/%s/pages/domains/%s", url.QueryEscape(project), domain)
req, err := s.client.NewRequest("DELETE", u, nil, options) req, err := s.client.NewRequest("DELETE", u, nil, options)
if err != nil { if err != nil {
......
...@@ -76,29 +76,18 @@ func (i PipelineList) String() string { ...@@ -76,29 +76,18 @@ func (i PipelineList) String() string {
return Stringify(i) return Stringify(i)
} }
// OrderBy represent in which order to sort the item
type OrderBy string
// These constants represent all valid order by values.
const (
OrderByID OrderBy = "id"
OrderByStatus OrderBy = "status"
OrderByRef OrderBy = "ref"
OrderByUserID OrderBy = "user_id"
)
// ListProjectPipelinesOptions represents the available ListProjectPipelines() options. // ListProjectPipelinesOptions represents the available ListProjectPipelines() options.
// //
// GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines // GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines
type ListProjectPipelinesOptions struct { type ListProjectPipelinesOptions struct {
ListOptions ListOptions
Scope *string `url:"scope,omitempty" json:"scope,omitempty"` Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
Status *BuildState `url:"status,omitempty" json:"status,omitempty"` Status *BuildStateValue `url:"status,omitempty" json:"status,omitempty"`
Ref *string `url:"ref,omitempty" json:"ref,omitempty"` Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
YamlErrors *bool `url:"yaml_errors,omitempty" json:"yaml_errors,omitempty"` YamlErrors *bool `url:"yaml_errors,omitempty" json:"yaml_errors,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"` Name *string `url:"name,omitempty" json:"name,omitempty"`
Username *string `url:"username,omitempty" json:"username,omitempty"` Username *string `url:"username,omitempty" json:"username,omitempty"`
OrderBy *OrderBy `url:"order_by,omitempty" json:"order_by,omitempty"` OrderBy *OrderByValue `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"` Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment