@@ -62,6 +62,23 @@ type RepositoryBranch struct {
6262 Heads []map [string ]interface {}
6363}
6464
65+ type RepositoryTags struct {
66+ Page int
67+ Pagelen int
68+ MaxDepth int
69+ Size int
70+ Next string
71+ Tags []RepositoryTag
72+ }
73+
74+ type RepositoryTag struct {
75+ Type string
76+ Name string
77+ Links map [string ]interface {}
78+ Target map [string ]interface {}
79+ Heads []map [string ]interface {}
80+ }
81+
6582type Pipeline struct {
6683 Type string
6784 Enabled bool
@@ -160,6 +177,38 @@ func (r *Repository) ListBranches(rbo *RepositoryBranchOptions) (*RepositoryBran
160177 return decodeRepositoryBranches (response )
161178}
162179
180+ func (r * Repository ) ListTags (rbo * RepositoryTagOptions ) (* RepositoryTags , error ) {
181+
182+ params := url.Values {}
183+ if rbo .Query != "" {
184+ params .Add ("q" , rbo .Query )
185+ }
186+
187+ if rbo .Sort != "" {
188+ params .Add ("sort" , rbo .Sort )
189+ }
190+
191+ if rbo .PageNum > 0 {
192+ params .Add ("page" , strconv .Itoa (rbo .PageNum ))
193+ }
194+
195+ if rbo .Pagelen > 0 {
196+ params .Add ("pagelen" , strconv .Itoa (rbo .Pagelen ))
197+ }
198+
199+ if rbo .MaxDepth > 0 {
200+ params .Add ("max_depth" , strconv .Itoa (rbo .MaxDepth ))
201+ }
202+
203+ urlStr := r .c .requestUrl ("/repositories/%s/%s/refs/tags?%s" , rbo .Owner , rbo .RepoSlug , params .Encode ())
204+ response , err := r .c .executeRaw ("GET" , urlStr , "" )
205+ if err != nil {
206+ return nil , err
207+ }
208+
209+ return decodeRepositoryTags (response )
210+ }
211+
163212func (r * Repository ) Delete (ro * RepositoryOptions ) (interface {}, error ) {
164213 urlStr := r .c .requestUrl ("/repositories/%s/%s" , ro .Owner , ro .RepoSlug )
165214 return r .c .execute ("DELETE" , urlStr , "" )
@@ -379,6 +428,58 @@ func decodeRepositoryBranches(branchResponse interface{}) (*RepositoryBranches,
379428 return & repositoryBranches , nil
380429}
381430
431+ func decodeRepositoryTags (tagResponse interface {}) (* RepositoryTags , error ) {
432+
433+ var tagResponseMap map [string ]interface {}
434+ err := json .Unmarshal (tagResponse .([]byte ), & tagResponseMap )
435+ if err != nil {
436+ return nil , err
437+ }
438+
439+ tagArray := tagResponseMap ["values" ].([]interface {})
440+ var tags []RepositoryTag
441+ for _ , tagEntry := range tagArray {
442+ var tag RepositoryTag
443+ err = mapstructure .Decode (tagEntry , & tag )
444+ if err == nil {
445+ tags = append (tags , tag )
446+ }
447+ }
448+
449+ page , ok := tagResponseMap ["page" ].(float64 )
450+ if ! ok {
451+ page = 0
452+ }
453+
454+ pagelen , ok := tagResponseMap ["pagelen" ].(float64 )
455+ if ! ok {
456+ pagelen = 0
457+ }
458+ max_depth , ok := tagResponseMap ["max_depth" ].(float64 )
459+ if ! ok {
460+ max_depth = 0
461+ }
462+ size , ok := tagResponseMap ["size" ].(float64 )
463+ if ! ok {
464+ size = 0
465+ }
466+
467+ next , ok := tagResponseMap ["next" ].(string )
468+ if ! ok {
469+ next = ""
470+ }
471+
472+ repositoryTags := RepositoryTags {
473+ Page : int (page ),
474+ Pagelen : int (pagelen ),
475+ MaxDepth : int (max_depth ),
476+ Size : int (size ),
477+ Next : next ,
478+ Tags : tags ,
479+ }
480+ return & repositoryTags , nil
481+ }
482+
382483func decodePipelineRepository (repoResponse interface {}) (* Pipeline , error ) {
383484 repoMap := repoResponse .(map [string ]interface {})
384485
0 commit comments