Commit 31ea4f31 authored by Thomas Bruyelle's avatar Thomas Bruyelle Committed by Sander van Harmelen

Snippet: add Explore API call (#303)

* Snippet: add Explore API call

See https://docs.gitlab.com/ce/api/snippets.html#explore-all-public-snippets

* Snippet: add missing raw_url property

* Some renames for consistency
parent a1095b75
...@@ -49,6 +49,7 @@ type Snippet struct { ...@@ -49,6 +49,7 @@ type Snippet struct {
UpdatedAt *time.Time `json:"updated_at"` UpdatedAt *time.Time `json:"updated_at"`
CreatedAt *time.Time `json:"created_at"` CreatedAt *time.Time `json:"created_at"`
WebURL string `json:"web_url"` WebURL string `json:"web_url"`
RawURL string `json:"raw_url"`
} }
func (s Snippet) String() string { func (s Snippet) String() string {
...@@ -204,3 +205,29 @@ func (s *SnippetsService) SnippetContent(snippet int, options ...OptionFunc) ([] ...@@ -204,3 +205,29 @@ func (s *SnippetsService) SnippetContent(snippet int, options ...OptionFunc) ([]
return b.Bytes(), resp, err return b.Bytes(), resp, err
} }
// ExploreSnippetsOptions represents the available ExploreSnippets() options.
//
// https://docs.gitlab.com/ce/api/snippets.html#explore-all-public-snippets
type ExploreSnippetsOptions struct {
ListOptions
}
// ExploreSnippets gets the list of public snippets.
//
// GitLab API docs:
// https://docs.gitlab.com/ce/api/snippets.html#explore-all-public-snippets
func (s *SnippetsService) ExploreSnippets(opt *ExploreSnippetsOptions, options ...OptionFunc) ([]*Snippet, *Response, error) {
req, err := s.client.NewRequest("GET", "snippets/public", nil, options)
if err != nil {
return nil, nil, err
}
var ps []*Snippet
resp, err := s.client.Do(req, &ps)
if err != nil {
return nil, resp, err
}
return ps, resp, err
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment