@@ -100,6 +100,11 @@ type PipelineKeyPair struct {
100
100
PrivateKey string
101
101
}
102
102
103
+ type PipelineBuildNumber struct {
104
+ Type string
105
+ Next int
106
+ }
107
+
103
108
func (r * Repository ) Create (ro * RepositoryOptions ) (* Repository , error ) {
104
109
data := r .buildRepositoryBody (ro )
105
110
urlStr := r .c .requestUrl ("/repositories/%s/%s" , ro .Owner , ro .RepoSlug )
@@ -259,6 +264,18 @@ func (r *Repository) AddPipelineKeyPair(rpkpo *RepositoryPipelineKeyPairOptions)
259
264
return decodePipelineKeyPairRepository (response )
260
265
}
261
266
267
+ func (r * Repository ) UpdatePipelineBuildNumber (rpbno * RepositoryPipelineBuildNumberOptions ) (* PipelineBuildNumber , error ) {
268
+ data := r .buildPipelineBuildNumberBody (rpbno )
269
+ urlStr := r .c .requestUrl ("/repositories/%s/%s/pipelines_config/build_number" , rpbno .Owner , rpbno .RepoSlug )
270
+
271
+ response , err := r .c .execute ("PUT" , urlStr , data )
272
+ if err != nil {
273
+ return nil , err
274
+ }
275
+
276
+ return decodePipelineBuildNumberRepository (response )
277
+ }
278
+
262
279
func (r * Repository ) buildJsonBody (body map [string ]interface {}) string {
263
280
264
281
data , err := json .Marshal (body )
@@ -344,6 +361,15 @@ func (r *Repository) buildPipelineKeyPairBody(rpkpo *RepositoryPipelineKeyPairOp
344
361
return r .buildJsonBody (body )
345
362
}
346
363
364
+ func (r * Repository ) buildPipelineBuildNumberBody (rpbno * RepositoryPipelineBuildNumberOptions ) string {
365
+
366
+ body := map [string ]interface {}{}
367
+
368
+ body ["next" ] = rpbno .Next
369
+
370
+ return r .buildJsonBody (body )
371
+ }
372
+
347
373
func decodeRepository (repoResponse interface {}) (* Repository , error ) {
348
374
repoMap := repoResponse .(map [string ]interface {})
349
375
@@ -528,6 +554,22 @@ func decodePipelineKeyPairRepository(repoResponse interface{}) (*PipelineKeyPair
528
554
return pipelineKeyPair , nil
529
555
}
530
556
557
+ func decodePipelineBuildNumberRepository (repoResponse interface {}) (* PipelineBuildNumber , error ) {
558
+ repoMap := repoResponse .(map [string ]interface {})
559
+
560
+ if repoMap ["type" ] == "error" {
561
+ return nil , DecodeError (repoMap )
562
+ }
563
+
564
+ var pipelineBuildNumber = new (PipelineBuildNumber )
565
+ err := mapstructure .Decode (repoMap , pipelineBuildNumber )
566
+ if err != nil {
567
+ return nil , err
568
+ }
569
+
570
+ return pipelineBuildNumber , nil
571
+ }
572
+
531
573
func (rf RepositoryFile ) String () string {
532
574
return rf .Path
533
575
}
0 commit comments