1package artifacts
2
3// Copyright (c) Microsoft Corporation. All rights reserved.
4// Licensed under the MIT License. See License.txt in the project root for license information.
5//
6// Code generated by Microsoft (R) AutoRest Code Generator.
7// Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
9import (
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// DataFlowDebugSessionClient is the client for the DataFlowDebugSession methods of the Artifacts service.
19type DataFlowDebugSessionClient struct {
20	BaseClient
21}
22
23// NewDataFlowDebugSessionClient creates an instance of the DataFlowDebugSessionClient client.
24func NewDataFlowDebugSessionClient(endpoint string) DataFlowDebugSessionClient {
25	return DataFlowDebugSessionClient{New(endpoint)}
26}
27
28// AddDataFlow add a data flow into debug session.
29// Parameters:
30// request - data flow debug session definition with debug content.
31func (client DataFlowDebugSessionClient) AddDataFlow(ctx context.Context, request DataFlowDebugPackage) (result AddDataFlowToDebugSessionResponse, err error) {
32	if tracing.IsEnabled() {
33		ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowDebugSessionClient.AddDataFlow")
34		defer func() {
35			sc := -1
36			if result.Response.Response != nil {
37				sc = result.Response.Response.StatusCode
38			}
39			tracing.EndSpan(ctx, sc, err)
40		}()
41	}
42	if err := validation.Validate([]validation.Validation{
43		{TargetValue: request,
44			Constraints: []validation.Constraint{{Target: "request.Staging", Name: validation.Null, Rule: false,
45				Chain: []validation.Constraint{{Target: "request.Staging.LinkedService", Name: validation.Null, Rule: false,
46					Chain: []validation.Constraint{{Target: "request.Staging.LinkedService.Type", Name: validation.Null, Rule: true, Chain: nil},
47						{Target: "request.Staging.LinkedService.ReferenceName", Name: validation.Null, Rule: true, Chain: nil},
48					}},
49				}}}}}); err != nil {
50		return result, validation.NewError("artifacts.DataFlowDebugSessionClient", "AddDataFlow", err.Error())
51	}
52
53	req, err := client.AddDataFlowPreparer(ctx, request)
54	if err != nil {
55		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "AddDataFlow", nil, "Failure preparing request")
56		return
57	}
58
59	resp, err := client.AddDataFlowSender(req)
60	if err != nil {
61		result.Response = autorest.Response{Response: resp}
62		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "AddDataFlow", resp, "Failure sending request")
63		return
64	}
65
66	result, err = client.AddDataFlowResponder(resp)
67	if err != nil {
68		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "AddDataFlow", resp, "Failure responding to request")
69		return
70	}
71
72	return
73}
74
75// AddDataFlowPreparer prepares the AddDataFlow request.
76func (client DataFlowDebugSessionClient) AddDataFlowPreparer(ctx context.Context, request DataFlowDebugPackage) (*http.Request, error) {
77	urlParameters := map[string]interface{}{
78		"endpoint": client.Endpoint,
79	}
80
81	const APIVersion = "2019-06-01-preview"
82	queryParameters := map[string]interface{}{
83		"api-version": APIVersion,
84	}
85
86	preparer := autorest.CreatePreparer(
87		autorest.AsContentType("application/json; charset=utf-8"),
88		autorest.AsPost(),
89		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
90		autorest.WithPath("/addDataFlowToDebugSession"),
91		autorest.WithJSON(request),
92		autorest.WithQueryParameters(queryParameters))
93	return preparer.Prepare((&http.Request{}).WithContext(ctx))
94}
95
96// AddDataFlowSender sends the AddDataFlow request. The method will close the
97// http.Response Body if it receives an error.
98func (client DataFlowDebugSessionClient) AddDataFlowSender(req *http.Request) (*http.Response, error) {
99	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
100}
101
102// AddDataFlowResponder handles the response to the AddDataFlow request. The method always
103// closes the http.Response Body.
104func (client DataFlowDebugSessionClient) AddDataFlowResponder(resp *http.Response) (result AddDataFlowToDebugSessionResponse, err error) {
105	err = autorest.Respond(
106		resp,
107		azure.WithErrorUnlessStatusCode(http.StatusOK),
108		autorest.ByUnmarshallingJSON(&result),
109		autorest.ByClosing())
110	result.Response = autorest.Response{Response: resp}
111	return
112}
113
114// CreateDataFlowDebugSession creates a data flow debug session.
115// Parameters:
116// request - data flow debug session definition
117func (client DataFlowDebugSessionClient) CreateDataFlowDebugSession(ctx context.Context, request CreateDataFlowDebugSessionRequest) (result DataFlowDebugSessionCreateDataFlowDebugSessionFuture, err error) {
118	if tracing.IsEnabled() {
119		ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowDebugSessionClient.CreateDataFlowDebugSession")
120		defer func() {
121			sc := -1
122			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
123				sc = result.FutureAPI.Response().StatusCode
124			}
125			tracing.EndSpan(ctx, sc, err)
126		}()
127	}
128	req, err := client.CreateDataFlowDebugSessionPreparer(ctx, request)
129	if err != nil {
130		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "CreateDataFlowDebugSession", nil, "Failure preparing request")
131		return
132	}
133
134	result, err = client.CreateDataFlowDebugSessionSender(req)
135	if err != nil {
136		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "CreateDataFlowDebugSession", nil, "Failure sending request")
137		return
138	}
139
140	return
141}
142
143// CreateDataFlowDebugSessionPreparer prepares the CreateDataFlowDebugSession request.
144func (client DataFlowDebugSessionClient) CreateDataFlowDebugSessionPreparer(ctx context.Context, request CreateDataFlowDebugSessionRequest) (*http.Request, error) {
145	urlParameters := map[string]interface{}{
146		"endpoint": client.Endpoint,
147	}
148
149	const APIVersion = "2019-06-01-preview"
150	queryParameters := map[string]interface{}{
151		"api-version": APIVersion,
152	}
153
154	preparer := autorest.CreatePreparer(
155		autorest.AsContentType("application/json; charset=utf-8"),
156		autorest.AsPost(),
157		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
158		autorest.WithPath("/createDataFlowDebugSession"),
159		autorest.WithJSON(request),
160		autorest.WithQueryParameters(queryParameters))
161	return preparer.Prepare((&http.Request{}).WithContext(ctx))
162}
163
164// CreateDataFlowDebugSessionSender sends the CreateDataFlowDebugSession request. The method will close the
165// http.Response Body if it receives an error.
166func (client DataFlowDebugSessionClient) CreateDataFlowDebugSessionSender(req *http.Request) (future DataFlowDebugSessionCreateDataFlowDebugSessionFuture, err error) {
167	var resp *http.Response
168	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
169	if err != nil {
170		return
171	}
172	var azf azure.Future
173	azf, err = azure.NewFutureFromResponse(resp)
174	future.FutureAPI = &azf
175	future.Result = future.result
176	return
177}
178
179// CreateDataFlowDebugSessionResponder handles the response to the CreateDataFlowDebugSession request. The method always
180// closes the http.Response Body.
181func (client DataFlowDebugSessionClient) CreateDataFlowDebugSessionResponder(resp *http.Response) (result CreateDataFlowDebugSessionResponse, err error) {
182	err = autorest.Respond(
183		resp,
184		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
185		autorest.ByUnmarshallingJSON(&result),
186		autorest.ByClosing())
187	result.Response = autorest.Response{Response: resp}
188	return
189}
190
191// DeleteDataFlowDebugSession deletes a data flow debug session.
192// Parameters:
193// request - data flow debug session definition for deletion
194func (client DataFlowDebugSessionClient) DeleteDataFlowDebugSession(ctx context.Context, request DeleteDataFlowDebugSessionRequest) (result autorest.Response, err error) {
195	if tracing.IsEnabled() {
196		ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowDebugSessionClient.DeleteDataFlowDebugSession")
197		defer func() {
198			sc := -1
199			if result.Response != nil {
200				sc = result.Response.StatusCode
201			}
202			tracing.EndSpan(ctx, sc, err)
203		}()
204	}
205	req, err := client.DeleteDataFlowDebugSessionPreparer(ctx, request)
206	if err != nil {
207		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "DeleteDataFlowDebugSession", nil, "Failure preparing request")
208		return
209	}
210
211	resp, err := client.DeleteDataFlowDebugSessionSender(req)
212	if err != nil {
213		result.Response = resp
214		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "DeleteDataFlowDebugSession", resp, "Failure sending request")
215		return
216	}
217
218	result, err = client.DeleteDataFlowDebugSessionResponder(resp)
219	if err != nil {
220		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "DeleteDataFlowDebugSession", resp, "Failure responding to request")
221		return
222	}
223
224	return
225}
226
227// DeleteDataFlowDebugSessionPreparer prepares the DeleteDataFlowDebugSession request.
228func (client DataFlowDebugSessionClient) DeleteDataFlowDebugSessionPreparer(ctx context.Context, request DeleteDataFlowDebugSessionRequest) (*http.Request, error) {
229	urlParameters := map[string]interface{}{
230		"endpoint": client.Endpoint,
231	}
232
233	const APIVersion = "2019-06-01-preview"
234	queryParameters := map[string]interface{}{
235		"api-version": APIVersion,
236	}
237
238	preparer := autorest.CreatePreparer(
239		autorest.AsContentType("application/json; charset=utf-8"),
240		autorest.AsPost(),
241		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
242		autorest.WithPath("/deleteDataFlowDebugSession"),
243		autorest.WithJSON(request),
244		autorest.WithQueryParameters(queryParameters))
245	return preparer.Prepare((&http.Request{}).WithContext(ctx))
246}
247
248// DeleteDataFlowDebugSessionSender sends the DeleteDataFlowDebugSession request. The method will close the
249// http.Response Body if it receives an error.
250func (client DataFlowDebugSessionClient) DeleteDataFlowDebugSessionSender(req *http.Request) (*http.Response, error) {
251	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
252}
253
254// DeleteDataFlowDebugSessionResponder handles the response to the DeleteDataFlowDebugSession request. The method always
255// closes the http.Response Body.
256func (client DataFlowDebugSessionClient) DeleteDataFlowDebugSessionResponder(resp *http.Response) (result autorest.Response, err error) {
257	err = autorest.Respond(
258		resp,
259		azure.WithErrorUnlessStatusCode(http.StatusOK),
260		autorest.ByClosing())
261	result.Response = resp
262	return
263}
264
265// ExecuteCommand execute a data flow debug command.
266// Parameters:
267// request - data flow debug command definition.
268func (client DataFlowDebugSessionClient) ExecuteCommand(ctx context.Context, request DataFlowDebugCommandRequest) (result DataFlowDebugSessionExecuteCommandFuture, err error) {
269	if tracing.IsEnabled() {
270		ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowDebugSessionClient.ExecuteCommand")
271		defer func() {
272			sc := -1
273			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
274				sc = result.FutureAPI.Response().StatusCode
275			}
276			tracing.EndSpan(ctx, sc, err)
277		}()
278	}
279	if err := validation.Validate([]validation.Validation{
280		{TargetValue: request,
281			Constraints: []validation.Constraint{{Target: "request.SessionID", Name: validation.Null, Rule: true, Chain: nil},
282				{Target: "request.CommandPayload", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
283		return result, validation.NewError("artifacts.DataFlowDebugSessionClient", "ExecuteCommand", err.Error())
284	}
285
286	req, err := client.ExecuteCommandPreparer(ctx, request)
287	if err != nil {
288		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "ExecuteCommand", nil, "Failure preparing request")
289		return
290	}
291
292	result, err = client.ExecuteCommandSender(req)
293	if err != nil {
294		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "ExecuteCommand", nil, "Failure sending request")
295		return
296	}
297
298	return
299}
300
301// ExecuteCommandPreparer prepares the ExecuteCommand request.
302func (client DataFlowDebugSessionClient) ExecuteCommandPreparer(ctx context.Context, request DataFlowDebugCommandRequest) (*http.Request, error) {
303	urlParameters := map[string]interface{}{
304		"endpoint": client.Endpoint,
305	}
306
307	const APIVersion = "2019-06-01-preview"
308	queryParameters := map[string]interface{}{
309		"api-version": APIVersion,
310	}
311
312	preparer := autorest.CreatePreparer(
313		autorest.AsContentType("application/json; charset=utf-8"),
314		autorest.AsPost(),
315		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
316		autorest.WithPath("/executeDataFlowDebugCommand"),
317		autorest.WithJSON(request),
318		autorest.WithQueryParameters(queryParameters))
319	return preparer.Prepare((&http.Request{}).WithContext(ctx))
320}
321
322// ExecuteCommandSender sends the ExecuteCommand request. The method will close the
323// http.Response Body if it receives an error.
324func (client DataFlowDebugSessionClient) ExecuteCommandSender(req *http.Request) (future DataFlowDebugSessionExecuteCommandFuture, err error) {
325	var resp *http.Response
326	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
327	if err != nil {
328		return
329	}
330	var azf azure.Future
331	azf, err = azure.NewFutureFromResponse(resp)
332	future.FutureAPI = &azf
333	future.Result = future.result
334	return
335}
336
337// ExecuteCommandResponder handles the response to the ExecuteCommand request. The method always
338// closes the http.Response Body.
339func (client DataFlowDebugSessionClient) ExecuteCommandResponder(resp *http.Response) (result DataFlowDebugCommandResponse, err error) {
340	err = autorest.Respond(
341		resp,
342		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
343		autorest.ByUnmarshallingJSON(&result),
344		autorest.ByClosing())
345	result.Response = autorest.Response{Response: resp}
346	return
347}
348
349// QueryDataFlowDebugSessionsByWorkspace query all active data flow debug sessions.
350func (client DataFlowDebugSessionClient) QueryDataFlowDebugSessionsByWorkspace(ctx context.Context) (result QueryDataFlowDebugSessionsResponsePage, err error) {
351	if tracing.IsEnabled() {
352		ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowDebugSessionClient.QueryDataFlowDebugSessionsByWorkspace")
353		defer func() {
354			sc := -1
355			if result.qdfdsr.Response.Response != nil {
356				sc = result.qdfdsr.Response.Response.StatusCode
357			}
358			tracing.EndSpan(ctx, sc, err)
359		}()
360	}
361	result.fn = client.queryDataFlowDebugSessionsByWorkspaceNextResults
362	req, err := client.QueryDataFlowDebugSessionsByWorkspacePreparer(ctx)
363	if err != nil {
364		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "QueryDataFlowDebugSessionsByWorkspace", nil, "Failure preparing request")
365		return
366	}
367
368	resp, err := client.QueryDataFlowDebugSessionsByWorkspaceSender(req)
369	if err != nil {
370		result.qdfdsr.Response = autorest.Response{Response: resp}
371		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "QueryDataFlowDebugSessionsByWorkspace", resp, "Failure sending request")
372		return
373	}
374
375	result.qdfdsr, err = client.QueryDataFlowDebugSessionsByWorkspaceResponder(resp)
376	if err != nil {
377		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "QueryDataFlowDebugSessionsByWorkspace", resp, "Failure responding to request")
378		return
379	}
380	if result.qdfdsr.hasNextLink() && result.qdfdsr.IsEmpty() {
381		err = result.NextWithContext(ctx)
382		return
383	}
384
385	return
386}
387
388// QueryDataFlowDebugSessionsByWorkspacePreparer prepares the QueryDataFlowDebugSessionsByWorkspace request.
389func (client DataFlowDebugSessionClient) QueryDataFlowDebugSessionsByWorkspacePreparer(ctx context.Context) (*http.Request, error) {
390	urlParameters := map[string]interface{}{
391		"endpoint": client.Endpoint,
392	}
393
394	const APIVersion = "2019-06-01-preview"
395	queryParameters := map[string]interface{}{
396		"api-version": APIVersion,
397	}
398
399	preparer := autorest.CreatePreparer(
400		autorest.AsPost(),
401		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
402		autorest.WithPath("/queryDataFlowDebugSessions"),
403		autorest.WithQueryParameters(queryParameters))
404	return preparer.Prepare((&http.Request{}).WithContext(ctx))
405}
406
407// QueryDataFlowDebugSessionsByWorkspaceSender sends the QueryDataFlowDebugSessionsByWorkspace request. The method will close the
408// http.Response Body if it receives an error.
409func (client DataFlowDebugSessionClient) QueryDataFlowDebugSessionsByWorkspaceSender(req *http.Request) (*http.Response, error) {
410	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
411}
412
413// QueryDataFlowDebugSessionsByWorkspaceResponder handles the response to the QueryDataFlowDebugSessionsByWorkspace request. The method always
414// closes the http.Response Body.
415func (client DataFlowDebugSessionClient) QueryDataFlowDebugSessionsByWorkspaceResponder(resp *http.Response) (result QueryDataFlowDebugSessionsResponse, err error) {
416	err = autorest.Respond(
417		resp,
418		azure.WithErrorUnlessStatusCode(http.StatusOK),
419		autorest.ByUnmarshallingJSON(&result),
420		autorest.ByClosing())
421	result.Response = autorest.Response{Response: resp}
422	return
423}
424
425// queryDataFlowDebugSessionsByWorkspaceNextResults retrieves the next set of results, if any.
426func (client DataFlowDebugSessionClient) queryDataFlowDebugSessionsByWorkspaceNextResults(ctx context.Context, lastResults QueryDataFlowDebugSessionsResponse) (result QueryDataFlowDebugSessionsResponse, err error) {
427	req, err := lastResults.queryDataFlowDebugSessionsResponsePreparer(ctx)
428	if err != nil {
429		return result, autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "queryDataFlowDebugSessionsByWorkspaceNextResults", nil, "Failure preparing next results request")
430	}
431	if req == nil {
432		return
433	}
434	resp, err := client.QueryDataFlowDebugSessionsByWorkspaceSender(req)
435	if err != nil {
436		result.Response = autorest.Response{Response: resp}
437		return result, autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "queryDataFlowDebugSessionsByWorkspaceNextResults", resp, "Failure sending next results request")
438	}
439	result, err = client.QueryDataFlowDebugSessionsByWorkspaceResponder(resp)
440	if err != nil {
441		err = autorest.NewErrorWithError(err, "artifacts.DataFlowDebugSessionClient", "queryDataFlowDebugSessionsByWorkspaceNextResults", resp, "Failure responding to next results request")
442	}
443	return
444}
445
446// QueryDataFlowDebugSessionsByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required.
447func (client DataFlowDebugSessionClient) QueryDataFlowDebugSessionsByWorkspaceComplete(ctx context.Context) (result QueryDataFlowDebugSessionsResponseIterator, err error) {
448	if tracing.IsEnabled() {
449		ctx = tracing.StartSpan(ctx, fqdn+"/DataFlowDebugSessionClient.QueryDataFlowDebugSessionsByWorkspace")
450		defer func() {
451			sc := -1
452			if result.Response().Response.Response != nil {
453				sc = result.page.Response().Response.Response.StatusCode
454			}
455			tracing.EndSpan(ctx, sc, err)
456		}()
457	}
458	result.page, err = client.QueryDataFlowDebugSessionsByWorkspace(ctx)
459	return
460}
461