1 package artifacts
2
3
4
5
6
7
8
9 import (
10 "context"
11 "github.com/Azure/go-autorest/autorest"
12 "github.com/Azure/go-autorest/autorest/azure"
13 "github.com/Azure/go-autorest/autorest/validation"
14 "github.com/Azure/go-autorest/tracing"
15 "net/http"
16 )
17
18
19 type PipelineRunClient struct {
20 BaseClient
21 }
22
23
24 func NewPipelineRunClient(endpoint string) PipelineRunClient {
25 return PipelineRunClient{New(endpoint)}
26 }
27
28
29
30
31
32 func (client PipelineRunClient) CancelPipelineRun(ctx context.Context, runID string, isRecursive *bool) (result autorest.Response, err error) {
33 if tracing.IsEnabled() {
34 ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.CancelPipelineRun")
35 defer func() {
36 sc := -1
37 if result.Response != nil {
38 sc = result.Response.StatusCode
39 }
40 tracing.EndSpan(ctx, sc, err)
41 }()
42 }
43 req, err := client.CancelPipelineRunPreparer(ctx, runID, isRecursive)
44 if err != nil {
45 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "CancelPipelineRun", nil, "Failure preparing request")
46 return
47 }
48
49 resp, err := client.CancelPipelineRunSender(req)
50 if err != nil {
51 result.Response = resp
52 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "CancelPipelineRun", resp, "Failure sending request")
53 return
54 }
55
56 result, err = client.CancelPipelineRunResponder(resp)
57 if err != nil {
58 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "CancelPipelineRun", resp, "Failure responding to request")
59 return
60 }
61
62 return
63 }
64
65
66 func (client PipelineRunClient) CancelPipelineRunPreparer(ctx context.Context, runID string, isRecursive *bool) (*http.Request, error) {
67 urlParameters := map[string]interface{}{
68 "endpoint": client.Endpoint,
69 }
70
71 pathParameters := map[string]interface{}{
72 "runId": autorest.Encode("path", runID),
73 }
74
75 const APIVersion = "2019-06-01-preview"
76 queryParameters := map[string]interface{}{
77 "api-version": APIVersion,
78 }
79 if isRecursive != nil {
80 queryParameters["isRecursive"] = autorest.Encode("query", *isRecursive)
81 }
82
83 preparer := autorest.CreatePreparer(
84 autorest.AsPost(),
85 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
86 autorest.WithPathParameters("/pipelineruns/{runId}/cancel", pathParameters),
87 autorest.WithQueryParameters(queryParameters))
88 return preparer.Prepare((&http.Request{}).WithContext(ctx))
89 }
90
91
92
93 func (client PipelineRunClient) CancelPipelineRunSender(req *http.Request) (*http.Response, error) {
94 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
95 }
96
97
98
99 func (client PipelineRunClient) CancelPipelineRunResponder(resp *http.Response) (result autorest.Response, err error) {
100 err = autorest.Respond(
101 resp,
102 azure.WithErrorUnlessStatusCode(http.StatusOK),
103 autorest.ByClosing())
104 result.Response = resp
105 return
106 }
107
108
109
110
111 func (client PipelineRunClient) GetPipelineRun(ctx context.Context, runID string) (result PipelineRun, err error) {
112 if tracing.IsEnabled() {
113 ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.GetPipelineRun")
114 defer func() {
115 sc := -1
116 if result.Response.Response != nil {
117 sc = result.Response.Response.StatusCode
118 }
119 tracing.EndSpan(ctx, sc, err)
120 }()
121 }
122 req, err := client.GetPipelineRunPreparer(ctx, runID)
123 if err != nil {
124 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "GetPipelineRun", nil, "Failure preparing request")
125 return
126 }
127
128 resp, err := client.GetPipelineRunSender(req)
129 if err != nil {
130 result.Response = autorest.Response{Response: resp}
131 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "GetPipelineRun", resp, "Failure sending request")
132 return
133 }
134
135 result, err = client.GetPipelineRunResponder(resp)
136 if err != nil {
137 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "GetPipelineRun", resp, "Failure responding to request")
138 return
139 }
140
141 return
142 }
143
144
145 func (client PipelineRunClient) GetPipelineRunPreparer(ctx context.Context, runID string) (*http.Request, error) {
146 urlParameters := map[string]interface{}{
147 "endpoint": client.Endpoint,
148 }
149
150 pathParameters := map[string]interface{}{
151 "runId": autorest.Encode("path", runID),
152 }
153
154 const APIVersion = "2019-06-01-preview"
155 queryParameters := map[string]interface{}{
156 "api-version": APIVersion,
157 }
158
159 preparer := autorest.CreatePreparer(
160 autorest.AsGet(),
161 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
162 autorest.WithPathParameters("/pipelineruns/{runId}", pathParameters),
163 autorest.WithQueryParameters(queryParameters))
164 return preparer.Prepare((&http.Request{}).WithContext(ctx))
165 }
166
167
168
169 func (client PipelineRunClient) GetPipelineRunSender(req *http.Request) (*http.Response, error) {
170 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
171 }
172
173
174
175 func (client PipelineRunClient) GetPipelineRunResponder(resp *http.Response) (result PipelineRun, err error) {
176 err = autorest.Respond(
177 resp,
178 azure.WithErrorUnlessStatusCode(http.StatusOK),
179 autorest.ByUnmarshallingJSON(&result),
180 autorest.ByClosing())
181 result.Response = autorest.Response{Response: resp}
182 return
183 }
184
185
186
187
188
189
190 func (client PipelineRunClient) QueryActivityRuns(ctx context.Context, pipelineName string, runID string, filterParameters RunFilterParameters) (result ActivityRunsQueryResponse, err error) {
191 if tracing.IsEnabled() {
192 ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.QueryActivityRuns")
193 defer func() {
194 sc := -1
195 if result.Response.Response != nil {
196 sc = result.Response.Response.StatusCode
197 }
198 tracing.EndSpan(ctx, sc, err)
199 }()
200 }
201 if err := validation.Validate([]validation.Validation{
202 {TargetValue: pipelineName,
203 Constraints: []validation.Constraint{{Target: "pipelineName", Name: validation.MaxLength, Rule: 260, Chain: nil},
204 {Target: "pipelineName", Name: validation.MinLength, Rule: 1, Chain: nil},
205 {Target: "pipelineName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}},
206 {TargetValue: filterParameters,
207 Constraints: []validation.Constraint{{Target: "filterParameters.LastUpdatedAfter", Name: validation.Null, Rule: true, Chain: nil},
208 {Target: "filterParameters.LastUpdatedBefore", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
209 return result, validation.NewError("artifacts.PipelineRunClient", "QueryActivityRuns", err.Error())
210 }
211
212 req, err := client.QueryActivityRunsPreparer(ctx, pipelineName, runID, filterParameters)
213 if err != nil {
214 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryActivityRuns", nil, "Failure preparing request")
215 return
216 }
217
218 resp, err := client.QueryActivityRunsSender(req)
219 if err != nil {
220 result.Response = autorest.Response{Response: resp}
221 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryActivityRuns", resp, "Failure sending request")
222 return
223 }
224
225 result, err = client.QueryActivityRunsResponder(resp)
226 if err != nil {
227 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryActivityRuns", resp, "Failure responding to request")
228 return
229 }
230
231 return
232 }
233
234
235 func (client PipelineRunClient) QueryActivityRunsPreparer(ctx context.Context, pipelineName string, runID string, filterParameters RunFilterParameters) (*http.Request, error) {
236 urlParameters := map[string]interface{}{
237 "endpoint": client.Endpoint,
238 }
239
240 pathParameters := map[string]interface{}{
241 "pipelineName": autorest.Encode("path", pipelineName),
242 "runId": autorest.Encode("path", runID),
243 }
244
245 const APIVersion = "2019-06-01-preview"
246 queryParameters := map[string]interface{}{
247 "api-version": APIVersion,
248 }
249
250 preparer := autorest.CreatePreparer(
251 autorest.AsContentType("application/json; charset=utf-8"),
252 autorest.AsPost(),
253 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
254 autorest.WithPathParameters("/pipelines/{pipelineName}/pipelineruns/{runId}/queryActivityruns", pathParameters),
255 autorest.WithJSON(filterParameters),
256 autorest.WithQueryParameters(queryParameters))
257 return preparer.Prepare((&http.Request{}).WithContext(ctx))
258 }
259
260
261
262 func (client PipelineRunClient) QueryActivityRunsSender(req *http.Request) (*http.Response, error) {
263 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
264 }
265
266
267
268 func (client PipelineRunClient) QueryActivityRunsResponder(resp *http.Response) (result ActivityRunsQueryResponse, err error) {
269 err = autorest.Respond(
270 resp,
271 azure.WithErrorUnlessStatusCode(http.StatusOK),
272 autorest.ByUnmarshallingJSON(&result),
273 autorest.ByClosing())
274 result.Response = autorest.Response{Response: resp}
275 return
276 }
277
278
279
280
281 func (client PipelineRunClient) QueryPipelineRunsByWorkspace(ctx context.Context, filterParameters RunFilterParameters) (result PipelineRunsQueryResponse, err error) {
282 if tracing.IsEnabled() {
283 ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.QueryPipelineRunsByWorkspace")
284 defer func() {
285 sc := -1
286 if result.Response.Response != nil {
287 sc = result.Response.Response.StatusCode
288 }
289 tracing.EndSpan(ctx, sc, err)
290 }()
291 }
292 if err := validation.Validate([]validation.Validation{
293 {TargetValue: filterParameters,
294 Constraints: []validation.Constraint{{Target: "filterParameters.LastUpdatedAfter", Name: validation.Null, Rule: true, Chain: nil},
295 {Target: "filterParameters.LastUpdatedBefore", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
296 return result, validation.NewError("artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", err.Error())
297 }
298
299 req, err := client.QueryPipelineRunsByWorkspacePreparer(ctx, filterParameters)
300 if err != nil {
301 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", nil, "Failure preparing request")
302 return
303 }
304
305 resp, err := client.QueryPipelineRunsByWorkspaceSender(req)
306 if err != nil {
307 result.Response = autorest.Response{Response: resp}
308 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", resp, "Failure sending request")
309 return
310 }
311
312 result, err = client.QueryPipelineRunsByWorkspaceResponder(resp)
313 if err != nil {
314 err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", resp, "Failure responding to request")
315 return
316 }
317
318 return
319 }
320
321
322 func (client PipelineRunClient) QueryPipelineRunsByWorkspacePreparer(ctx context.Context, filterParameters RunFilterParameters) (*http.Request, error) {
323 urlParameters := map[string]interface{}{
324 "endpoint": client.Endpoint,
325 }
326
327 const APIVersion = "2019-06-01-preview"
328 queryParameters := map[string]interface{}{
329 "api-version": APIVersion,
330 }
331
332 preparer := autorest.CreatePreparer(
333 autorest.AsContentType("application/json; charset=utf-8"),
334 autorest.AsPost(),
335 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
336 autorest.WithPath("/queryPipelineRuns"),
337 autorest.WithJSON(filterParameters),
338 autorest.WithQueryParameters(queryParameters))
339 return preparer.Prepare((&http.Request{}).WithContext(ctx))
340 }
341
342
343
344 func (client PipelineRunClient) QueryPipelineRunsByWorkspaceSender(req *http.Request) (*http.Response, error) {
345 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
346 }
347
348
349
350 func (client PipelineRunClient) QueryPipelineRunsByWorkspaceResponder(resp *http.Response) (result PipelineRunsQueryResponse, err error) {
351 err = autorest.Respond(
352 resp,
353 azure.WithErrorUnlessStatusCode(http.StatusOK),
354 autorest.ByUnmarshallingJSON(&result),
355 autorest.ByClosing())
356 result.Response = autorest.Response{Response: resp}
357 return
358 }
359
View as plain text