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
9f70db7d
Commit
9f70db7d
authored
Mar 01, 2019
by
Roli Christen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for group badges API
parent
68c08691
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
163 additions
and
0 deletions
+163
-0
gitlab.go
gitlab.go
+2
-0
group_badges.go
group_badges.go
+161
-0
No files found.
gitlab.go
View file @
9f70db7d
...
...
@@ -302,6 +302,7 @@ type Client struct {
Events
*
EventsService
Features
*
FeaturesService
GitIgnoreTemplates
*
GitIgnoreTemplatesService
GroupBadges
*
GroupBadgesService
GroupIssueBoards
*
GroupIssueBoardsService
GroupMembers
*
GroupMembersService
GroupMilestones
*
GroupMilestonesService
...
...
@@ -444,6 +445,7 @@ func newClient(httpClient *http.Client) *Client {
c
.
Events
=
&
EventsService
{
client
:
c
}
c
.
Features
=
&
FeaturesService
{
client
:
c
}
c
.
GitIgnoreTemplates
=
&
GitIgnoreTemplatesService
{
client
:
c
}
c
.
GroupBadges
=
&
GroupBadgesService
{
client
:
c
}
c
.
GroupIssueBoards
=
&
GroupIssueBoardsService
{
client
:
c
}
c
.
GroupMembers
=
&
GroupMembersService
{
client
:
c
}
c
.
GroupMilestones
=
&
GroupMilestonesService
{
client
:
c
}
...
...
group_badges.go
0 → 100644
View file @
9f70db7d
package
gitlab
import
(
"fmt"
"net/url"
)
// GroupBadge represents a group badge.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/group_badges.html
type
GroupBadge
struct
{
ID
int
`json:"id"`
LinkURL
string
`json:"link_url"`
ImageURL
string
`json:"image_url"`
RenderedLinkURL
string
`json:"rendered_link_url"`
RenderedImageURL
string
`json:"rendered_image_url"`
// Kind represents a project badge kind. Can be empty, when used PreviewProjectBadge().
Kind
string
`json:"kind"`
}
type
GroupBadgesService
struct
{
client
*
Client
}
type
ListGroupBadgesOptions
ListOptions
func
(
s
*
GroupBadgesService
)
ListGroupBadges
(
gid
interface
{},
opt
*
ListGroupBadgesOptions
,
options
...
OptionFunc
)
([]
*
GroupBadge
,
*
Response
,
error
)
{
group
,
err
:=
parseID
(
gid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"groups/%s/badges"
,
url
.
QueryEscape
(
group
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
var
gb
[]
*
GroupBadge
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
gb
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
gb
,
resp
,
err
}
func
(
s
*
GroupBadgesService
)
GetGroupBadge
(
gid
interface
{},
badge
int
,
options
...
OptionFunc
)
(
*
GroupBadge
,
*
Response
,
error
)
{
group
,
err
:=
parseID
(
gid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"groups/%s/badges/%d"
,
url
.
QueryEscape
(
group
),
badge
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
gb
:=
new
(
GroupBadge
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
gb
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
gb
,
resp
,
err
}
type
AddGroupBadgeOptions
struct
{
LinkURL
*
string
`url:"link_url,omitempty" json:"link_url,omitempty"`
ImageURL
*
string
`url:"image_url,omitempty" json:"image_url,omitempty"`
}
func
(
s
*
GroupBadgesService
)
AddGroupBadge
(
gid
interface
{},
opt
*
AddGroupBadgeOptions
,
options
...
OptionFunc
)
(
*
GroupBadge
,
*
Response
,
error
)
{
group
,
err
:=
parseID
(
gid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"groups/%s/badges"
,
url
.
QueryEscape
(
group
))
req
,
err
:=
s
.
client
.
NewRequest
(
"POST"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
gb
:=
new
(
GroupBadge
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
gb
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
gb
,
resp
,
err
}
type
EditGroupBadgeOptions
struct
{
LinkURL
*
string
`url:"link_url,omitempty" json:"link_url,omitempty"`
ImageURL
*
string
`url:"image_url,omitempty" json:"image_url,omitempty"`
}
func
(
s
*
GroupBadgesService
)
EditGroupBadge
(
gid
interface
{},
badge
int
,
opt
*
EditGroupBadgeOptions
,
options
...
OptionFunc
)
(
*
GroupBadge
,
*
Response
,
error
)
{
group
,
err
:=
parseID
(
gid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"groups/%s/badges/%d"
,
url
.
QueryEscape
(
group
),
badge
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
gb
:=
new
(
GroupBadge
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
gb
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
gb
,
resp
,
err
}
func
(
s
*
GroupBadgesService
)
DeleteGroupBadge
(
gid
interface
{},
badge
int
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
group
,
err
:=
parseID
(
gid
)
if
err
!=
nil
{
return
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"group/%s/badges/%d"
,
url
.
QueryEscape
(
group
),
badge
)
req
,
err
:=
s
.
client
.
NewRequest
(
"DELETE"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
err
}
return
s
.
client
.
Do
(
req
,
nil
)
}
type
GroupBadgePreviewOptions
struct
{
LinkURL
*
string
`url:"link_url,omitempty" json:"link_url,omitempty"`
ImageURL
*
string
`url:"image_url,omitempty" json:"image_url,omitempty"`
}
func
(
s
*
GroupBadgesService
)
PreviewGroupBadge
(
gid
interface
{},
opt
*
GroupBadgePreviewOptions
,
options
...
OptionFunc
)
(
*
GroupBadge
,
*
Response
,
error
)
{
group
,
err
:=
parseID
(
gid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"groups/%s/badges/render"
,
url
.
QueryEscape
(
group
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
gb
:=
new
(
GroupBadge
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
gb
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
gb
,
resp
,
err
}
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