1package automation
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	"github.com/Azure/go-autorest/tracing"
26	"net/http"
27)
28
29// DscConfigurationClient is the automation Client
30type DscConfigurationClient struct {
31	BaseClient
32}
33
34// NewDscConfigurationClient creates an instance of the DscConfigurationClient client.
35func NewDscConfigurationClient(subscriptionID string) DscConfigurationClient {
36	return NewDscConfigurationClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewDscConfigurationClientWithBaseURI creates an instance of the DscConfigurationClient client using a custom
40// endpoint.  Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure
41// stack).
42func NewDscConfigurationClientWithBaseURI(baseURI string, subscriptionID string) DscConfigurationClient {
43	return DscConfigurationClient{NewWithBaseURI(baseURI, subscriptionID)}
44}
45
46// CreateOrUpdate create the configuration identified by configuration name.
47// Parameters:
48// resourceGroupName - name of an Azure Resource group.
49// automationAccountName - the name of the automation account.
50// configurationName - the create or update parameters for configuration.
51// parameters - the create or update parameters for configuration.
52func (client DscConfigurationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (result DscConfiguration, err error) {
53	if tracing.IsEnabled() {
54		ctx = tracing.StartSpan(ctx, fqdn+"/DscConfigurationClient.CreateOrUpdate")
55		defer func() {
56			sc := -1
57			if result.Response.Response != nil {
58				sc = result.Response.Response.StatusCode
59			}
60			tracing.EndSpan(ctx, sc, err)
61		}()
62	}
63	if err := validation.Validate([]validation.Validation{
64		{TargetValue: resourceGroupName,
65			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
66				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
67				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}},
68		{TargetValue: parameters,
69			Constraints: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties", Name: validation.Null, Rule: true,
70				Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source", Name: validation.Null, Rule: true,
71					Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash", Name: validation.Null, Rule: false,
72						Chain: []validation.Constraint{{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Algorithm", Name: validation.Null, Rule: true, Chain: nil},
73							{Target: "parameters.DscConfigurationCreateOrUpdateProperties.Source.Hash.Value", Name: validation.Null, Rule: true, Chain: nil},
74						}},
75					}},
76				}}}}}); err != nil {
77		return result, validation.NewError("automation.DscConfigurationClient", "CreateOrUpdate", err.Error())
78	}
79
80	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, automationAccountName, configurationName, parameters)
81	if err != nil {
82		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", nil, "Failure preparing request")
83		return
84	}
85
86	resp, err := client.CreateOrUpdateSender(req)
87	if err != nil {
88		result.Response = autorest.Response{Response: resp}
89		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure sending request")
90		return
91	}
92
93	result, err = client.CreateOrUpdateResponder(resp)
94	if err != nil {
95		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "CreateOrUpdate", resp, "Failure responding to request")
96		return
97	}
98
99	return
100}
101
102// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
103func (client DscConfigurationClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters DscConfigurationCreateOrUpdateParameters) (*http.Request, error) {
104	pathParameters := map[string]interface{}{
105		"automationAccountName": autorest.Encode("path", automationAccountName),
106		"configurationName":     autorest.Encode("path", configurationName),
107		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
108		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
109	}
110
111	const APIVersion = "2015-10-31"
112	queryParameters := map[string]interface{}{
113		"api-version": APIVersion,
114	}
115
116	preparer := autorest.CreatePreparer(
117		autorest.AsContentType("application/json; charset=utf-8"),
118		autorest.AsPut(),
119		autorest.WithBaseURL(client.BaseURI),
120		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters),
121		autorest.WithJSON(parameters),
122		autorest.WithQueryParameters(queryParameters))
123	return preparer.Prepare((&http.Request{}).WithContext(ctx))
124}
125
126// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
127// http.Response Body if it receives an error.
128func (client DscConfigurationClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
129	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
130}
131
132// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
133// closes the http.Response Body.
134func (client DscConfigurationClient) CreateOrUpdateResponder(resp *http.Response) (result DscConfiguration, err error) {
135	err = autorest.Respond(
136		resp,
137		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
138		autorest.ByUnmarshallingJSON(&result),
139		autorest.ByClosing())
140	result.Response = autorest.Response{Response: resp}
141	return
142}
143
144// Delete delete the dsc configuration identified by configuration name.
145// Parameters:
146// resourceGroupName - name of an Azure Resource group.
147// automationAccountName - the name of the automation account.
148// configurationName - the configuration name.
149func (client DscConfigurationClient) Delete(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result autorest.Response, err error) {
150	if tracing.IsEnabled() {
151		ctx = tracing.StartSpan(ctx, fqdn+"/DscConfigurationClient.Delete")
152		defer func() {
153			sc := -1
154			if result.Response != nil {
155				sc = result.Response.StatusCode
156			}
157			tracing.EndSpan(ctx, sc, err)
158		}()
159	}
160	if err := validation.Validate([]validation.Validation{
161		{TargetValue: resourceGroupName,
162			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
163				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
164				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
165		return result, validation.NewError("automation.DscConfigurationClient", "Delete", err.Error())
166	}
167
168	req, err := client.DeletePreparer(ctx, resourceGroupName, automationAccountName, configurationName)
169	if err != nil {
170		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", nil, "Failure preparing request")
171		return
172	}
173
174	resp, err := client.DeleteSender(req)
175	if err != nil {
176		result.Response = resp
177		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure sending request")
178		return
179	}
180
181	result, err = client.DeleteResponder(resp)
182	if err != nil {
183		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Delete", resp, "Failure responding to request")
184		return
185	}
186
187	return
188}
189
190// DeletePreparer prepares the Delete request.
191func (client DscConfigurationClient) DeletePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) {
192	pathParameters := map[string]interface{}{
193		"automationAccountName": autorest.Encode("path", automationAccountName),
194		"configurationName":     autorest.Encode("path", configurationName),
195		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
196		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
197	}
198
199	const APIVersion = "2015-10-31"
200	queryParameters := map[string]interface{}{
201		"api-version": APIVersion,
202	}
203
204	preparer := autorest.CreatePreparer(
205		autorest.AsDelete(),
206		autorest.WithBaseURL(client.BaseURI),
207		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters),
208		autorest.WithQueryParameters(queryParameters))
209	return preparer.Prepare((&http.Request{}).WithContext(ctx))
210}
211
212// DeleteSender sends the Delete request. The method will close the
213// http.Response Body if it receives an error.
214func (client DscConfigurationClient) DeleteSender(req *http.Request) (*http.Response, error) {
215	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
216}
217
218// DeleteResponder handles the response to the Delete request. The method always
219// closes the http.Response Body.
220func (client DscConfigurationClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
221	err = autorest.Respond(
222		resp,
223		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
224		autorest.ByClosing())
225	result.Response = resp
226	return
227}
228
229// Get retrieve the configuration identified by configuration name.
230// Parameters:
231// resourceGroupName - name of an Azure Resource group.
232// automationAccountName - the name of the automation account.
233// configurationName - the configuration name.
234func (client DscConfigurationClient) Get(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result DscConfiguration, err error) {
235	if tracing.IsEnabled() {
236		ctx = tracing.StartSpan(ctx, fqdn+"/DscConfigurationClient.Get")
237		defer func() {
238			sc := -1
239			if result.Response.Response != nil {
240				sc = result.Response.Response.StatusCode
241			}
242			tracing.EndSpan(ctx, sc, err)
243		}()
244	}
245	if err := validation.Validate([]validation.Validation{
246		{TargetValue: resourceGroupName,
247			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
248				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
249				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
250		return result, validation.NewError("automation.DscConfigurationClient", "Get", err.Error())
251	}
252
253	req, err := client.GetPreparer(ctx, resourceGroupName, automationAccountName, configurationName)
254	if err != nil {
255		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", nil, "Failure preparing request")
256		return
257	}
258
259	resp, err := client.GetSender(req)
260	if err != nil {
261		result.Response = autorest.Response{Response: resp}
262		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure sending request")
263		return
264	}
265
266	result, err = client.GetResponder(resp)
267	if err != nil {
268		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Get", resp, "Failure responding to request")
269		return
270	}
271
272	return
273}
274
275// GetPreparer prepares the Get request.
276func (client DscConfigurationClient) GetPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) {
277	pathParameters := map[string]interface{}{
278		"automationAccountName": autorest.Encode("path", automationAccountName),
279		"configurationName":     autorest.Encode("path", configurationName),
280		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
281		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
282	}
283
284	const APIVersion = "2015-10-31"
285	queryParameters := map[string]interface{}{
286		"api-version": APIVersion,
287	}
288
289	preparer := autorest.CreatePreparer(
290		autorest.AsGet(),
291		autorest.WithBaseURL(client.BaseURI),
292		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters),
293		autorest.WithQueryParameters(queryParameters))
294	return preparer.Prepare((&http.Request{}).WithContext(ctx))
295}
296
297// GetSender sends the Get request. The method will close the
298// http.Response Body if it receives an error.
299func (client DscConfigurationClient) GetSender(req *http.Request) (*http.Response, error) {
300	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
301}
302
303// GetResponder handles the response to the Get request. The method always
304// closes the http.Response Body.
305func (client DscConfigurationClient) GetResponder(resp *http.Response) (result DscConfiguration, err error) {
306	err = autorest.Respond(
307		resp,
308		azure.WithErrorUnlessStatusCode(http.StatusOK),
309		autorest.ByUnmarshallingJSON(&result),
310		autorest.ByClosing())
311	result.Response = autorest.Response{Response: resp}
312	return
313}
314
315// GetContent retrieve the configuration script identified by configuration name.
316// Parameters:
317// resourceGroupName - name of an Azure Resource group.
318// automationAccountName - the name of the automation account.
319// configurationName - the configuration name.
320func (client DscConfigurationClient) GetContent(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (result ReadCloser, err error) {
321	if tracing.IsEnabled() {
322		ctx = tracing.StartSpan(ctx, fqdn+"/DscConfigurationClient.GetContent")
323		defer func() {
324			sc := -1
325			if result.Response.Response != nil {
326				sc = result.Response.Response.StatusCode
327			}
328			tracing.EndSpan(ctx, sc, err)
329		}()
330	}
331	if err := validation.Validate([]validation.Validation{
332		{TargetValue: resourceGroupName,
333			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
334				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
335				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
336		return result, validation.NewError("automation.DscConfigurationClient", "GetContent", err.Error())
337	}
338
339	req, err := client.GetContentPreparer(ctx, resourceGroupName, automationAccountName, configurationName)
340	if err != nil {
341		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", nil, "Failure preparing request")
342		return
343	}
344
345	resp, err := client.GetContentSender(req)
346	if err != nil {
347		result.Response = autorest.Response{Response: resp}
348		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure sending request")
349		return
350	}
351
352	result, err = client.GetContentResponder(resp)
353	if err != nil {
354		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "GetContent", resp, "Failure responding to request")
355		return
356	}
357
358	return
359}
360
361// GetContentPreparer prepares the GetContent request.
362func (client DscConfigurationClient) GetContentPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string) (*http.Request, error) {
363	pathParameters := map[string]interface{}{
364		"automationAccountName": autorest.Encode("path", automationAccountName),
365		"configurationName":     autorest.Encode("path", configurationName),
366		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
367		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
368	}
369
370	const APIVersion = "2015-10-31"
371	queryParameters := map[string]interface{}{
372		"api-version": APIVersion,
373	}
374
375	preparer := autorest.CreatePreparer(
376		autorest.AsGet(),
377		autorest.WithBaseURL(client.BaseURI),
378		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}/content", pathParameters),
379		autorest.WithQueryParameters(queryParameters))
380	return preparer.Prepare((&http.Request{}).WithContext(ctx))
381}
382
383// GetContentSender sends the GetContent request. The method will close the
384// http.Response Body if it receives an error.
385func (client DscConfigurationClient) GetContentSender(req *http.Request) (*http.Response, error) {
386	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
387}
388
389// GetContentResponder handles the response to the GetContent request. The method always
390// closes the http.Response Body.
391func (client DscConfigurationClient) GetContentResponder(resp *http.Response) (result ReadCloser, err error) {
392	result.Value = &resp.Body
393	err = autorest.Respond(
394		resp,
395		azure.WithErrorUnlessStatusCode(http.StatusOK))
396	result.Response = autorest.Response{Response: resp}
397	return
398}
399
400// ListByAutomationAccount retrieve a list of configurations.
401// Parameters:
402// resourceGroupName - name of an Azure Resource group.
403// automationAccountName - the name of the automation account.
404// filter - the filter to apply on the operation.
405// skip - the number of rows to skip.
406// top - the number of rows to take.
407// inlinecount - return total rows.
408func (client DscConfigurationClient) ListByAutomationAccount(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscConfigurationListResultPage, err error) {
409	if tracing.IsEnabled() {
410		ctx = tracing.StartSpan(ctx, fqdn+"/DscConfigurationClient.ListByAutomationAccount")
411		defer func() {
412			sc := -1
413			if result.dclr.Response.Response != nil {
414				sc = result.dclr.Response.Response.StatusCode
415			}
416			tracing.EndSpan(ctx, sc, err)
417		}()
418	}
419	if err := validation.Validate([]validation.Validation{
420		{TargetValue: resourceGroupName,
421			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
422				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
423				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
424		return result, validation.NewError("automation.DscConfigurationClient", "ListByAutomationAccount", err.Error())
425	}
426
427	result.fn = client.listByAutomationAccountNextResults
428	req, err := client.ListByAutomationAccountPreparer(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount)
429	if err != nil {
430		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", nil, "Failure preparing request")
431		return
432	}
433
434	resp, err := client.ListByAutomationAccountSender(req)
435	if err != nil {
436		result.dclr.Response = autorest.Response{Response: resp}
437		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure sending request")
438		return
439	}
440
441	result.dclr, err = client.ListByAutomationAccountResponder(resp)
442	if err != nil {
443		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "ListByAutomationAccount", resp, "Failure responding to request")
444		return
445	}
446	if result.dclr.hasNextLink() && result.dclr.IsEmpty() {
447		err = result.NextWithContext(ctx)
448		return
449	}
450
451	return
452}
453
454// ListByAutomationAccountPreparer prepares the ListByAutomationAccount request.
455func (client DscConfigurationClient) ListByAutomationAccountPreparer(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (*http.Request, error) {
456	pathParameters := map[string]interface{}{
457		"automationAccountName": autorest.Encode("path", automationAccountName),
458		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
459		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
460	}
461
462	const APIVersion = "2015-10-31"
463	queryParameters := map[string]interface{}{
464		"api-version": APIVersion,
465	}
466	if len(filter) > 0 {
467		queryParameters["$filter"] = autorest.Encode("query", filter)
468	}
469	if skip != nil {
470		queryParameters["$skip"] = autorest.Encode("query", *skip)
471	}
472	if top != nil {
473		queryParameters["$top"] = autorest.Encode("query", *top)
474	}
475	if len(inlinecount) > 0 {
476		queryParameters["$inlinecount"] = autorest.Encode("query", inlinecount)
477	}
478
479	preparer := autorest.CreatePreparer(
480		autorest.AsGet(),
481		autorest.WithBaseURL(client.BaseURI),
482		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations", pathParameters),
483		autorest.WithQueryParameters(queryParameters))
484	return preparer.Prepare((&http.Request{}).WithContext(ctx))
485}
486
487// ListByAutomationAccountSender sends the ListByAutomationAccount request. The method will close the
488// http.Response Body if it receives an error.
489func (client DscConfigurationClient) ListByAutomationAccountSender(req *http.Request) (*http.Response, error) {
490	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
491}
492
493// ListByAutomationAccountResponder handles the response to the ListByAutomationAccount request. The method always
494// closes the http.Response Body.
495func (client DscConfigurationClient) ListByAutomationAccountResponder(resp *http.Response) (result DscConfigurationListResult, err error) {
496	err = autorest.Respond(
497		resp,
498		azure.WithErrorUnlessStatusCode(http.StatusOK),
499		autorest.ByUnmarshallingJSON(&result),
500		autorest.ByClosing())
501	result.Response = autorest.Response{Response: resp}
502	return
503}
504
505// listByAutomationAccountNextResults retrieves the next set of results, if any.
506func (client DscConfigurationClient) listByAutomationAccountNextResults(ctx context.Context, lastResults DscConfigurationListResult) (result DscConfigurationListResult, err error) {
507	req, err := lastResults.dscConfigurationListResultPreparer(ctx)
508	if err != nil {
509		return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", nil, "Failure preparing next results request")
510	}
511	if req == nil {
512		return
513	}
514	resp, err := client.ListByAutomationAccountSender(req)
515	if err != nil {
516		result.Response = autorest.Response{Response: resp}
517		return result, autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure sending next results request")
518	}
519	result, err = client.ListByAutomationAccountResponder(resp)
520	if err != nil {
521		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "listByAutomationAccountNextResults", resp, "Failure responding to next results request")
522	}
523	return
524}
525
526// ListByAutomationAccountComplete enumerates all values, automatically crossing page boundaries as required.
527func (client DscConfigurationClient) ListByAutomationAccountComplete(ctx context.Context, resourceGroupName string, automationAccountName string, filter string, skip *int32, top *int32, inlinecount string) (result DscConfigurationListResultIterator, err error) {
528	if tracing.IsEnabled() {
529		ctx = tracing.StartSpan(ctx, fqdn+"/DscConfigurationClient.ListByAutomationAccount")
530		defer func() {
531			sc := -1
532			if result.Response().Response.Response != nil {
533				sc = result.page.Response().Response.Response.StatusCode
534			}
535			tracing.EndSpan(ctx, sc, err)
536		}()
537	}
538	result.page, err = client.ListByAutomationAccount(ctx, resourceGroupName, automationAccountName, filter, skip, top, inlinecount)
539	return
540}
541
542// Update create the configuration identified by configuration name.
543// Parameters:
544// resourceGroupName - name of an Azure Resource group.
545// automationAccountName - the name of the automation account.
546// configurationName - the create or update parameters for configuration.
547// parameters - the create or update parameters for configuration.
548func (client DscConfigurationClient) Update(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters *DscConfigurationUpdateParameters) (result DscConfiguration, err error) {
549	if tracing.IsEnabled() {
550		ctx = tracing.StartSpan(ctx, fqdn+"/DscConfigurationClient.Update")
551		defer func() {
552			sc := -1
553			if result.Response.Response != nil {
554				sc = result.Response.Response.StatusCode
555			}
556			tracing.EndSpan(ctx, sc, err)
557		}()
558	}
559	if err := validation.Validate([]validation.Validation{
560		{TargetValue: resourceGroupName,
561			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
562				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
563				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
564		return result, validation.NewError("automation.DscConfigurationClient", "Update", err.Error())
565	}
566
567	req, err := client.UpdatePreparer(ctx, resourceGroupName, automationAccountName, configurationName, parameters)
568	if err != nil {
569		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", nil, "Failure preparing request")
570		return
571	}
572
573	resp, err := client.UpdateSender(req)
574	if err != nil {
575		result.Response = autorest.Response{Response: resp}
576		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", resp, "Failure sending request")
577		return
578	}
579
580	result, err = client.UpdateResponder(resp)
581	if err != nil {
582		err = autorest.NewErrorWithError(err, "automation.DscConfigurationClient", "Update", resp, "Failure responding to request")
583		return
584	}
585
586	return
587}
588
589// UpdatePreparer prepares the Update request.
590func (client DscConfigurationClient) UpdatePreparer(ctx context.Context, resourceGroupName string, automationAccountName string, configurationName string, parameters *DscConfigurationUpdateParameters) (*http.Request, error) {
591	pathParameters := map[string]interface{}{
592		"automationAccountName": autorest.Encode("path", automationAccountName),
593		"configurationName":     autorest.Encode("path", configurationName),
594		"resourceGroupName":     autorest.Encode("path", resourceGroupName),
595		"subscriptionId":        autorest.Encode("path", client.SubscriptionID),
596	}
597
598	const APIVersion = "2015-10-31"
599	queryParameters := map[string]interface{}{
600		"api-version": APIVersion,
601	}
602
603	preparer := autorest.CreatePreparer(
604		autorest.AsContentType("application/json; charset=utf-8"),
605		autorest.AsPatch(),
606		autorest.WithBaseURL(client.BaseURI),
607		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/configurations/{configurationName}", pathParameters),
608		autorest.WithQueryParameters(queryParameters))
609	if parameters != nil {
610		preparer = autorest.DecoratePreparer(preparer,
611			autorest.WithJSON(parameters))
612	}
613	return preparer.Prepare((&http.Request{}).WithContext(ctx))
614}
615
616// UpdateSender sends the Update request. The method will close the
617// http.Response Body if it receives an error.
618func (client DscConfigurationClient) UpdateSender(req *http.Request) (*http.Response, error) {
619	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
620}
621
622// UpdateResponder handles the response to the Update request. The method always
623// closes the http.Response Body.
624func (client DscConfigurationClient) UpdateResponder(resp *http.Response) (result DscConfiguration, err error) {
625	err = autorest.Respond(
626		resp,
627		azure.WithErrorUnlessStatusCode(http.StatusOK),
628		autorest.ByUnmarshallingJSON(&result),
629		autorest.ByClosing())
630	result.Response = autorest.Response{Response: resp}
631	return
632}
633