@@ -62,6 +62,23 @@ type RepositoryBranch struct {
62
62
Heads []map [string ]interface {}
63
63
}
64
64
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
+
65
82
type Pipeline struct {
66
83
Type string
67
84
Enabled bool
@@ -160,6 +177,38 @@ func (r *Repository) ListBranches(rbo *RepositoryBranchOptions) (*RepositoryBran
160
177
return decodeRepositoryBranches (response )
161
178
}
162
179
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
+
163
212
func (r * Repository ) Delete (ro * RepositoryOptions ) (interface {}, error ) {
164
213
urlStr := r .c .requestUrl ("/repositories/%s/%s" , ro .Owner , ro .RepoSlug )
165
214
return r .c .execute ("DELETE" , urlStr , "" )
@@ -379,6 +428,58 @@ func decodeRepositoryBranches(branchResponse interface{}) (*RepositoryBranches,
379
428
return & repositoryBranches , nil
380
429
}
381
430
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
+
382
483
func decodePipelineRepository (repoResponse interface {}) (* Pipeline , error ) {
383
484
repoMap := repoResponse .(map [string ]interface {})
384
485
0 commit comments