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.
## Coverage
This API client package covers **67%** of the existing GitLab API calls! So this
includes all calls to the following services:
This API client package covers most of the existing Gitlab API calls and is updated regularly
to add new and/or missing endpoints. Currently the following services are supported:
- [x] Award Emojis
- [x] Branches
......@@ -38,7 +38,7 @@ includes all calls to the following services:
- [ ] Group Access Requests
- [ ] Group Members
- [x] Issues
- [ ] Issue Boards
- [x] Issue Boards
- [x] Jobs
- [ ] Keys
- [x] Labels
......@@ -49,7 +49,7 @@ includes all calls to the following services:
- [x] Notes (comments)
- [x] Notification settings
- [ ] Open source license templates
- [ ] Page Domains
- [x] Page Domains
- [x] Pipelines
- [x] Pipeline Triggers
- [ ] Pipeline Schedules
......
This diff is collapsed.
......@@ -34,20 +34,20 @@ type CommitsService struct {
//
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html
type Commit struct {
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
AuthoredDate *time.Time `json:"authored_date"`
CommitterName string `json:"committer_name"`
CommitterEmail string `json:"committer_email"`
CommittedDate *time.Time `json:"committed_date"`
CreatedAt *time.Time `json:"created_at"`
Message string `json:"message"`
ParentIDs []string `json:"parent_ids"`
Stats *CommitStats `json:"stats"`
Status *BuildState `json:"status"`
ID string `json:"id"`
ShortID string `json:"short_id"`
Title string `json:"title"`
AuthorName string `json:"author_name"`
AuthorEmail string `json:"author_email"`
AuthoredDate *time.Time `json:"authored_date"`
CommitterName string `json:"committer_name"`
CommitterEmail string `json:"committer_email"`
CommittedDate *time.Time `json:"committed_date"`
CreatedAt *time.Time `json:"created_at"`
Message string `json:"message"`
ParentIDs []string `json:"parent_ids"`
Stats *CommitStats `json:"stats"`
Status *BuildStateValue `json:"status"`
}
// CommitStats represents the number of added and deleted files in a commit.
......@@ -368,27 +368,14 @@ 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
type SetCommitStatusOptions struct {
State BuildState `url:"state" json:"state"`
Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
Context *string `url:"context,omitempty" json:"context,omitempty"`
TargetURL *string `url:"target_url,omitempty" json:"target_url,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
State BuildStateValue `url:"state" json:"state"`
Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
Context *string `url:"context,omitempty" json:"context,omitempty"`
TargetURL *string `url:"target_url,omitempty" json:"target_url,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.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/commits.html#post-the-status-to-commit
......
......@@ -12,12 +12,12 @@ func pipelineExample() {
opt := &gitlab.ListProjectPipelinesOptions{
Scope: gitlab.String("branches"),
Status: gitlab.Build(gitlab.Running),
Status: gitlab.BuildState(gitlab.Running),
Ref: gitlab.String("master"),
YamlErrors: gitlab.Bool(true),
Name: gitlab.String("name"),
Username: gitlab.String("username"),
OrderBy: gitlab.Order(gitlab.OrderByStatus),
OrderBy: gitlab.OrderBy(gitlab.OrderByStatus),
Sort: gitlab.String("asc"),
}
......
......@@ -70,6 +70,19 @@ const (
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
type ISOTime time.Time
......@@ -166,6 +179,17 @@ var notificationLevelTypes = map[string]NotificationLevelValue{
"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.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/
......@@ -249,7 +273,7 @@ type Client struct {
Issues *IssuesService
IssueLinks *IssueLinksService
Jobs *JobsService
Boards *BoardsService
Boards *IssueBoardsService
Labels *LabelsService
MergeRequests *MergeRequestsService
Milestones *MilestonesService
......@@ -331,7 +355,7 @@ func newClient(httpClient *http.Client, tokenType tokenType, token string) *Clie
c.Issues = &IssuesService{client: c, timeStats: timeStats}
c.IssueLinks = &IssueLinksService{client: c}
c.Jobs = &JobsService{client: c}
c.Boards = &BoardsService{client: c}
c.Boards = &IssueBoardsService{client: c}
c.Labels = &LabelsService{client: c}
c.MergeRequests = &MergeRequestsService{client: c, timeStats: timeStats}
c.Milestones = &MilestonesService{client: c}
......@@ -700,34 +724,34 @@ func AccessLevel(v AccessLevelValue) *AccessLevelValue {
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.
func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue {
p := new(NotificationLevelValue)
func BuildState(v BuildStateValue) *BuildStateValue {
p := new(BuildStateValue)
*p = v
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.
func Visibility(v VisibilityValue) *VisibilityValue {
p := new(VisibilityValue)
func NotificationLevel(v NotificationLevelValue) *NotificationLevelValue {
p := new(NotificationLevelValue)
*p = v
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.
func Order(v OrderBy) *OrderBy {
p := new(OrderBy)
func OrderBy(v OrderByValue) *OrderByValue {
p := new(OrderByValue)
*p = v
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.
func Build(v BuildState) *BuildState {
p := new(BuildState)
func Visibility(v VisibilityValue) *VisibilityValue {
p := new(VisibilityValue)
*p = v
return p
}
......@@ -27,7 +27,7 @@ import (
// ListJobsOptions are options for two list apis
type ListJobsOptions struct {
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
......
......@@ -6,28 +6,25 @@ import (
"time"
)
// PagesDomainsService handles Pages domains.
// PagesDomainsService handles communication with the pages domains
// related methods of the GitLab API.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/pages_domains.html
// GitLab API docs: https://docs.gitlab.com/ce/api/pages_domains.html
type PagesDomainsService struct {
client *Client
}
type Cert struct {
Expired bool `json:"expired"`
Expiration *time.Time `json:"expiration"`
}
// PageDomain represents a pages domain.
// PagesDomain represents a pages domain.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/pages_domains.html
// GitLab API docs: https://docs.gitlab.com/ce/api/pages_domains.html
type PagesDomain struct {
Domain string `json:"domain"`
URL string `json:"url"`
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.
......@@ -38,7 +35,7 @@ type ListPagesDomainsOptions struct {
ListOptions
}
// ListPagesDomains gets a list of project Domains.
// ListPagesDomains gets a list of project pages domains.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/pages_domains.html#list-pages-domains
......@@ -54,55 +51,55 @@ func (s *PagesDomainsService) ListPagesDomains(pid interface{}, opt *ListPagesDo
return nil, nil, err
}
var pt []*PagesDomain
resp, err := s.client.Do(req, &pt)
var pd []*PagesDomain
resp, err := s.client.Do(req, &pd)
if err != nil {
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:
// https://docs.gitlab.com/ce/api/Pages_Domainss.html#get-Domains-details
func (s *PagesDomainsService) GetPagesDomains(pid interface{}, Domains int, options ...OptionFunc) (*PagesDomain, *Response, error) {
// https://docs.gitlab.com/ce/api/pages_domains.html#single-pages-domain
func (s *PagesDomainsService) GetPagesDomain(pid interface{}, domain string, options ...OptionFunc) (*PagesDomain, *Response, error) {
project, err := parseID(pid)
if err != nil {
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)
if err != nil {
return nil, nil, err
}
pt := new(PagesDomain)
resp, err := s.client.Do(req, pt)
pd := new(PagesDomain)
resp, err := s.client.Do(req, pd)
if err != nil {
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:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#create-a-project-trigger
type AddPagesDomainOptions struct {
// // https://docs.gitlab.com/ce/api/pages_domains.html#create-new-pages-domain
type CreatePagesDomainOptions struct {
Domain *string `url:"domain,omitempty" json:"domain,omitempty"`
Certificate *string `url:"certifiate,omitempty" json:"certifiate,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:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#create-a-project-trigger
func (s *PagesDomainsService) AddPagesDomain(pid interface{}, opt *AddPagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) {
// https://docs.gitlab.com/ce/api/pages_domains.html#create-new-pages-domain
func (s *PagesDomainsService) CreatePagesDomain(pid interface{}, opt *CreatePagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) {
project, err := parseID(pid)
if err != nil {
return nil, nil, err
......@@ -114,61 +111,59 @@ func (s *PagesDomainsService) AddPagesDomain(pid interface{}, opt *AddPagesDomai
return nil, nil, err
}
pt := new(PagesDomain)
resp, err := s.client.Do(req, pt)
pd := new(PagesDomain)
resp, err := s.client.Do(req, pd)
if err != nil {
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:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#update-a-project-trigger
type EditPagesDomainOptions struct {
ID *int `url:"id,omitempty" json:"id,omitempty"`
Domain *string `url:"domain,omitempty" json:"domain,omitempty"`
// https://docs.gitlab.com/ce/api/pages_domains.html#update-pages-domain
type UpdatePagesDomainOptions struct {
Cerificate *string `url:"certifiate" json:"certifiate"`
Key *string `url:"key" json:"key"`
}
// EditPagesDomain edits a domain for a specified project.
// UpdatePagesDomain updates an existing project pages domain.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#update-a-project-trigger
func (s *PagesDomainsService) EditPagesDomain(pid interface{}, trigger int, opt *EditPagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) {
// https://docs.gitlab.com/ce/api/pages_domains.html#update-pages-domain
func (s *PagesDomainsService) UpdatePagesDomain(pid interface{}, domain string, opt *UpdatePagesDomainOptions, options ...OptionFunc) (*PagesDomain, *Response, error) {
project, err := parseID(pid)
if err != nil {
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)
if err != nil {
return nil, nil, err
}
pt := new(PagesDomain)
resp, err := s.client.Do(req, pt)
pd := new(PagesDomain)
resp, err := s.client.Do(req, pd)
if err != nil {
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:
// https://docs.gitlab.com/ce/api/pipeline_triggers.html#remove-a-project-trigger
func (s *PagesDomainsService) DeletePagesDomain(pid interface{}, trigger int, options ...OptionFunc) (*Response, error) {
// https://docs.gitlab.com/ce/api/pages_domains.html#delete-pages-domain
func (s *PagesDomainsService) DeletePagesDomain(pid interface{}, domain string, options ...OptionFunc) (*Response, error) {
project, err := parseID(pid)
if err != nil {
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)
if err != nil {
......
......@@ -76,30 +76,19 @@ func (i PipelineList) String() string {
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.
//
// GitLab API docs: https://docs.gitlab.com/ce/api/pipelines.html#list-project-pipelines
type ListProjectPipelinesOptions struct {
ListOptions
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
Status *BuildState `url:"status,omitempty" json:"status,omitempty"`
Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
YamlErrors *bool `url:"yaml_errors,omitempty" json:"yaml_errors,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
Username *string `url:"username,omitempty" json:"username,omitempty"`
OrderBy *OrderBy `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
Scope *string `url:"scope,omitempty" json:"scope,omitempty"`
Status *BuildStateValue `url:"status,omitempty" json:"status,omitempty"`
Ref *string `url:"ref,omitempty" json:"ref,omitempty"`
YamlErrors *bool `url:"yaml_errors,omitempty" json:"yaml_errors,omitempty"`
Name *string `url:"name,omitempty" json:"name,omitempty"`
Username *string `url:"username,omitempty" json:"username,omitempty"`
OrderBy *OrderByValue `url:"order_by,omitempty" json:"order_by,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
}
// ListProjectPipelines gets a list of project piplines.
......
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