1package datafactory
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"github.com/Azure/go-autorest/autorest"
23	"github.com/Azure/go-autorest/autorest/azure"
24	"github.com/Azure/go-autorest/autorest/validation"
25	"net/http"
26)
27
28// FactoriesClient is the the Azure Data Factory V2 management API provides a RESTful set of web services that interact
29// with Azure Data Factory V2 services.
30type FactoriesClient struct {
31	BaseClient
32}
33
34// NewFactoriesClient creates an instance of the FactoriesClient client.
35func NewFactoriesClient(subscriptionID string) FactoriesClient {
36	return NewFactoriesClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewFactoriesClientWithBaseURI creates an instance of the FactoriesClient client.
40func NewFactoriesClientWithBaseURI(baseURI string, subscriptionID string) FactoriesClient {
41	return FactoriesClient{NewWithBaseURI(baseURI, subscriptionID)}
42}
43
44// CancelPipelineRun cancel a pipeline run by its run ID.
45// Parameters:
46// resourceGroupName - the resource group name.
47// factoryName - the factory name.
48// runID - the pipeline run identifier.
49func (client FactoriesClient) CancelPipelineRun(ctx context.Context, resourceGroupName string, factoryName string, runID string) (result autorest.Response, err error) {
50	if err := validation.Validate([]validation.Validation{
51		{TargetValue: resourceGroupName,
52			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
53				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
54				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
55		{TargetValue: factoryName,
56			Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil},
57				{Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil},
58				{Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}}}); err != nil {
59		return result, validation.NewError("datafactory.FactoriesClient", "CancelPipelineRun", err.Error())
60	}
61
62	req, err := client.CancelPipelineRunPreparer(ctx, resourceGroupName, factoryName, runID)
63	if err != nil {
64		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "CancelPipelineRun", nil, "Failure preparing request")
65		return
66	}
67
68	resp, err := client.CancelPipelineRunSender(req)
69	if err != nil {
70		result.Response = resp
71		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "CancelPipelineRun", resp, "Failure sending request")
72		return
73	}
74
75	result, err = client.CancelPipelineRunResponder(resp)
76	if err != nil {
77		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "CancelPipelineRun", resp, "Failure responding to request")
78	}
79
80	return
81}
82
83// CancelPipelineRunPreparer prepares the CancelPipelineRun request.
84func (client FactoriesClient) CancelPipelineRunPreparer(ctx context.Context, resourceGroupName string, factoryName string, runID string) (*http.Request, error) {
85	pathParameters := map[string]interface{}{
86		"factoryName":       autorest.Encode("path", factoryName),
87		"resourceGroupName": autorest.Encode("path", resourceGroupName),
88		"runId":             autorest.Encode("path", runID),
89		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
90	}
91
92	const APIVersion = "2017-09-01-preview"
93	queryParameters := map[string]interface{}{
94		"api-version": APIVersion,
95	}
96
97	preparer := autorest.CreatePreparer(
98		autorest.AsPost(),
99		autorest.WithBaseURL(client.BaseURI),
100		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/cancelpipelinerun/{runId}", pathParameters),
101		autorest.WithQueryParameters(queryParameters))
102	return preparer.Prepare((&http.Request{}).WithContext(ctx))
103}
104
105// CancelPipelineRunSender sends the CancelPipelineRun request. The method will close the
106// http.Response Body if it receives an error.
107func (client FactoriesClient) CancelPipelineRunSender(req *http.Request) (*http.Response, error) {
108	return autorest.SendWithSender(client, req,
109		azure.DoRetryWithRegistration(client.Client))
110}
111
112// CancelPipelineRunResponder handles the response to the CancelPipelineRun request. The method always
113// closes the http.Response Body.
114func (client FactoriesClient) CancelPipelineRunResponder(resp *http.Response) (result autorest.Response, err error) {
115	err = autorest.Respond(
116		resp,
117		client.ByInspecting(),
118		azure.WithErrorUnlessStatusCode(http.StatusOK),
119		autorest.ByClosing())
120	result.Response = resp
121	return
122}
123
124// ConfigureFactoryRepo updates a factory's repo information.
125// Parameters:
126// locationID - the location identifier.
127// factoryRepoUpdate - update factory repo request definition.
128func (client FactoriesClient) ConfigureFactoryRepo(ctx context.Context, locationID string, factoryRepoUpdate FactoryRepoUpdate) (result Factory, err error) {
129	req, err := client.ConfigureFactoryRepoPreparer(ctx, locationID, factoryRepoUpdate)
130	if err != nil {
131		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "ConfigureFactoryRepo", nil, "Failure preparing request")
132		return
133	}
134
135	resp, err := client.ConfigureFactoryRepoSender(req)
136	if err != nil {
137		result.Response = autorest.Response{Response: resp}
138		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "ConfigureFactoryRepo", resp, "Failure sending request")
139		return
140	}
141
142	result, err = client.ConfigureFactoryRepoResponder(resp)
143	if err != nil {
144		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "ConfigureFactoryRepo", resp, "Failure responding to request")
145	}
146
147	return
148}
149
150// ConfigureFactoryRepoPreparer prepares the ConfigureFactoryRepo request.
151func (client FactoriesClient) ConfigureFactoryRepoPreparer(ctx context.Context, locationID string, factoryRepoUpdate FactoryRepoUpdate) (*http.Request, error) {
152	pathParameters := map[string]interface{}{
153		"locationId":     autorest.Encode("path", locationID),
154		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
155	}
156
157	const APIVersion = "2017-09-01-preview"
158	queryParameters := map[string]interface{}{
159		"api-version": APIVersion,
160	}
161
162	preparer := autorest.CreatePreparer(
163		autorest.AsContentType("application/json; charset=utf-8"),
164		autorest.AsPost(),
165		autorest.WithBaseURL(client.BaseURI),
166		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DataFactory/locations/{locationId}/configureFactoryRepo", pathParameters),
167		autorest.WithJSON(factoryRepoUpdate),
168		autorest.WithQueryParameters(queryParameters))
169	return preparer.Prepare((&http.Request{}).WithContext(ctx))
170}
171
172// ConfigureFactoryRepoSender sends the ConfigureFactoryRepo request. The method will close the
173// http.Response Body if it receives an error.
174func (client FactoriesClient) ConfigureFactoryRepoSender(req *http.Request) (*http.Response, error) {
175	return autorest.SendWithSender(client, req,
176		azure.DoRetryWithRegistration(client.Client))
177}
178
179// ConfigureFactoryRepoResponder handles the response to the ConfigureFactoryRepo request. The method always
180// closes the http.Response Body.
181func (client FactoriesClient) ConfigureFactoryRepoResponder(resp *http.Response) (result Factory, err error) {
182	err = autorest.Respond(
183		resp,
184		client.ByInspecting(),
185		azure.WithErrorUnlessStatusCode(http.StatusOK),
186		autorest.ByUnmarshallingJSON(&result),
187		autorest.ByClosing())
188	result.Response = autorest.Response{Response: resp}
189	return
190}
191
192// CreateOrUpdate creates or updates a factory.
193// Parameters:
194// resourceGroupName - the resource group name.
195// factoryName - the factory name.
196// factory - factory resource definition.
197func (client FactoriesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, factoryName string, factory Factory) (result Factory, err error) {
198	if err := validation.Validate([]validation.Validation{
199		{TargetValue: resourceGroupName,
200			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
201				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
202				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
203		{TargetValue: factoryName,
204			Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil},
205				{Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil},
206				{Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}},
207		{TargetValue: factory,
208			Constraints: []validation.Constraint{{Target: "factory.Identity", Name: validation.Null, Rule: false,
209				Chain: []validation.Constraint{{Target: "factory.Identity.Type", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
210		return result, validation.NewError("datafactory.FactoriesClient", "CreateOrUpdate", err.Error())
211	}
212
213	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, factoryName, factory)
214	if err != nil {
215		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "CreateOrUpdate", nil, "Failure preparing request")
216		return
217	}
218
219	resp, err := client.CreateOrUpdateSender(req)
220	if err != nil {
221		result.Response = autorest.Response{Response: resp}
222		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "CreateOrUpdate", resp, "Failure sending request")
223		return
224	}
225
226	result, err = client.CreateOrUpdateResponder(resp)
227	if err != nil {
228		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "CreateOrUpdate", resp, "Failure responding to request")
229	}
230
231	return
232}
233
234// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
235func (client FactoriesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, factoryName string, factory Factory) (*http.Request, error) {
236	pathParameters := map[string]interface{}{
237		"factoryName":       autorest.Encode("path", factoryName),
238		"resourceGroupName": autorest.Encode("path", resourceGroupName),
239		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
240	}
241
242	const APIVersion = "2017-09-01-preview"
243	queryParameters := map[string]interface{}{
244		"api-version": APIVersion,
245	}
246
247	preparer := autorest.CreatePreparer(
248		autorest.AsContentType("application/json; charset=utf-8"),
249		autorest.AsPut(),
250		autorest.WithBaseURL(client.BaseURI),
251		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}", pathParameters),
252		autorest.WithJSON(factory),
253		autorest.WithQueryParameters(queryParameters))
254	return preparer.Prepare((&http.Request{}).WithContext(ctx))
255}
256
257// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
258// http.Response Body if it receives an error.
259func (client FactoriesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
260	return autorest.SendWithSender(client, req,
261		azure.DoRetryWithRegistration(client.Client))
262}
263
264// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
265// closes the http.Response Body.
266func (client FactoriesClient) CreateOrUpdateResponder(resp *http.Response) (result Factory, err error) {
267	err = autorest.Respond(
268		resp,
269		client.ByInspecting(),
270		azure.WithErrorUnlessStatusCode(http.StatusOK),
271		autorest.ByUnmarshallingJSON(&result),
272		autorest.ByClosing())
273	result.Response = autorest.Response{Response: resp}
274	return
275}
276
277// Delete deletes a factory.
278// Parameters:
279// resourceGroupName - the resource group name.
280// factoryName - the factory name.
281func (client FactoriesClient) Delete(ctx context.Context, resourceGroupName string, factoryName string) (result autorest.Response, err error) {
282	if err := validation.Validate([]validation.Validation{
283		{TargetValue: resourceGroupName,
284			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
285				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
286				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
287		{TargetValue: factoryName,
288			Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil},
289				{Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil},
290				{Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}}}); err != nil {
291		return result, validation.NewError("datafactory.FactoriesClient", "Delete", err.Error())
292	}
293
294	req, err := client.DeletePreparer(ctx, resourceGroupName, factoryName)
295	if err != nil {
296		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Delete", nil, "Failure preparing request")
297		return
298	}
299
300	resp, err := client.DeleteSender(req)
301	if err != nil {
302		result.Response = resp
303		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Delete", resp, "Failure sending request")
304		return
305	}
306
307	result, err = client.DeleteResponder(resp)
308	if err != nil {
309		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Delete", resp, "Failure responding to request")
310	}
311
312	return
313}
314
315// DeletePreparer prepares the Delete request.
316func (client FactoriesClient) DeletePreparer(ctx context.Context, resourceGroupName string, factoryName string) (*http.Request, error) {
317	pathParameters := map[string]interface{}{
318		"factoryName":       autorest.Encode("path", factoryName),
319		"resourceGroupName": autorest.Encode("path", resourceGroupName),
320		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
321	}
322
323	const APIVersion = "2017-09-01-preview"
324	queryParameters := map[string]interface{}{
325		"api-version": APIVersion,
326	}
327
328	preparer := autorest.CreatePreparer(
329		autorest.AsDelete(),
330		autorest.WithBaseURL(client.BaseURI),
331		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}", pathParameters),
332		autorest.WithQueryParameters(queryParameters))
333	return preparer.Prepare((&http.Request{}).WithContext(ctx))
334}
335
336// DeleteSender sends the Delete request. The method will close the
337// http.Response Body if it receives an error.
338func (client FactoriesClient) DeleteSender(req *http.Request) (*http.Response, error) {
339	return autorest.SendWithSender(client, req,
340		azure.DoRetryWithRegistration(client.Client))
341}
342
343// DeleteResponder handles the response to the Delete request. The method always
344// closes the http.Response Body.
345func (client FactoriesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
346	err = autorest.Respond(
347		resp,
348		client.ByInspecting(),
349		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
350		autorest.ByClosing())
351	result.Response = resp
352	return
353}
354
355// Get gets a factory.
356// Parameters:
357// resourceGroupName - the resource group name.
358// factoryName - the factory name.
359func (client FactoriesClient) Get(ctx context.Context, resourceGroupName string, factoryName string) (result Factory, err error) {
360	if err := validation.Validate([]validation.Validation{
361		{TargetValue: resourceGroupName,
362			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
363				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
364				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
365		{TargetValue: factoryName,
366			Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil},
367				{Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil},
368				{Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}}}); err != nil {
369		return result, validation.NewError("datafactory.FactoriesClient", "Get", err.Error())
370	}
371
372	req, err := client.GetPreparer(ctx, resourceGroupName, factoryName)
373	if err != nil {
374		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Get", nil, "Failure preparing request")
375		return
376	}
377
378	resp, err := client.GetSender(req)
379	if err != nil {
380		result.Response = autorest.Response{Response: resp}
381		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Get", resp, "Failure sending request")
382		return
383	}
384
385	result, err = client.GetResponder(resp)
386	if err != nil {
387		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Get", resp, "Failure responding to request")
388	}
389
390	return
391}
392
393// GetPreparer prepares the Get request.
394func (client FactoriesClient) GetPreparer(ctx context.Context, resourceGroupName string, factoryName string) (*http.Request, error) {
395	pathParameters := map[string]interface{}{
396		"factoryName":       autorest.Encode("path", factoryName),
397		"resourceGroupName": autorest.Encode("path", resourceGroupName),
398		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
399	}
400
401	const APIVersion = "2017-09-01-preview"
402	queryParameters := map[string]interface{}{
403		"api-version": APIVersion,
404	}
405
406	preparer := autorest.CreatePreparer(
407		autorest.AsGet(),
408		autorest.WithBaseURL(client.BaseURI),
409		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}", pathParameters),
410		autorest.WithQueryParameters(queryParameters))
411	return preparer.Prepare((&http.Request{}).WithContext(ctx))
412}
413
414// GetSender sends the Get request. The method will close the
415// http.Response Body if it receives an error.
416func (client FactoriesClient) GetSender(req *http.Request) (*http.Response, error) {
417	return autorest.SendWithSender(client, req,
418		azure.DoRetryWithRegistration(client.Client))
419}
420
421// GetResponder handles the response to the Get request. The method always
422// closes the http.Response Body.
423func (client FactoriesClient) GetResponder(resp *http.Response) (result Factory, err error) {
424	err = autorest.Respond(
425		resp,
426		client.ByInspecting(),
427		azure.WithErrorUnlessStatusCode(http.StatusOK),
428		autorest.ByUnmarshallingJSON(&result),
429		autorest.ByClosing())
430	result.Response = autorest.Response{Response: resp}
431	return
432}
433
434// List lists factories under the specified subscription.
435func (client FactoriesClient) List(ctx context.Context) (result FactoryListResponsePage, err error) {
436	result.fn = client.listNextResults
437	req, err := client.ListPreparer(ctx)
438	if err != nil {
439		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "List", nil, "Failure preparing request")
440		return
441	}
442
443	resp, err := client.ListSender(req)
444	if err != nil {
445		result.flr.Response = autorest.Response{Response: resp}
446		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "List", resp, "Failure sending request")
447		return
448	}
449
450	result.flr, err = client.ListResponder(resp)
451	if err != nil {
452		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "List", resp, "Failure responding to request")
453	}
454
455	return
456}
457
458// ListPreparer prepares the List request.
459func (client FactoriesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
460	pathParameters := map[string]interface{}{
461		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
462	}
463
464	const APIVersion = "2017-09-01-preview"
465	queryParameters := map[string]interface{}{
466		"api-version": APIVersion,
467	}
468
469	preparer := autorest.CreatePreparer(
470		autorest.AsGet(),
471		autorest.WithBaseURL(client.BaseURI),
472		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DataFactory/factories", pathParameters),
473		autorest.WithQueryParameters(queryParameters))
474	return preparer.Prepare((&http.Request{}).WithContext(ctx))
475}
476
477// ListSender sends the List request. The method will close the
478// http.Response Body if it receives an error.
479func (client FactoriesClient) ListSender(req *http.Request) (*http.Response, error) {
480	return autorest.SendWithSender(client, req,
481		azure.DoRetryWithRegistration(client.Client))
482}
483
484// ListResponder handles the response to the List request. The method always
485// closes the http.Response Body.
486func (client FactoriesClient) ListResponder(resp *http.Response) (result FactoryListResponse, err error) {
487	err = autorest.Respond(
488		resp,
489		client.ByInspecting(),
490		azure.WithErrorUnlessStatusCode(http.StatusOK),
491		autorest.ByUnmarshallingJSON(&result),
492		autorest.ByClosing())
493	result.Response = autorest.Response{Response: resp}
494	return
495}
496
497// listNextResults retrieves the next set of results, if any.
498func (client FactoriesClient) listNextResults(lastResults FactoryListResponse) (result FactoryListResponse, err error) {
499	req, err := lastResults.factoryListResponsePreparer()
500	if err != nil {
501		return result, autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "listNextResults", nil, "Failure preparing next results request")
502	}
503	if req == nil {
504		return
505	}
506	resp, err := client.ListSender(req)
507	if err != nil {
508		result.Response = autorest.Response{Response: resp}
509		return result, autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "listNextResults", resp, "Failure sending next results request")
510	}
511	result, err = client.ListResponder(resp)
512	if err != nil {
513		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "listNextResults", resp, "Failure responding to next results request")
514	}
515	return
516}
517
518// ListComplete enumerates all values, automatically crossing page boundaries as required.
519func (client FactoriesClient) ListComplete(ctx context.Context) (result FactoryListResponseIterator, err error) {
520	result.page, err = client.List(ctx)
521	return
522}
523
524// ListByResourceGroup lists factories.
525// Parameters:
526// resourceGroupName - the resource group name.
527func (client FactoriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result FactoryListResponsePage, err error) {
528	if err := validation.Validate([]validation.Validation{
529		{TargetValue: resourceGroupName,
530			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
531				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
532				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
533		return result, validation.NewError("datafactory.FactoriesClient", "ListByResourceGroup", err.Error())
534	}
535
536	result.fn = client.listByResourceGroupNextResults
537	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
538	if err != nil {
539		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "ListByResourceGroup", nil, "Failure preparing request")
540		return
541	}
542
543	resp, err := client.ListByResourceGroupSender(req)
544	if err != nil {
545		result.flr.Response = autorest.Response{Response: resp}
546		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "ListByResourceGroup", resp, "Failure sending request")
547		return
548	}
549
550	result.flr, err = client.ListByResourceGroupResponder(resp)
551	if err != nil {
552		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "ListByResourceGroup", resp, "Failure responding to request")
553	}
554
555	return
556}
557
558// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
559func (client FactoriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
560	pathParameters := map[string]interface{}{
561		"resourceGroupName": autorest.Encode("path", resourceGroupName),
562		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
563	}
564
565	const APIVersion = "2017-09-01-preview"
566	queryParameters := map[string]interface{}{
567		"api-version": APIVersion,
568	}
569
570	preparer := autorest.CreatePreparer(
571		autorest.AsGet(),
572		autorest.WithBaseURL(client.BaseURI),
573		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories", pathParameters),
574		autorest.WithQueryParameters(queryParameters))
575	return preparer.Prepare((&http.Request{}).WithContext(ctx))
576}
577
578// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
579// http.Response Body if it receives an error.
580func (client FactoriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
581	return autorest.SendWithSender(client, req,
582		azure.DoRetryWithRegistration(client.Client))
583}
584
585// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
586// closes the http.Response Body.
587func (client FactoriesClient) ListByResourceGroupResponder(resp *http.Response) (result FactoryListResponse, err error) {
588	err = autorest.Respond(
589		resp,
590		client.ByInspecting(),
591		azure.WithErrorUnlessStatusCode(http.StatusOK),
592		autorest.ByUnmarshallingJSON(&result),
593		autorest.ByClosing())
594	result.Response = autorest.Response{Response: resp}
595	return
596}
597
598// listByResourceGroupNextResults retrieves the next set of results, if any.
599func (client FactoriesClient) listByResourceGroupNextResults(lastResults FactoryListResponse) (result FactoryListResponse, err error) {
600	req, err := lastResults.factoryListResponsePreparer()
601	if err != nil {
602		return result, autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
603	}
604	if req == nil {
605		return
606	}
607	resp, err := client.ListByResourceGroupSender(req)
608	if err != nil {
609		result.Response = autorest.Response{Response: resp}
610		return result, autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
611	}
612	result, err = client.ListByResourceGroupResponder(resp)
613	if err != nil {
614		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
615	}
616	return
617}
618
619// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
620func (client FactoriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result FactoryListResponseIterator, err error) {
621	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
622	return
623}
624
625// Update updates a factory.
626// Parameters:
627// resourceGroupName - the resource group name.
628// factoryName - the factory name.
629// factoryUpdateParameters - the parameters for updating a factory.
630func (client FactoriesClient) Update(ctx context.Context, resourceGroupName string, factoryName string, factoryUpdateParameters FactoryUpdateParameters) (result Factory, err error) {
631	if err := validation.Validate([]validation.Validation{
632		{TargetValue: resourceGroupName,
633			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
634				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
635				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
636		{TargetValue: factoryName,
637			Constraints: []validation.Constraint{{Target: "factoryName", Name: validation.MaxLength, Rule: 63, Chain: nil},
638				{Target: "factoryName", Name: validation.MinLength, Rule: 3, Chain: nil},
639				{Target: "factoryName", Name: validation.Pattern, Rule: `^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$`, Chain: nil}}}}); err != nil {
640		return result, validation.NewError("datafactory.FactoriesClient", "Update", err.Error())
641	}
642
643	req, err := client.UpdatePreparer(ctx, resourceGroupName, factoryName, factoryUpdateParameters)
644	if err != nil {
645		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Update", nil, "Failure preparing request")
646		return
647	}
648
649	resp, err := client.UpdateSender(req)
650	if err != nil {
651		result.Response = autorest.Response{Response: resp}
652		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Update", resp, "Failure sending request")
653		return
654	}
655
656	result, err = client.UpdateResponder(resp)
657	if err != nil {
658		err = autorest.NewErrorWithError(err, "datafactory.FactoriesClient", "Update", resp, "Failure responding to request")
659	}
660
661	return
662}
663
664// UpdatePreparer prepares the Update request.
665func (client FactoriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, factoryName string, factoryUpdateParameters FactoryUpdateParameters) (*http.Request, error) {
666	pathParameters := map[string]interface{}{
667		"factoryName":       autorest.Encode("path", factoryName),
668		"resourceGroupName": autorest.Encode("path", resourceGroupName),
669		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
670	}
671
672	const APIVersion = "2017-09-01-preview"
673	queryParameters := map[string]interface{}{
674		"api-version": APIVersion,
675	}
676
677	preparer := autorest.CreatePreparer(
678		autorest.AsContentType("application/json; charset=utf-8"),
679		autorest.AsPatch(),
680		autorest.WithBaseURL(client.BaseURI),
681		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}", pathParameters),
682		autorest.WithJSON(factoryUpdateParameters),
683		autorest.WithQueryParameters(queryParameters))
684	return preparer.Prepare((&http.Request{}).WithContext(ctx))
685}
686
687// UpdateSender sends the Update request. The method will close the
688// http.Response Body if it receives an error.
689func (client FactoriesClient) UpdateSender(req *http.Request) (*http.Response, error) {
690	return autorest.SendWithSender(client, req,
691		azure.DoRetryWithRegistration(client.Client))
692}
693
694// UpdateResponder handles the response to the Update request. The method always
695// closes the http.Response Body.
696func (client FactoriesClient) UpdateResponder(resp *http.Response) (result Factory, err error) {
697	err = autorest.Respond(
698		resp,
699		client.ByInspecting(),
700		azure.WithErrorUnlessStatusCode(http.StatusOK),
701		autorest.ByUnmarshallingJSON(&result),
702		autorest.ByClosing())
703	result.Response = autorest.Response{Response: resp}
704	return
705}
706