File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 1- 0.19.2
1+ 0.19.3
Original file line number Diff line number Diff line change 1919 Tokens () ITokenAPI
2020 RuntimeEnvironments () IRuntimeEnvironmentAPI
2121 Workflows () IWorkflowAPI
22+ Progresses () IProgressAPI
2223 }
2324)
2425
@@ -47,6 +48,10 @@ func (c *codefresh) Workflows() IWorkflowAPI {
4748 return newWorkflowAPI (c )
4849}
4950
51+ func (c * codefresh ) Progresses () IProgressAPI {
52+ return newProgressAPI (c )
53+ }
54+
5055func (c * codefresh ) requestAPI (opt * requestOptions ) (* http.Response , error ) {
5156 var body []byte
5257 finalURL := fmt .Sprintf ("%s%s" , c .host , opt .path )
Original file line number Diff line number Diff line change 1+ package codefresh
2+
3+ import (
4+ "fmt"
5+ )
6+
7+ type (
8+ IProgressAPI interface {
9+ Get (string ) (* Progress , error )
10+ }
11+
12+ progress struct {
13+ codefresh Codefresh
14+ }
15+
16+ Progress struct {
17+ ID string `json:"id"`
18+ Status string `json:"status"`
19+ Location Location `json:"location"`
20+ }
21+
22+ Location struct {
23+ Type string `json:"type"`
24+ URL string `json:"url"`
25+ }
26+ )
27+
28+ func newProgressAPI (codefresh Codefresh ) IProgressAPI {
29+ return & progress {codefresh }
30+ }
31+
32+ func (p * progress ) Get (id string ) (* Progress , error ) {
33+ result := & Progress {}
34+ resp , err := p .codefresh .requestAPI (& requestOptions {
35+ path : fmt .Sprintf ("/api/progress/%s" , id ),
36+ method : "GET" ,
37+ })
38+ // failed in api call
39+ if err != nil {
40+ return nil , err
41+ }
42+ err = p .codefresh .decodeResponseInto (resp , result )
43+ // failed to decode
44+ if err != nil {
45+ return nil , err
46+ }
47+ return result , nil
48+ }
You can’t perform that action at this time.
0 commit comments