@@ -8,22 +8,35 @@ import (
8
8
)
9
9
10
10
const (
11
- pipelinePath = "pipeline/api/pipelines/%s"
12
- pipelineListPath = "pipeline/api/pipelines/list"
13
- pipelineExecutionPath = "pipeline/api/pipelines/execution/url"
14
- pipelineExecutionGetPath = "pipeline/api/pipelines/execution/v2/%s"
15
- pipelineExecutionSummaryPath = "pipeline/api/pipelines/execution/summary"
11
+ // Base API paths
12
+ pipelinePath = "api/pipelines/%s"
13
+ pipelineListPath = "api/pipelines/list"
14
+ pipelineExecutionPath = "api/pipelines/execution/url"
15
+ pipelineExecutionGetPath = "api/pipelines/execution/v2/%s"
16
+ pipelineExecutionSummaryPath = "api/pipelines/execution/summary"
17
+
18
+ // Prefix to prepend for external API calls
19
+ externalPathPrefix = "pipeline/"
16
20
)
17
21
18
22
type PipelineService struct {
19
23
Client * Client
24
+ UseInternalPaths bool
25
+ }
26
+
27
+ func (p * PipelineService ) buildPath (basePath string ) string {
28
+ if p .UseInternalPaths {
29
+ return basePath
30
+ }
31
+ return externalPathPrefix + basePath
20
32
}
21
33
22
34
func (p * PipelineService ) Get (ctx context.Context , scope dto.Scope , pipelineID string ) (
23
35
* dto.Entity [dto.PipelineData ],
24
36
error ,
25
37
) {
26
- path := fmt .Sprintf (pipelinePath , pipelineID )
38
+ pathTemplate := p .buildPath (pipelinePath )
39
+ path := fmt .Sprintf (pathTemplate , pipelineID )
27
40
28
41
// Prepare query parameters
29
42
params := make (map [string ]string )
@@ -46,6 +59,7 @@ func (p *PipelineService) List(
46
59
scope dto.Scope ,
47
60
opts * dto.PipelineListOptions ,
48
61
) (* dto.ListOutput [dto.PipelineListItem ], error ) {
62
+ path := p .buildPath (pipelineListPath )
49
63
// Prepare query parameters
50
64
params := make (map [string ]string )
51
65
addScope (scope , params )
@@ -76,7 +90,7 @@ func (p *PipelineService) List(
76
90
response := & dto.ListOutput [dto.PipelineListItem ]{}
77
91
78
92
// Make the POST request
79
- err := p .Client .Post (ctx , pipelineListPath , params , requestBody , response )
93
+ err := p .Client .Post (ctx , path , params , requestBody , response )
80
94
if err != nil {
81
95
return nil , err
82
96
}
@@ -89,6 +103,7 @@ func (p *PipelineService) ListExecutions(
89
103
scope dto.Scope ,
90
104
opts * dto.PipelineExecutionOptions ,
91
105
) (* dto.ListOutput [dto.PipelineExecution ], error ) {
106
+ path := p .buildPath (pipelineExecutionSummaryPath )
92
107
// Prepare query parameters
93
108
params := make (map [string ]string )
94
109
addScope (scope , params )
@@ -132,7 +147,7 @@ func (p *PipelineService) ListExecutions(
132
147
response := & dto.ListOutput [dto.PipelineExecution ]{}
133
148
134
149
// Make the POST request
135
- err := p .Client .Post (ctx , pipelineExecutionSummaryPath , params , requestBody , response )
150
+ err := p .Client .Post (ctx , path , params , requestBody , response )
136
151
if err != nil {
137
152
return nil , fmt .Errorf ("failed to list pipeline executions: %w" , err )
138
153
}
@@ -146,7 +161,8 @@ func (p *PipelineService) GetExecution(
146
161
scope dto.Scope ,
147
162
planExecutionID string ,
148
163
) (* dto.Entity [dto.PipelineExecution ], error ) {
149
- path := fmt .Sprintf (pipelineExecutionGetPath , planExecutionID )
164
+ pathTemplate := p .buildPath (pipelineExecutionGetPath )
165
+ path := fmt .Sprintf (pathTemplate , planExecutionID )
150
166
151
167
// Prepare query parameters
152
168
params := make (map [string ]string )
@@ -175,7 +191,7 @@ func (p *PipelineService) FetchExecutionURL(
175
191
scope dto.Scope ,
176
192
pipelineID , planExecutionID string ,
177
193
) (string , error ) {
178
- path := pipelineExecutionPath
194
+ path := p . buildPath ( pipelineExecutionPath )
179
195
180
196
// Prepare query parameters
181
197
params := make (map [string ]string )
0 commit comments