diff options
Diffstat (limited to 'vendor/github.com/xanzy/go-gitlab/wikis.go')
-rw-r--r-- | vendor/github.com/xanzy/go-gitlab/wikis.go | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/vendor/github.com/xanzy/go-gitlab/wikis.go b/vendor/github.com/xanzy/go-gitlab/wikis.go index ffabef845f..7437cc3c7e 100644 --- a/vendor/github.com/xanzy/go-gitlab/wikis.go +++ b/vendor/github.com/xanzy/go-gitlab/wikis.go @@ -1,4 +1,5 @@ -// Copyright 2017, Stany MARCEL +// +// Copyright 2021, Stany MARCEL // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -16,6 +17,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) @@ -27,26 +29,14 @@ type WikisService struct { client *Client } -// WikiFormat represents the available wiki formats. -// -// GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html -type WikiFormat string - -// The available wiki formats. -const ( - WikiFormatMarkdown WikiFormat = "markdown" - WikiFormatRFoc WikiFormat = "rdoc" - WikiFormatASCIIDoc WikiFormat = "asciidoc" -) - // Wiki represents a GitLab wiki. // // GitLab API docs: https://docs.gitlab.com/ce/api/wikis.html type Wiki struct { - Content string `json:"content"` - Format WikiFormat `json:"format"` - Slug string `json:"slug"` - Title string `json:"title"` + Content string `json:"content"` + Format WikiFormatValue `json:"format"` + Slug string `json:"slug"` + Title string `json:"title"` } func (w Wiki) String() string { @@ -73,18 +63,18 @@ func (s *WikisService) ListWikis(pid interface{}, opt *ListWikisOptions, options } u := fmt.Sprintf("projects/%s/wikis", pathEscape(project)) - req, err := s.client.NewRequest("GET", u, opt, options) + req, err := s.client.NewRequest(http.MethodGet, u, opt, options) if err != nil { return nil, nil, err } - var w []*Wiki - resp, err := s.client.Do(req, &w) + var ws []*Wiki + resp, err := s.client.Do(req, &ws) if err != nil { return nil, resp, err } - return w, resp, err + return ws, resp, err } // GetWikiPage gets a wiki page for a given project. @@ -98,13 +88,13 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Requ } u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug)) - req, err := s.client.NewRequest("GET", u, nil, options) + req, err := s.client.NewRequest(http.MethodGet, u, nil, options) if err != nil { return nil, nil, err } - var w *Wiki - resp, err := s.client.Do(req, &w) + w := new(Wiki) + resp, err := s.client.Do(req, w) if err != nil { return nil, resp, err } @@ -117,9 +107,9 @@ func (s *WikisService) GetWikiPage(pid interface{}, slug string, options ...Requ // GitLab API docs: // https://docs.gitlab.com/ce/api/wikis.html#create-a-new-wiki-page type CreateWikiPageOptions struct { - Content *string `url:"content" json:"content"` - Title *string `url:"title" json:"title"` - Format *string `url:"format,omitempty" json:"format,omitempty"` + Content *string `url:"content,omitempty" json:"content,omitempty"` + Title *string `url:"title,omitempty" json:"title,omitempty"` + Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"` } // CreateWikiPage creates a new wiki page for the given repository with @@ -134,7 +124,7 @@ func (s *WikisService) CreateWikiPage(pid interface{}, opt *CreateWikiPageOption } u := fmt.Sprintf("projects/%s/wikis", pathEscape(project)) - req, err := s.client.NewRequest("POST", u, opt, options) + req, err := s.client.NewRequest(http.MethodPost, u, opt, options) if err != nil { return nil, nil, err } @@ -153,9 +143,9 @@ func (s *WikisService) CreateWikiPage(pid interface{}, opt *CreateWikiPageOption // GitLab API docs: // https://docs.gitlab.com/ce/api/wikis.html#edit-an-existing-wiki-page type EditWikiPageOptions struct { - Content *string `url:"content" json:"content"` - Title *string `url:"title" json:"title"` - Format *string `url:"format,omitempty" json:"format,omitempty"` + Content *string `url:"content,omitempty" json:"content,omitempty"` + Title *string `url:"title,omitempty" json:"title,omitempty"` + Format *WikiFormatValue `url:"format,omitempty" json:"format,omitempty"` } // EditWikiPage Updates an existing wiki page. At least one parameter is @@ -170,7 +160,7 @@ func (s *WikisService) EditWikiPage(pid interface{}, slug string, opt *EditWikiP } u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug)) - req, err := s.client.NewRequest("PUT", u, opt, options) + req, err := s.client.NewRequest(http.MethodPut, u, opt, options) if err != nil { return nil, nil, err } @@ -195,7 +185,7 @@ func (s *WikisService) DeleteWikiPage(pid interface{}, slug string, options ...R } u := fmt.Sprintf("projects/%s/wikis/%s", pathEscape(project), url.PathEscape(slug)) - req, err := s.client.NewRequest("DELETE", u, nil, options) + req, err := s.client.NewRequest(http.MethodDelete, u, nil, options) if err != nil { return nil, err } |