Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
b3618c7c
Commit
b3618c7c
authored
Feb 14, 2018
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a couple of too quickly merged PR’s
parent
680b9eba
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
92 additions
and
97 deletions
+92
-97
README.md
README.md
+4
-4
boards.go
boards.go
+0
-0
commits.go
commits.go
+2
-15
pipelines.go
examples/pipelines.go
+2
-2
gitlab.go
gitlab.go
+38
-14
jobs.go
jobs.go
+1
-1
pages_domains.go
pages_domains.go
+43
-48
pipelines.go
pipelines.go
+2
-13
No files found.
README.md
View file @
b3618c7c
...
...
@@ -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
...
...
boards.go
View file @
b3618c7c
This diff is collapsed.
Click to expand it.
commits.go
View file @
b3618c7c
...
...
@@ -47,7 +47,7 @@ type Commit struct {
Message
string
`json:"message"`
ParentIDs
[]
string
`json:"parent_ids"`
Stats
*
CommitStats
`json:"stats"`
Status
*
BuildState
`json:"status"`
Status
*
BuildState
Value
`json:"status"`
}
// 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
//
// 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"`
State
BuildState
Value
`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"`
...
...
@@ -376,19 +376,6 @@ type SetCommitStatusOptions struct {
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
...
...
examples/pipelines.go
View file @
b3618c7c
...
...
@@ -12,12 +12,12 @@ func pipelineExample() {
opt
:=
&
gitlab
.
ListProjectPipelinesOptions
{
Scope
:
gitlab
.
String
(
"branches"
),
Status
:
gitlab
.
Build
(
gitlab
.
Running
),
Status
:
gitlab
.
Build
State
(
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
.
Order
By
(
gitlab
.
OrderByStatus
),
Sort
:
gitlab
.
String
(
"asc"
),
}
...
...
gitlab.go
View file @
b3618c7c
...
...
@@ -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
*
Issue
BoardsService
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
=
&
Issue
BoardsService
{
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 NotificationLevel
Value
//
BuildState is a helper routine that allocates a new BuildState
Value
// to store v and returns a pointer to it.
func
NotificationLevel
(
v
NotificationLevelValue
)
*
NotificationLevel
Value
{
p
:=
new
(
NotificationLevel
Value
)
func
BuildState
(
v
BuildStateValue
)
*
BuildState
Value
{
p
:=
new
(
BuildState
Value
)
*
p
=
v
return
p
}
//
Visibility is a helper routine that allocates a new Visibility
Value
//
NotificationLevel is a helper routine that allocates a new NotificationLevel
Value
// to store v and returns a pointer to it.
func
Visibility
(
v
VisibilityValue
)
*
Visibility
Value
{
p
:=
new
(
Visibility
Value
)
func
NotificationLevel
(
v
NotificationLevelValue
)
*
NotificationLevel
Value
{
p
:=
new
(
NotificationLevel
Value
)
*
p
=
v
return
p
}
// Order
is a helper routine that allocates a new OrderBy
// Order
By 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
Order
By
(
v
OrderByValue
)
*
OrderByValue
{
p
:=
new
(
OrderBy
Value
)
*
p
=
v
return
p
}
//
Build is a helper routine that allocates a new BuildStat
e
//
Visibility is a helper routine that allocates a new VisibilityValu
e
// to store v and returns a pointer to it.
func
Build
(
v
BuildState
)
*
BuildStat
e
{
p
:=
new
(
BuildStat
e
)
func
Visibility
(
v
VisibilityValue
)
*
VisibilityValu
e
{
p
:=
new
(
VisibilityValu
e
)
*
p
=
v
return
p
}
jobs.go
View file @
b3618c7c
...
...
@@ -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
[]
BuildState
Value
`url:"scope,omitempty" json:"scope,omitempty"`
}
// JobsService handles communication with the ci builds related methods
...
...
pages_domains.go
View file @
b3618c7c
...
...
@@ -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
D
omains.
// ListPagesDomains gets a list of project
pages d
omains.
//
// 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
p
t
[]
*
PagesDomain
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
p
t
)
var
p
d
[]
*
PagesDomain
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
p
d
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
p
t
,
resp
,
err
return
p
d
,
resp
,
err
}
// GetPagesDomain
s 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
)
GetPagesDomain
s
(
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
}
p
t
:=
new
(
PagesDomain
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
t
)
p
d
:=
new
(
PagesDomain
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
d
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
p
t
,
resp
,
err
return
p
d
,
resp
,
err
}
//
AddPagesDomainOptions represents the available Add
PagesDomain() options.
//
CreatePagesDomainOptions represents the available Create
PagesDomain() options.
//
// GitLab API docs:
//
https://docs.gitlab.com/ce/api/pipeline_triggers.html#create-a-project-trigger
type
Add
PagesDomainOptions
struct
{
//
// https://docs.gitlab.com/ce/api/pages_domains.html#create-new-pages-domain
type
Create
PagesDomainOptions
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/p
ipeline_triggers.html#create-a-project-trigger
func
(
s
*
PagesDomainsService
)
AddPagesDomain
(
pid
interface
{},
opt
*
Add
PagesDomainOptions
,
options
...
OptionFunc
)
(
*
PagesDomain
,
*
Response
,
error
)
{
// https://docs.gitlab.com/ce/api/p
ages_domains.html#create-new-pages-domain
func
(
s
*
PagesDomainsService
)
CreatePagesDomain
(
pid
interface
{},
opt
*
Create
PagesDomainOptions
,
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
}
p
t
:=
new
(
PagesDomain
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
t
)
p
d
:=
new
(
PagesDomain
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
d
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
p
t
,
resp
,
err
return
p
d
,
resp
,
err
}
//
EditPagesDomainOptions represents the available Edit
PagesDomain() options.
//
UpdatePagesDomainOptions represents the available Update
PagesDomain() 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/p
ipeline_triggers.html#update-a-project-trigger
func
(
s
*
PagesDomainsService
)
EditPagesDomain
(
pid
interface
{},
trigger
int
,
opt
*
Edit
PagesDomainOptions
,
options
...
OptionFunc
)
(
*
PagesDomain
,
*
Response
,
error
)
{
// https://docs.gitlab.com/ce/api/p
ages_domains.html#update-pages-domain
func
(
s
*
PagesDomainsService
)
UpdatePagesDomain
(
pid
interface
{},
domain
string
,
opt
*
Update
PagesDomainOptions
,
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
}
p
t
:=
new
(
PagesDomain
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
t
)
p
d
:=
new
(
PagesDomain
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
p
d
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
p
t
,
resp
,
err
return
p
d
,
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/p
ipeline_triggers.html#remove-a-project-trigger
func
(
s
*
PagesDomainsService
)
DeletePagesDomain
(
pid
interface
{},
trigger
int
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
// https://docs.gitlab.com/ce/api/p
ages_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
{
...
...
pipelines.go
View file @
b3618c7c
...
...
@@ -76,29 +76,18 @@ 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"`
Status
*
BuildState
Value
`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"`
OrderBy
*
OrderBy
Value
`url:"order_by,omitempty" json:"order_by,omitempty"`
Sort
*
string
`url:"sort,omitempty" json:"sort,omitempty"`
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment