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 DataFlowClient struct {
20 BaseClient
21 }
22
23
24 func NewDataFlowClient(endpoint string) DataFlowClient {
25 return DataFlowClient{New(endpoint)}
26 }
27
28
29
30
31
32
33
34 func (client DataFlowClient) CreateOrUpdateDataFlow(ctx context.Context, dataFlowName string, dataFlow DataFlowResource, ifMatch string) (result DataFlowCreateOrUpdateDataFlowFuture, err error) {
35 if tracing.IsEnabled() {
36 ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowClient.CreateOrUpdateDataFlow")
37 defer func() {
38 sc := -1
39 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
40 sc = result.FutureAPI.Response().StatusCode
41 }
42 tracing.EndSpan(ctx, sc, err)
43 }()
44 }
45 if err := validation.Validate([]validation.Validation{
46 {TargetValue: dataFlowName,
47 Constraints: []validation.Constraint{{Target: "dataFlowName", Name: validation.MaxLength, Rule: 260, Chain: nil},
48 {Target: "dataFlowName", Name: validation.MinLength, Rule: 1, Chain: nil},
49 {Target: "dataFlowName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}}}); err != nil {
50 return result, validation.NewError("artifacts.DataFlowClient", "CreateOrUpdateDataFlow", err.Error())
51 }
52
53 req, err := client.CreateOrUpdateDataFlowPreparer(ctx, dataFlowName, dataFlow, ifMatch)
54 if err != nil {
55 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "CreateOrUpdateDataFlow", nil, "Failure preparing request")
56 return
57 }
58
59 result, err = client.CreateOrUpdateDataFlowSender(req)
60 if err != nil {
61 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "CreateOrUpdateDataFlow", nil, "Failure sending request")
62 return
63 }
64
65 return
66 }
67
68
69 func (client DataFlowClient) CreateOrUpdateDataFlowPreparer(ctx context.Context, dataFlowName string, dataFlow DataFlowResource, ifMatch string) (*http.Request, error) {
70 urlParameters := map[string]interface{}{
71 "endpoint": client.Endpoint,
72 }
73
74 pathParameters := map[string]interface{}{
75 "dataFlowName": autorest.Encode("path", dataFlowName),
76 }
77
78 const APIVersion = "2019-06-01-preview"
79 queryParameters := map[string]interface{}{
80 "api-version": APIVersion,
81 }
82
83 preparer := autorest.CreatePreparer(
84 autorest.AsContentType("application/json; charset=utf-8"),
85 autorest.AsPut(),
86 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
87 autorest.WithPathParameters("/dataflows/{dataFlowName}", pathParameters),
88 autorest.WithJSON(dataFlow),
89 autorest.WithQueryParameters(queryParameters))
90 if len(ifMatch) > 0 {
91 preparer = autorest.DecoratePreparer(preparer,
92 autorest.WithHeader("If-Match", autorest.String(ifMatch)))
93 }
94 return preparer.Prepare((&http.Request{}).WithContext(ctx))
95 }
96
97
98
99 func (client DataFlowClient) CreateOrUpdateDataFlowSender(req *http.Request) (future DataFlowCreateOrUpdateDataFlowFuture, err error) {
100 var resp *http.Response
101 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
102 if err != nil {
103 return
104 }
105 var azf azure.Future
106 azf, err = azure.NewFutureFromResponse(resp)
107 future.FutureAPI = &azf
108 future.Result = future.result
109 return
110 }
111
112
113
114 func (client DataFlowClient) CreateOrUpdateDataFlowResponder(resp *http.Response) (result DataFlowResource, err error) {
115 err = autorest.Respond(
116 resp,
117 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
118 autorest.ByUnmarshallingJSON(&result),
119 autorest.ByClosing())
120 result.Response = autorest.Response{Response: resp}
121 return
122 }
123
124
125
126
127 func (client DataFlowClient) DeleteDataFlow(ctx context.Context, dataFlowName string) (result DataFlowDeleteDataFlowFuture, err error) {
128 if tracing.IsEnabled() {
129 ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowClient.DeleteDataFlow")
130 defer func() {
131 sc := -1
132 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
133 sc = result.FutureAPI.Response().StatusCode
134 }
135 tracing.EndSpan(ctx, sc, err)
136 }()
137 }
138 if err := validation.Validate([]validation.Validation{
139 {TargetValue: dataFlowName,
140 Constraints: []validation.Constraint{{Target: "dataFlowName", Name: validation.MaxLength, Rule: 260, Chain: nil},
141 {Target: "dataFlowName", Name: validation.MinLength, Rule: 1, Chain: nil},
142 {Target: "dataFlowName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}}}); err != nil {
143 return result, validation.NewError("artifacts.DataFlowClient", "DeleteDataFlow", err.Error())
144 }
145
146 req, err := client.DeleteDataFlowPreparer(ctx, dataFlowName)
147 if err != nil {
148 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "DeleteDataFlow", nil, "Failure preparing request")
149 return
150 }
151
152 result, err = client.DeleteDataFlowSender(req)
153 if err != nil {
154 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "DeleteDataFlow", nil, "Failure sending request")
155 return
156 }
157
158 return
159 }
160
161
162 func (client DataFlowClient) DeleteDataFlowPreparer(ctx context.Context, dataFlowName string) (*http.Request, error) {
163 urlParameters := map[string]interface{}{
164 "endpoint": client.Endpoint,
165 }
166
167 pathParameters := map[string]interface{}{
168 "dataFlowName": autorest.Encode("path", dataFlowName),
169 }
170
171 const APIVersion = "2019-06-01-preview"
172 queryParameters := map[string]interface{}{
173 "api-version": APIVersion,
174 }
175
176 preparer := autorest.CreatePreparer(
177 autorest.AsDelete(),
178 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
179 autorest.WithPathParameters("/dataflows/{dataFlowName}", pathParameters),
180 autorest.WithQueryParameters(queryParameters))
181 return preparer.Prepare((&http.Request{}).WithContext(ctx))
182 }
183
184
185
186 func (client DataFlowClient) DeleteDataFlowSender(req *http.Request) (future DataFlowDeleteDataFlowFuture, err error) {
187 var resp *http.Response
188 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
189 if err != nil {
190 return
191 }
192 var azf azure.Future
193 azf, err = azure.NewFutureFromResponse(resp)
194 future.FutureAPI = &azf
195 future.Result = future.result
196 return
197 }
198
199
200
201 func (client DataFlowClient) DeleteDataFlowResponder(resp *http.Response) (result autorest.Response, err error) {
202 err = autorest.Respond(
203 resp,
204 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
205 autorest.ByClosing())
206 result.Response = resp
207 return
208 }
209
210
211
212
213
214
215 func (client DataFlowClient) GetDataFlow(ctx context.Context, dataFlowName string, ifNoneMatch string) (result DataFlowResource, err error) {
216 if tracing.IsEnabled() {
217 ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowClient.GetDataFlow")
218 defer func() {
219 sc := -1
220 if result.Response.Response != nil {
221 sc = result.Response.Response.StatusCode
222 }
223 tracing.EndSpan(ctx, sc, err)
224 }()
225 }
226 if err := validation.Validate([]validation.Validation{
227 {TargetValue: dataFlowName,
228 Constraints: []validation.Constraint{{Target: "dataFlowName", Name: validation.MaxLength, Rule: 260, Chain: nil},
229 {Target: "dataFlowName", Name: validation.MinLength, Rule: 1, Chain: nil},
230 {Target: "dataFlowName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}}}); err != nil {
231 return result, validation.NewError("artifacts.DataFlowClient", "GetDataFlow", err.Error())
232 }
233
234 req, err := client.GetDataFlowPreparer(ctx, dataFlowName, ifNoneMatch)
235 if err != nil {
236 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "GetDataFlow", nil, "Failure preparing request")
237 return
238 }
239
240 resp, err := client.GetDataFlowSender(req)
241 if err != nil {
242 result.Response = autorest.Response{Response: resp}
243 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "GetDataFlow", resp, "Failure sending request")
244 return
245 }
246
247 result, err = client.GetDataFlowResponder(resp)
248 if err != nil {
249 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "GetDataFlow", resp, "Failure responding to request")
250 return
251 }
252
253 return
254 }
255
256
257 func (client DataFlowClient) GetDataFlowPreparer(ctx context.Context, dataFlowName string, ifNoneMatch string) (*http.Request, error) {
258 urlParameters := map[string]interface{}{
259 "endpoint": client.Endpoint,
260 }
261
262 pathParameters := map[string]interface{}{
263 "dataFlowName": autorest.Encode("path", dataFlowName),
264 }
265
266 const APIVersion = "2019-06-01-preview"
267 queryParameters := map[string]interface{}{
268 "api-version": APIVersion,
269 }
270
271 preparer := autorest.CreatePreparer(
272 autorest.AsGet(),
273 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
274 autorest.WithPathParameters("/dataflows/{dataFlowName}", pathParameters),
275 autorest.WithQueryParameters(queryParameters))
276 if len(ifNoneMatch) > 0 {
277 preparer = autorest.DecoratePreparer(preparer,
278 autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
279 }
280 return preparer.Prepare((&http.Request{}).WithContext(ctx))
281 }
282
283
284
285 func (client DataFlowClient) GetDataFlowSender(req *http.Request) (*http.Response, error) {
286 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
287 }
288
289
290
291 func (client DataFlowClient) GetDataFlowResponder(resp *http.Response) (result DataFlowResource, err error) {
292 err = autorest.Respond(
293 resp,
294 azure.WithErrorUnlessStatusCode(http.StatusOK),
295 autorest.ByUnmarshallingJSON(&result),
296 autorest.ByClosing())
297 result.Response = autorest.Response{Response: resp}
298 return
299 }
300
301
302 func (client DataFlowClient) GetDataFlowsByWorkspace(ctx context.Context) (result DataFlowListResponsePage, err error) {
303 if tracing.IsEnabled() {
304 ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowClient.GetDataFlowsByWorkspace")
305 defer func() {
306 sc := -1
307 if result.dflr.Response.Response != nil {
308 sc = result.dflr.Response.Response.StatusCode
309 }
310 tracing.EndSpan(ctx, sc, err)
311 }()
312 }
313 result.fn = client.getDataFlowsByWorkspaceNextResults
314 req, err := client.GetDataFlowsByWorkspacePreparer(ctx)
315 if err != nil {
316 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "GetDataFlowsByWorkspace", nil, "Failure preparing request")
317 return
318 }
319
320 resp, err := client.GetDataFlowsByWorkspaceSender(req)
321 if err != nil {
322 result.dflr.Response = autorest.Response{Response: resp}
323 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "GetDataFlowsByWorkspace", resp, "Failure sending request")
324 return
325 }
326
327 result.dflr, err = client.GetDataFlowsByWorkspaceResponder(resp)
328 if err != nil {
329 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "GetDataFlowsByWorkspace", resp, "Failure responding to request")
330 return
331 }
332 if result.dflr.hasNextLink() && result.dflr.IsEmpty() {
333 err = result.NextWithContext(ctx)
334 return
335 }
336
337 return
338 }
339
340
341 func (client DataFlowClient) GetDataFlowsByWorkspacePreparer(ctx context.Context) (*http.Request, error) {
342 urlParameters := map[string]interface{}{
343 "endpoint": client.Endpoint,
344 }
345
346 const APIVersion = "2019-06-01-preview"
347 queryParameters := map[string]interface{}{
348 "api-version": APIVersion,
349 }
350
351 preparer := autorest.CreatePreparer(
352 autorest.AsGet(),
353 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
354 autorest.WithPath("/dataflows"),
355 autorest.WithQueryParameters(queryParameters))
356 return preparer.Prepare((&http.Request{}).WithContext(ctx))
357 }
358
359
360
361 func (client DataFlowClient) GetDataFlowsByWorkspaceSender(req *http.Request) (*http.Response, error) {
362 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
363 }
364
365
366
367 func (client DataFlowClient) GetDataFlowsByWorkspaceResponder(resp *http.Response) (result DataFlowListResponse, err error) {
368 err = autorest.Respond(
369 resp,
370 azure.WithErrorUnlessStatusCode(http.StatusOK),
371 autorest.ByUnmarshallingJSON(&result),
372 autorest.ByClosing())
373 result.Response = autorest.Response{Response: resp}
374 return
375 }
376
377
378 func (client DataFlowClient) getDataFlowsByWorkspaceNextResults(ctx context.Context, lastResults DataFlowListResponse) (result DataFlowListResponse, err error) {
379 req, err := lastResults.dataFlowListResponsePreparer(ctx)
380 if err != nil {
381 return result, autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "getDataFlowsByWorkspaceNextResults", nil, "Failure preparing next results request")
382 }
383 if req == nil {
384 return
385 }
386 resp, err := client.GetDataFlowsByWorkspaceSender(req)
387 if err != nil {
388 result.Response = autorest.Response{Response: resp}
389 return result, autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "getDataFlowsByWorkspaceNextResults", resp, "Failure sending next results request")
390 }
391 result, err = client.GetDataFlowsByWorkspaceResponder(resp)
392 if err != nil {
393 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "getDataFlowsByWorkspaceNextResults", resp, "Failure responding to next results request")
394 }
395 return
396 }
397
398
399 func (client DataFlowClient) GetDataFlowsByWorkspaceComplete(ctx context.Context) (result DataFlowListResponseIterator, err error) {
400 if tracing.IsEnabled() {
401 ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowClient.GetDataFlowsByWorkspace")
402 defer func() {
403 sc := -1
404 if result.Response().Response.Response != nil {
405 sc = result.page.Response().Response.Response.StatusCode
406 }
407 tracing.EndSpan(ctx, sc, err)
408 }()
409 }
410 result.page, err = client.GetDataFlowsByWorkspace(ctx)
411 return
412 }
413
414
415
416
417
418 func (client DataFlowClient) RenameDataFlow(ctx context.Context, dataFlowName string, request RenameRequest) (result DataFlowRenameDataFlowFuture, err error) {
419 if tracing.IsEnabled() {
420 ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowClient.RenameDataFlow")
421 defer func() {
422 sc := -1
423 if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
424 sc = result.FutureAPI.Response().StatusCode
425 }
426 tracing.EndSpan(ctx, sc, err)
427 }()
428 }
429 if err := validation.Validate([]validation.Validation{
430 {TargetValue: dataFlowName,
431 Constraints: []validation.Constraint{{Target: "dataFlowName", Name: validation.MaxLength, Rule: 260, Chain: nil},
432 {Target: "dataFlowName", Name: validation.MinLength, Rule: 1, Chain: nil},
433 {Target: "dataFlowName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}},
434 {TargetValue: request,
435 Constraints: []validation.Constraint{{Target: "request.NewName", Name: validation.Null, Rule: false,
436 Chain: []validation.Constraint{{Target: "request.NewName", Name: validation.MaxLength, Rule: 260, Chain: nil},
437 {Target: "request.NewName", Name: validation.MinLength, Rule: 1, Chain: nil},
438 {Target: "request.NewName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil},
439 }}}}}); err != nil {
440 return result, validation.NewError("artifacts.DataFlowClient", "RenameDataFlow", err.Error())
441 }
442
443 req, err := client.RenameDataFlowPreparer(ctx, dataFlowName, request)
444 if err != nil {
445 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "RenameDataFlow", nil, "Failure preparing request")
446 return
447 }
448
449 result, err = client.RenameDataFlowSender(req)
450 if err != nil {
451 err = autorest.NewErrorWithError(err, "artifacts.DataFlowClient", "RenameDataFlow", nil, "Failure sending request")
452 return
453 }
454
455 return
456 }
457
458
459 func (client DataFlowClient) RenameDataFlowPreparer(ctx context.Context, dataFlowName string, request RenameRequest) (*http.Request, error) {
460 urlParameters := map[string]interface{}{
461 "endpoint": client.Endpoint,
462 }
463
464 pathParameters := map[string]interface{}{
465 "dataFlowName": autorest.Encode("path", dataFlowName),
466 }
467
468 const APIVersion = "2019-06-01-preview"
469 queryParameters := map[string]interface{}{
470 "api-version": APIVersion,
471 }
472
473 preparer := autorest.CreatePreparer(
474 autorest.AsContentType("application/json; charset=utf-8"),
475 autorest.AsPost(),
476 autorest.WithCustomBaseURL("{endpoint}", urlParameters),
477 autorest.WithPathParameters("/dataflows/{dataFlowName}/rename", pathParameters),
478 autorest.WithJSON(request),
479 autorest.WithQueryParameters(queryParameters))
480 return preparer.Prepare((&http.Request{}).WithContext(ctx))
481 }
482
483
484
485 func (client DataFlowClient) RenameDataFlowSender(req *http.Request) (future DataFlowRenameDataFlowFuture, err error) {
486 var resp *http.Response
487 resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
488 if err != nil {
489 return
490 }
491 var azf azure.Future
492 azf, err = azure.NewFutureFromResponse(resp)
493 future.FutureAPI = &azf
494 future.Result = future.result
495 return
496 }
497
498
499
500 func (client DataFlowClient) RenameDataFlowResponder(resp *http.Response) (result autorest.Response, err error) {
501 err = autorest.Respond(
502 resp,
503 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
504 autorest.ByClosing())
505 result.Response = resp
506 return
507 }
508
View as plain text