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
9ab64883
Commit
9ab64883
authored
Oct 04, 2017
by
Stany MARCEL
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Take svanharmelen review remarks into account
Signed-off-by:
Stany MARCEL
<
stanypub@gmail.com
>
parent
74b5caef
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
30 deletions
+46
-30
wikis.go
wikis.go
+46
-30
No files found.
wikis.go
View file @
9ab64883
...
@@ -20,14 +20,14 @@ import (
...
@@ -20,14 +20,14 @@ import (
)
)
// WikisService handles communication with the wikis related methods of
// WikisService handles communication with the wikis related methods of
// the Gitlab API
Introduced in GitLab 10.0
.
// the Gitlab API.
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
type
WikisService
struct
{
type
WikisService
struct
{
client
*
Client
client
*
Client
}
}
// WikiFormat represents the available
formats that can be used for a wiki page
// WikiFormat represents the available
wiki formats
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html
type
WikiFormat
string
type
WikiFormat
string
...
@@ -49,13 +49,13 @@ type Wiki struct {
...
@@ -49,13 +49,13 @@ type Wiki struct {
Title
string
`json:"title"`
Title
string
`json:"title"`
}
}
func
(
t
Wiki
)
String
()
string
{
func
(
w
Wiki
)
String
()
string
{
return
Stringify
(
t
)
return
Stringify
(
w
)
}
}
// ListWikisOptions represents the available ListWikis
()
options.
// ListWikisOptions represents the available ListWikis options.
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html#
get-a-list-of-wiki
s
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html#
list-wiki-page
s
type
ListWikisOptions
struct
{
type
ListWikisOptions
struct
{
WithContent
*
bool
`url:"with_content,omitempty" json:"with_content,omitempty"`
WithContent
*
bool
`url:"with_content,omitempty" json:"with_content,omitempty"`
}
}
...
@@ -69,7 +69,6 @@ func (s *WikisService) ListWikis(pid interface{}, opt *ListWikisOptions, options
...
@@ -69,7 +69,6 @@ func (s *WikisService) ListWikis(pid interface{}, opt *ListWikisOptions, options
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis"
,
url
.
QueryEscape
(
project
))
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
...
@@ -77,13 +76,13 @@ func (s *WikisService) ListWikis(pid interface{}, opt *ListWikisOptions, options
...
@@ -77,13 +76,13 @@ func (s *WikisService) ListWikis(pid interface{}, opt *ListWikisOptions, options
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
var
t
[]
*
Wiki
var
w
[]
*
Wiki
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
t
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
w
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
}
}
return
t
,
resp
,
err
return
w
,
resp
,
err
}
}
// GetWikiPage gets a wiki page for a given project.
// GetWikiPage gets a wiki page for a given project.
...
@@ -94,7 +93,6 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Opti
...
@@ -94,7 +93,6 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Opti
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis/%s"
,
url
.
QueryEscape
(
project
),
url
.
QueryEscape
(
slug
))
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis/%s"
,
url
.
QueryEscape
(
project
),
url
.
QueryEscape
(
slug
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
...
@@ -102,67 +100,85 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Opti
...
@@ -102,67 +100,85 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Opti
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
var
t
*
Wiki
var
w
*
Wiki
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
t
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
w
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
}
}
return
t
,
resp
,
err
return
w
,
resp
,
err
}
}
// Create
NewWikiPageOptions represents options to CreateNew
WikiPage
// Create
WikiPageOptions represents options to Create
WikiPage
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html#create-a-new-wiki-page
// GitLab API docs:
type
CreateNewWikiPageOptions
struct
{
// https://docs.gitlab.com/ce/api/wikis.html#create-a-new-wiki-page
type
CreateWikiPageOptions
struct
{
Content
*
string
`url:"content" json:"content"`
Content
*
string
`url:"content" json:"content"`
Title
*
string
`url:"title" json:"title"`
Title
*
string
`url:"title" json:"title"`
Format
*
string
`url:"format,omitempty" json:"format,omitempty"`
Format
*
string
`url:"format,omitempty" json:"format,omitempty"`
}
}
// CreateNewWikiPage creates a new wiki page for the given repository with the given title, slug, and content..
// CreateWikiPage creates a new wiki page for the given repository with
// the given title, slug, and content..
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html#create-a-new-wiki-page
// GitLab API docs:
func
(
s
*
WikisService
)
CreateNewWikiPage
(
pid
interface
{},
opt
*
CreateNewWikiPageOptions
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
// https://docs.gitlab.com/ce/api/wikis.html#create-a-new-wiki-page
func
(
s
*
WikisService
)
CreateWikiPage
(
pid
interface
{},
opt
*
CreateWikiPageOptions
,
options
...
OptionFunc
)
(
*
Wiki
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis"
,
url
.
QueryEscape
(
project
))
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"POST"
,
u
,
opt
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"POST"
,
u
,
opt
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
nil
,
err
}
}
return
s
.
client
.
Do
(
req
,
nil
)
w
:=
new
(
Wiki
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
w
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
w
,
resp
,
err
}
}
// EditWikiPageOptions represents options to EditWikiPage
// EditWikiPageOptions represents options to EditWikiPage
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html#edit-an-existing-wiki-page
// GitLab API docs:
// https://docs.gitlab.com/ce/api/wikis.html#edit-an-existing-wiki-page
type
EditWikiPageOptions
struct
{
type
EditWikiPageOptions
struct
{
Content
*
string
`url:"content" json:"content"`
Content
*
string
`url:"content" json:"content"`
Title
*
string
`url:"title" json:"title"`
Title
*
string
`url:"title" json:"title"`
Format
*
string
`url:"format,omitempty" json:"format,omitempty"`
Format
*
string
`url:"format,omitempty" json:"format,omitempty"`
}
}
// EditWikiPage Updates an existing wiki page. At least one parameter is required to update the wiki page.
// EditWikiPage Updates an existing wiki page. At least one parameter is
// required to update the wiki page.
//
//
// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html#edit-an-existing-wiki-page
// GitLab API docs:
func
(
s
*
WikisService
)
EditWikiPage
(
pid
interface
{},
slug
string
,
opt
*
EditWikiPageOptions
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
// https://docs.gitlab.com/ce/api/wikis.html#edit-an-existing-wiki-page
func
(
s
*
WikisService
)
EditWikiPage
(
pid
interface
{},
slug
string
,
opt
*
EditWikiPageOptions
,
options
...
OptionFunc
)
(
*
Wiki
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis/%s"
,
url
.
QueryEscape
(
project
),
url
.
QueryEscape
(
slug
))
u
:=
fmt
.
Sprintf
(
"projects/%s/wikis/%s"
,
url
.
QueryEscape
(
project
),
url
.
QueryEscape
(
slug
))
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
,
err
return
nil
,
nil
,
err
}
}
return
s
.
client
.
Do
(
req
,
nil
)
w
:=
new
(
Wiki
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
w
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
w
,
resp
,
err
}
}
// DeleteWikiPage deletes a wiki page with a given slug.
// DeleteWikiPage deletes a wiki page with a given slug.
...
...
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