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
a9b79048
Commit
a9b79048
authored
Mar 22, 2017
by
Johan Brandhorst
Committed by
Sander van Harmelen
Mar 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Build Trigger endpoints (#150)
* Add Build Trigger endpoints * Update variable name
parent
5b756e2f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
114 additions
and
0 deletions
+114
-0
projects.go
projects.go
+114
-0
No files found.
projects.go
View file @
a9b79048
...
...
@@ -879,6 +879,120 @@ func (s *ProjectsService) DeleteProjectHook(pid interface{}, hook int, options .
return
s
.
client
.
Do
(
req
,
nil
)
}
// BuildTrigger represents a project build trigger.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/build_triggers.md#build-triggers
type
BuildTrigger
struct
{
CreatedAt
*
time
.
Time
`json:"created_at"`
DeletedAt
*
time
.
Time
`json:"deleted_at"`
LastUsed
*
time
.
Time
`json:"last_used"`
Token
string
`json:"token"`
UpdatedAt
*
time
.
Time
`json:"updated_at"`
}
// ListBuildTriggersOptions represents the available ListBuildTriggers() options.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/build_triggers.md#list-project-triggers
type
ListBuildTriggersOptions
struct
{
ListOptions
}
// ListBuildTriggers gets a list of project triggers.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/build_triggers.md#list-project-triggers
func
(
s
*
ProjectsService
)
ListBuildTriggers
(
pid
interface
{},
opt
*
ListBuildTriggersOptions
,
options
...
OptionFunc
)
([]
*
BuildTrigger
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/triggers"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
var
bt
[]
*
BuildTrigger
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
bt
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
bt
,
resp
,
err
}
// GetBuildTrigger gets a specific build trigger for a project.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/build_triggers.md#get-trigger-details
func
(
s
*
ProjectsService
)
GetBuildTrigger
(
pid
interface
{},
token
string
,
options
...
OptionFunc
)
(
*
BuildTrigger
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/triggers/%v"
,
url
.
QueryEscape
(
project
),
token
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
bt
:=
new
(
BuildTrigger
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
bt
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
bt
,
resp
,
err
}
// AddBuildTrigger adds a build trigger to a specified project.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/build_triggers.md#create-a-project-trigger
func
(
s
*
ProjectsService
)
AddBuildTrigger
(
pid
interface
{},
options
...
OptionFunc
)
(
*
BuildTrigger
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/triggers"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"POST"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
bt
:=
new
(
BuildTrigger
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
bt
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
bt
,
resp
,
err
}
// DeleteBuildTrigger removes a trigger from a project.
//
// GitLab API docs:
// https://gitlab.com/gitlab-org/gitlab-ce/blob/8-16-stable/doc/api/build_triggers.md#remove-a-project-trigger
func
(
s
*
ProjectsService
)
DeleteBuildTrigger
(
pid
interface
{},
token
string
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/triggers/%s"
,
url
.
QueryEscape
(
project
),
token
)
req
,
err
:=
s
.
client
.
NewRequest
(
"DELETE"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
err
}
return
s
.
client
.
Do
(
req
,
nil
)
}
// ProjectForkRelation represents a project fork relationship.
//
// GitLab API docs:
...
...
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