1package resources
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// Client is the provides operations for working with resources and resource groups.
19type Client struct {
20	BaseClient
21}
22
23// NewClient creates an instance of the Client client.
24func NewClient(subscriptionID string) Client {
25	return NewClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewClientWithBaseURI creates an instance of the Client client using a custom endpoint.  Use this when interacting
29// with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewClientWithBaseURI(baseURI string, subscriptionID string) Client {
31	return Client{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CheckExistence checks whether a resource exists.
35// Parameters:
36// resourceGroupName - the name of the resource group containing the resource to check. The name is case
37// insensitive.
38// resourceProviderNamespace - the resource provider of the resource to check.
39// parentResourcePath - the parent resource identity.
40// resourceType - the resource type.
41// resourceName - the name of the resource to check whether it exists.
42// APIVersion - the API version to use for the operation.
43func (client Client) CheckExistence(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result autorest.Response, err error) {
44	if tracing.IsEnabled() {
45		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckExistence")
46		defer func() {
47			sc := -1
48			if result.Response != nil {
49				sc = result.Response.StatusCode
50			}
51			tracing.EndSpan(ctx, sc, err)
52		}()
53	}
54	if err := validation.Validate([]validation.Validation{
55		{TargetValue: resourceGroupName,
56			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
57				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
58				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
59		return result, validation.NewError("resources.Client", "CheckExistence", err.Error())
60	}
61
62	req, err := client.CheckExistencePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion)
63	if err != nil {
64		err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistence", nil, "Failure preparing request")
65		return
66	}
67
68	resp, err := client.CheckExistenceSender(req)
69	if err != nil {
70		result.Response = resp
71		err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistence", resp, "Failure sending request")
72		return
73	}
74
75	result, err = client.CheckExistenceResponder(resp)
76	if err != nil {
77		err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistence", resp, "Failure responding to request")
78		return
79	}
80
81	return
82}
83
84// CheckExistencePreparer prepares the CheckExistence request.
85func (client Client) CheckExistencePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) {
86	pathParameters := map[string]interface{}{
87		"parentResourcePath":        parentResourcePath,
88		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
89		"resourceName":              autorest.Encode("path", resourceName),
90		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
91		"resourceType":              resourceType,
92		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
93	}
94
95	queryParameters := map[string]interface{}{
96		"api-version": APIVersion,
97	}
98
99	preparer := autorest.CreatePreparer(
100		autorest.AsHead(),
101		autorest.WithBaseURL(client.BaseURI),
102		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
103		autorest.WithQueryParameters(queryParameters))
104	return preparer.Prepare((&http.Request{}).WithContext(ctx))
105}
106
107// CheckExistenceSender sends the CheckExistence request. The method will close the
108// http.Response Body if it receives an error.
109func (client Client) CheckExistenceSender(req *http.Request) (*http.Response, error) {
110	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
111}
112
113// CheckExistenceResponder handles the response to the CheckExistence request. The method always
114// closes the http.Response Body.
115func (client Client) CheckExistenceResponder(resp *http.Response) (result autorest.Response, err error) {
116	err = autorest.Respond(
117		resp,
118		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
119		autorest.ByClosing())
120	result.Response = resp
121	return
122}
123
124// CheckExistenceByID checks by ID whether a resource exists.
125// Parameters:
126// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
127// format,
128// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
129// APIVersion - the API version to use for the operation.
130func (client Client) CheckExistenceByID(ctx context.Context, resourceID string, APIVersion string) (result autorest.Response, err error) {
131	if tracing.IsEnabled() {
132		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CheckExistenceByID")
133		defer func() {
134			sc := -1
135			if result.Response != nil {
136				sc = result.Response.StatusCode
137			}
138			tracing.EndSpan(ctx, sc, err)
139		}()
140	}
141	req, err := client.CheckExistenceByIDPreparer(ctx, resourceID, APIVersion)
142	if err != nil {
143		err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistenceByID", nil, "Failure preparing request")
144		return
145	}
146
147	resp, err := client.CheckExistenceByIDSender(req)
148	if err != nil {
149		result.Response = resp
150		err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistenceByID", resp, "Failure sending request")
151		return
152	}
153
154	result, err = client.CheckExistenceByIDResponder(resp)
155	if err != nil {
156		err = autorest.NewErrorWithError(err, "resources.Client", "CheckExistenceByID", resp, "Failure responding to request")
157		return
158	}
159
160	return
161}
162
163// CheckExistenceByIDPreparer prepares the CheckExistenceByID request.
164func (client Client) CheckExistenceByIDPreparer(ctx context.Context, resourceID string, APIVersion string) (*http.Request, error) {
165	pathParameters := map[string]interface{}{
166		"resourceId": resourceID,
167	}
168
169	queryParameters := map[string]interface{}{
170		"api-version": APIVersion,
171	}
172
173	preparer := autorest.CreatePreparer(
174		autorest.AsHead(),
175		autorest.WithBaseURL(client.BaseURI),
176		autorest.WithPathParameters("/{resourceId}", pathParameters),
177		autorest.WithQueryParameters(queryParameters))
178	return preparer.Prepare((&http.Request{}).WithContext(ctx))
179}
180
181// CheckExistenceByIDSender sends the CheckExistenceByID request. The method will close the
182// http.Response Body if it receives an error.
183func (client Client) CheckExistenceByIDSender(req *http.Request) (*http.Response, error) {
184	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
185}
186
187// CheckExistenceByIDResponder handles the response to the CheckExistenceByID request. The method always
188// closes the http.Response Body.
189func (client Client) CheckExistenceByIDResponder(resp *http.Response) (result autorest.Response, err error) {
190	err = autorest.Respond(
191		resp,
192		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound),
193		autorest.ByClosing())
194	result.Response = resp
195	return
196}
197
198// CreateOrUpdate creates a resource.
199// Parameters:
200// resourceGroupName - the name of the resource group for the resource. The name is case insensitive.
201// resourceProviderNamespace - the namespace of the resource provider.
202// parentResourcePath - the parent resource identity.
203// resourceType - the resource type of the resource to create.
204// resourceName - the name of the resource to create.
205// APIVersion - the API version to use for the operation.
206// parameters - parameters for creating or updating the resource.
207func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (result CreateOrUpdateFuture, err error) {
208	if tracing.IsEnabled() {
209		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate")
210		defer func() {
211			sc := -1
212			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
213				sc = result.FutureAPI.Response().StatusCode
214			}
215			tracing.EndSpan(ctx, sc, err)
216		}()
217	}
218	if err := validation.Validate([]validation.Validation{
219		{TargetValue: resourceGroupName,
220			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
221				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
222				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}},
223		{TargetValue: parameters,
224			Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false,
225				Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
226		return result, validation.NewError("resources.Client", "CreateOrUpdate", err.Error())
227	}
228
229	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion, parameters)
230	if err != nil {
231		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", nil, "Failure preparing request")
232		return
233	}
234
235	result, err = client.CreateOrUpdateSender(req)
236	if err != nil {
237		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdate", nil, "Failure sending request")
238		return
239	}
240
241	return
242}
243
244// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
245func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (*http.Request, error) {
246	pathParameters := map[string]interface{}{
247		"parentResourcePath":        parentResourcePath,
248		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
249		"resourceName":              autorest.Encode("path", resourceName),
250		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
251		"resourceType":              resourceType,
252		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
253	}
254
255	queryParameters := map[string]interface{}{
256		"api-version": APIVersion,
257	}
258
259	preparer := autorest.CreatePreparer(
260		autorest.AsContentType("application/json; charset=utf-8"),
261		autorest.AsPut(),
262		autorest.WithBaseURL(client.BaseURI),
263		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
264		autorest.WithJSON(parameters),
265		autorest.WithQueryParameters(queryParameters))
266	return preparer.Prepare((&http.Request{}).WithContext(ctx))
267}
268
269// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
270// http.Response Body if it receives an error.
271func (client Client) CreateOrUpdateSender(req *http.Request) (future CreateOrUpdateFuture, err error) {
272	var resp *http.Response
273	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
274	if err != nil {
275		return
276	}
277	var azf azure.Future
278	azf, err = azure.NewFutureFromResponse(resp)
279	future.FutureAPI = &azf
280	future.Result = future.result
281	return
282}
283
284// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
285// closes the http.Response Body.
286func (client Client) CreateOrUpdateResponder(resp *http.Response) (result GenericResource, err error) {
287	err = autorest.Respond(
288		resp,
289		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
290		autorest.ByUnmarshallingJSON(&result),
291		autorest.ByClosing())
292	result.Response = autorest.Response{Response: resp}
293	return
294}
295
296// CreateOrUpdateByID create a resource by ID.
297// Parameters:
298// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
299// format,
300// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
301// APIVersion - the API version to use for the operation.
302// parameters - create or update resource parameters.
303func (client Client) CreateOrUpdateByID(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (result CreateOrUpdateByIDFuture, err error) {
304	if tracing.IsEnabled() {
305		ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdateByID")
306		defer func() {
307			sc := -1
308			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
309				sc = result.FutureAPI.Response().StatusCode
310			}
311			tracing.EndSpan(ctx, sc, err)
312		}()
313	}
314	if err := validation.Validate([]validation.Validation{
315		{TargetValue: parameters,
316			Constraints: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Null, Rule: false,
317				Chain: []validation.Constraint{{Target: "parameters.Kind", Name: validation.Pattern, Rule: `^[-\w\._,\(\)]+$`, Chain: nil}}}}}}); err != nil {
318		return result, validation.NewError("resources.Client", "CreateOrUpdateByID", err.Error())
319	}
320
321	req, err := client.CreateOrUpdateByIDPreparer(ctx, resourceID, APIVersion, parameters)
322	if err != nil {
323		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", nil, "Failure preparing request")
324		return
325	}
326
327	result, err = client.CreateOrUpdateByIDSender(req)
328	if err != nil {
329		err = autorest.NewErrorWithError(err, "resources.Client", "CreateOrUpdateByID", nil, "Failure sending request")
330		return
331	}
332
333	return
334}
335
336// CreateOrUpdateByIDPreparer prepares the CreateOrUpdateByID request.
337func (client Client) CreateOrUpdateByIDPreparer(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (*http.Request, error) {
338	pathParameters := map[string]interface{}{
339		"resourceId": resourceID,
340	}
341
342	queryParameters := map[string]interface{}{
343		"api-version": APIVersion,
344	}
345
346	preparer := autorest.CreatePreparer(
347		autorest.AsContentType("application/json; charset=utf-8"),
348		autorest.AsPut(),
349		autorest.WithBaseURL(client.BaseURI),
350		autorest.WithPathParameters("/{resourceId}", pathParameters),
351		autorest.WithJSON(parameters),
352		autorest.WithQueryParameters(queryParameters))
353	return preparer.Prepare((&http.Request{}).WithContext(ctx))
354}
355
356// CreateOrUpdateByIDSender sends the CreateOrUpdateByID request. The method will close the
357// http.Response Body if it receives an error.
358func (client Client) CreateOrUpdateByIDSender(req *http.Request) (future CreateOrUpdateByIDFuture, err error) {
359	var resp *http.Response
360	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
361	if err != nil {
362		return
363	}
364	var azf azure.Future
365	azf, err = azure.NewFutureFromResponse(resp)
366	future.FutureAPI = &azf
367	future.Result = future.result
368	return
369}
370
371// CreateOrUpdateByIDResponder handles the response to the CreateOrUpdateByID request. The method always
372// closes the http.Response Body.
373func (client Client) CreateOrUpdateByIDResponder(resp *http.Response) (result GenericResource, err error) {
374	err = autorest.Respond(
375		resp,
376		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
377		autorest.ByUnmarshallingJSON(&result),
378		autorest.ByClosing())
379	result.Response = autorest.Response{Response: resp}
380	return
381}
382
383// Delete deletes a resource.
384// Parameters:
385// resourceGroupName - the name of the resource group that contains the resource to delete. The name is case
386// insensitive.
387// resourceProviderNamespace - the namespace of the resource provider.
388// parentResourcePath - the parent resource identity.
389// resourceType - the resource type.
390// resourceName - the name of the resource to delete.
391// APIVersion - the API version to use for the operation.
392func (client Client) Delete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result DeleteFuture, err error) {
393	if tracing.IsEnabled() {
394		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Delete")
395		defer func() {
396			sc := -1
397			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
398				sc = result.FutureAPI.Response().StatusCode
399			}
400			tracing.EndSpan(ctx, sc, err)
401		}()
402	}
403	if err := validation.Validate([]validation.Validation{
404		{TargetValue: resourceGroupName,
405			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
406				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
407				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
408		return result, validation.NewError("resources.Client", "Delete", err.Error())
409	}
410
411	req, err := client.DeletePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion)
412	if err != nil {
413		err = autorest.NewErrorWithError(err, "resources.Client", "Delete", nil, "Failure preparing request")
414		return
415	}
416
417	result, err = client.DeleteSender(req)
418	if err != nil {
419		err = autorest.NewErrorWithError(err, "resources.Client", "Delete", nil, "Failure sending request")
420		return
421	}
422
423	return
424}
425
426// DeletePreparer prepares the Delete request.
427func (client Client) DeletePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) {
428	pathParameters := map[string]interface{}{
429		"parentResourcePath":        parentResourcePath,
430		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
431		"resourceName":              autorest.Encode("path", resourceName),
432		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
433		"resourceType":              resourceType,
434		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
435	}
436
437	queryParameters := map[string]interface{}{
438		"api-version": APIVersion,
439	}
440
441	preparer := autorest.CreatePreparer(
442		autorest.AsDelete(),
443		autorest.WithBaseURL(client.BaseURI),
444		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
445		autorest.WithQueryParameters(queryParameters))
446	return preparer.Prepare((&http.Request{}).WithContext(ctx))
447}
448
449// DeleteSender sends the Delete request. The method will close the
450// http.Response Body if it receives an error.
451func (client Client) DeleteSender(req *http.Request) (future DeleteFuture, err error) {
452	var resp *http.Response
453	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
454	if err != nil {
455		return
456	}
457	var azf azure.Future
458	azf, err = azure.NewFutureFromResponse(resp)
459	future.FutureAPI = &azf
460	future.Result = future.result
461	return
462}
463
464// DeleteResponder handles the response to the Delete request. The method always
465// closes the http.Response Body.
466func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
467	err = autorest.Respond(
468		resp,
469		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
470		autorest.ByClosing())
471	result.Response = resp
472	return
473}
474
475// DeleteByID deletes a resource by ID.
476// Parameters:
477// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
478// format,
479// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
480// APIVersion - the API version to use for the operation.
481func (client Client) DeleteByID(ctx context.Context, resourceID string, APIVersion string) (result DeleteByIDFuture, err error) {
482	if tracing.IsEnabled() {
483		ctx = tracing.StartSpan(ctx, fqdn+"/Client.DeleteByID")
484		defer func() {
485			sc := -1
486			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
487				sc = result.FutureAPI.Response().StatusCode
488			}
489			tracing.EndSpan(ctx, sc, err)
490		}()
491	}
492	req, err := client.DeleteByIDPreparer(ctx, resourceID, APIVersion)
493	if err != nil {
494		err = autorest.NewErrorWithError(err, "resources.Client", "DeleteByID", nil, "Failure preparing request")
495		return
496	}
497
498	result, err = client.DeleteByIDSender(req)
499	if err != nil {
500		err = autorest.NewErrorWithError(err, "resources.Client", "DeleteByID", nil, "Failure sending request")
501		return
502	}
503
504	return
505}
506
507// DeleteByIDPreparer prepares the DeleteByID request.
508func (client Client) DeleteByIDPreparer(ctx context.Context, resourceID string, APIVersion string) (*http.Request, error) {
509	pathParameters := map[string]interface{}{
510		"resourceId": resourceID,
511	}
512
513	queryParameters := map[string]interface{}{
514		"api-version": APIVersion,
515	}
516
517	preparer := autorest.CreatePreparer(
518		autorest.AsDelete(),
519		autorest.WithBaseURL(client.BaseURI),
520		autorest.WithPathParameters("/{resourceId}", pathParameters),
521		autorest.WithQueryParameters(queryParameters))
522	return preparer.Prepare((&http.Request{}).WithContext(ctx))
523}
524
525// DeleteByIDSender sends the DeleteByID request. The method will close the
526// http.Response Body if it receives an error.
527func (client Client) DeleteByIDSender(req *http.Request) (future DeleteByIDFuture, err error) {
528	var resp *http.Response
529	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
530	if err != nil {
531		return
532	}
533	var azf azure.Future
534	azf, err = azure.NewFutureFromResponse(resp)
535	future.FutureAPI = &azf
536	future.Result = future.result
537	return
538}
539
540// DeleteByIDResponder handles the response to the DeleteByID request. The method always
541// closes the http.Response Body.
542func (client Client) DeleteByIDResponder(resp *http.Response) (result autorest.Response, err error) {
543	err = autorest.Respond(
544		resp,
545		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
546		autorest.ByClosing())
547	result.Response = resp
548	return
549}
550
551// Get gets a resource.
552// Parameters:
553// resourceGroupName - the name of the resource group containing the resource to get. The name is case
554// insensitive.
555// resourceProviderNamespace - the namespace of the resource provider.
556// parentResourcePath - the parent resource identity.
557// resourceType - the resource type of the resource.
558// resourceName - the name of the resource to get.
559// APIVersion - the API version to use for the operation.
560func (client Client) Get(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (result GenericResource, err error) {
561	if tracing.IsEnabled() {
562		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get")
563		defer func() {
564			sc := -1
565			if result.Response.Response != nil {
566				sc = result.Response.Response.StatusCode
567			}
568			tracing.EndSpan(ctx, sc, err)
569		}()
570	}
571	if err := validation.Validate([]validation.Validation{
572		{TargetValue: resourceGroupName,
573			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
574				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
575				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
576		return result, validation.NewError("resources.Client", "Get", err.Error())
577	}
578
579	req, err := client.GetPreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion)
580	if err != nil {
581		err = autorest.NewErrorWithError(err, "resources.Client", "Get", nil, "Failure preparing request")
582		return
583	}
584
585	resp, err := client.GetSender(req)
586	if err != nil {
587		result.Response = autorest.Response{Response: resp}
588		err = autorest.NewErrorWithError(err, "resources.Client", "Get", resp, "Failure sending request")
589		return
590	}
591
592	result, err = client.GetResponder(resp)
593	if err != nil {
594		err = autorest.NewErrorWithError(err, "resources.Client", "Get", resp, "Failure responding to request")
595		return
596	}
597
598	return
599}
600
601// GetPreparer prepares the Get request.
602func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string) (*http.Request, error) {
603	pathParameters := map[string]interface{}{
604		"parentResourcePath":        parentResourcePath,
605		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
606		"resourceName":              autorest.Encode("path", resourceName),
607		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
608		"resourceType":              resourceType,
609		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
610	}
611
612	queryParameters := map[string]interface{}{
613		"api-version": APIVersion,
614	}
615
616	preparer := autorest.CreatePreparer(
617		autorest.AsGet(),
618		autorest.WithBaseURL(client.BaseURI),
619		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
620		autorest.WithQueryParameters(queryParameters))
621	return preparer.Prepare((&http.Request{}).WithContext(ctx))
622}
623
624// GetSender sends the Get request. The method will close the
625// http.Response Body if it receives an error.
626func (client Client) GetSender(req *http.Request) (*http.Response, error) {
627	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
628}
629
630// GetResponder handles the response to the Get request. The method always
631// closes the http.Response Body.
632func (client Client) GetResponder(resp *http.Response) (result GenericResource, err error) {
633	err = autorest.Respond(
634		resp,
635		azure.WithErrorUnlessStatusCode(http.StatusOK),
636		autorest.ByUnmarshallingJSON(&result),
637		autorest.ByClosing())
638	result.Response = autorest.Response{Response: resp}
639	return
640}
641
642// GetByID gets a resource by ID.
643// Parameters:
644// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
645// format,
646// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
647// APIVersion - the API version to use for the operation.
648func (client Client) GetByID(ctx context.Context, resourceID string, APIVersion string) (result GenericResource, err error) {
649	if tracing.IsEnabled() {
650		ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetByID")
651		defer func() {
652			sc := -1
653			if result.Response.Response != nil {
654				sc = result.Response.Response.StatusCode
655			}
656			tracing.EndSpan(ctx, sc, err)
657		}()
658	}
659	req, err := client.GetByIDPreparer(ctx, resourceID, APIVersion)
660	if err != nil {
661		err = autorest.NewErrorWithError(err, "resources.Client", "GetByID", nil, "Failure preparing request")
662		return
663	}
664
665	resp, err := client.GetByIDSender(req)
666	if err != nil {
667		result.Response = autorest.Response{Response: resp}
668		err = autorest.NewErrorWithError(err, "resources.Client", "GetByID", resp, "Failure sending request")
669		return
670	}
671
672	result, err = client.GetByIDResponder(resp)
673	if err != nil {
674		err = autorest.NewErrorWithError(err, "resources.Client", "GetByID", resp, "Failure responding to request")
675		return
676	}
677
678	return
679}
680
681// GetByIDPreparer prepares the GetByID request.
682func (client Client) GetByIDPreparer(ctx context.Context, resourceID string, APIVersion string) (*http.Request, error) {
683	pathParameters := map[string]interface{}{
684		"resourceId": resourceID,
685	}
686
687	queryParameters := map[string]interface{}{
688		"api-version": APIVersion,
689	}
690
691	preparer := autorest.CreatePreparer(
692		autorest.AsGet(),
693		autorest.WithBaseURL(client.BaseURI),
694		autorest.WithPathParameters("/{resourceId}", pathParameters),
695		autorest.WithQueryParameters(queryParameters))
696	return preparer.Prepare((&http.Request{}).WithContext(ctx))
697}
698
699// GetByIDSender sends the GetByID request. The method will close the
700// http.Response Body if it receives an error.
701func (client Client) GetByIDSender(req *http.Request) (*http.Response, error) {
702	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
703}
704
705// GetByIDResponder handles the response to the GetByID request. The method always
706// closes the http.Response Body.
707func (client Client) GetByIDResponder(resp *http.Response) (result GenericResource, err error) {
708	err = autorest.Respond(
709		resp,
710		azure.WithErrorUnlessStatusCode(http.StatusOK),
711		autorest.ByUnmarshallingJSON(&result),
712		autorest.ByClosing())
713	result.Response = autorest.Response{Response: resp}
714	return
715}
716
717// List get all the resources in a subscription.
718// Parameters:
719// filter - the filter to apply on the operation.<br><br>The properties you can use for eq (equals) or ne (not
720// equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan,
721// plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.<br><br>For example, to filter
722// by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'<br><br>You can use
723// substringof(value, property) in the filter. The properties you can use for substring are: name and
724// resourceGroup.<br><br>For example, to get all resources with 'demo' anywhere in the name, use:
725// $filter=substringof('demo', name)<br><br>You can link more than one substringof together by adding and/or
726// operators.<br><br>You can filter by tag names and values. For example, to filter for a tag name and value,
727// use $filter=tagName eq 'tag1' and tagValue eq 'Value1'<br><br>You can use some properties together when
728// filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and
729// plan/name, identity and identity/principalId.
730// expand - comma-separated list of additional properties to be included in the response. Valid values include
731// `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`.
732// top - the number of results to return. If null is passed, returns all resource groups.
733func (client Client) List(ctx context.Context, filter string, expand string, top *int32) (result ListResultPage, err error) {
734	if tracing.IsEnabled() {
735		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
736		defer func() {
737			sc := -1
738			if result.lr.Response.Response != nil {
739				sc = result.lr.Response.Response.StatusCode
740			}
741			tracing.EndSpan(ctx, sc, err)
742		}()
743	}
744	result.fn = client.listNextResults
745	req, err := client.ListPreparer(ctx, filter, expand, top)
746	if err != nil {
747		err = autorest.NewErrorWithError(err, "resources.Client", "List", nil, "Failure preparing request")
748		return
749	}
750
751	resp, err := client.ListSender(req)
752	if err != nil {
753		result.lr.Response = autorest.Response{Response: resp}
754		err = autorest.NewErrorWithError(err, "resources.Client", "List", resp, "Failure sending request")
755		return
756	}
757
758	result.lr, err = client.ListResponder(resp)
759	if err != nil {
760		err = autorest.NewErrorWithError(err, "resources.Client", "List", resp, "Failure responding to request")
761		return
762	}
763	if result.lr.hasNextLink() && result.lr.IsEmpty() {
764		err = result.NextWithContext(ctx)
765		return
766	}
767
768	return
769}
770
771// ListPreparer prepares the List request.
772func (client Client) ListPreparer(ctx context.Context, filter string, expand string, top *int32) (*http.Request, error) {
773	pathParameters := map[string]interface{}{
774		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
775	}
776
777	const APIVersion = "2019-05-01"
778	queryParameters := map[string]interface{}{
779		"api-version": APIVersion,
780	}
781	if len(filter) > 0 {
782		queryParameters["$filter"] = autorest.Encode("query", filter)
783	}
784	if len(expand) > 0 {
785		queryParameters["$expand"] = autorest.Encode("query", expand)
786	}
787	if top != nil {
788		queryParameters["$top"] = autorest.Encode("query", *top)
789	}
790
791	preparer := autorest.CreatePreparer(
792		autorest.AsGet(),
793		autorest.WithBaseURL(client.BaseURI),
794		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", pathParameters),
795		autorest.WithQueryParameters(queryParameters))
796	return preparer.Prepare((&http.Request{}).WithContext(ctx))
797}
798
799// ListSender sends the List request. The method will close the
800// http.Response Body if it receives an error.
801func (client Client) ListSender(req *http.Request) (*http.Response, error) {
802	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
803}
804
805// ListResponder handles the response to the List request. The method always
806// closes the http.Response Body.
807func (client Client) ListResponder(resp *http.Response) (result ListResult, err error) {
808	err = autorest.Respond(
809		resp,
810		azure.WithErrorUnlessStatusCode(http.StatusOK),
811		autorest.ByUnmarshallingJSON(&result),
812		autorest.ByClosing())
813	result.Response = autorest.Response{Response: resp}
814	return
815}
816
817// listNextResults retrieves the next set of results, if any.
818func (client Client) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
819	req, err := lastResults.listResultPreparer(ctx)
820	if err != nil {
821		return result, autorest.NewErrorWithError(err, "resources.Client", "listNextResults", nil, "Failure preparing next results request")
822	}
823	if req == nil {
824		return
825	}
826	resp, err := client.ListSender(req)
827	if err != nil {
828		result.Response = autorest.Response{Response: resp}
829		return result, autorest.NewErrorWithError(err, "resources.Client", "listNextResults", resp, "Failure sending next results request")
830	}
831	result, err = client.ListResponder(resp)
832	if err != nil {
833		err = autorest.NewErrorWithError(err, "resources.Client", "listNextResults", resp, "Failure responding to next results request")
834	}
835	return
836}
837
838// ListComplete enumerates all values, automatically crossing page boundaries as required.
839func (client Client) ListComplete(ctx context.Context, filter string, expand string, top *int32) (result ListResultIterator, err error) {
840	if tracing.IsEnabled() {
841		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
842		defer func() {
843			sc := -1
844			if result.Response().Response.Response != nil {
845				sc = result.page.Response().Response.Response.StatusCode
846			}
847			tracing.EndSpan(ctx, sc, err)
848		}()
849	}
850	result.page, err = client.List(ctx, filter, expand, top)
851	return
852}
853
854// ListByResourceGroup get all the resources for a resource group.
855// Parameters:
856// resourceGroupName - the resource group with the resources to get.
857// filter - the filter to apply on the operation.<br><br>The properties you can use for eq (equals) or ne (not
858// equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan,
859// plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.<br><br>For example, to filter
860// by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'<br><br>You can use
861// substringof(value, property) in the filter. The properties you can use for substring are: name and
862// resourceGroup.<br><br>For example, to get all resources with 'demo' anywhere in the name, use:
863// $filter=substringof('demo', name)<br><br>You can link more than one substringof together by adding and/or
864// operators.<br><br>You can filter by tag names and values. For example, to filter for a tag name and value,
865// use $filter=tagName eq 'tag1' and tagValue eq 'Value1'<br><br>You can use some properties together when
866// filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and
867// plan/name, identity and identity/principalId.
868// expand - comma-separated list of additional properties to be included in the response. Valid values include
869// `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`.
870// top - the number of results to return. If null is passed, returns all resources.
871func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultPage, err error) {
872	if tracing.IsEnabled() {
873		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
874		defer func() {
875			sc := -1
876			if result.lr.Response.Response != nil {
877				sc = result.lr.Response.Response.StatusCode
878			}
879			tracing.EndSpan(ctx, sc, err)
880		}()
881	}
882	if err := validation.Validate([]validation.Validation{
883		{TargetValue: resourceGroupName,
884			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
885				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
886				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
887		return result, validation.NewError("resources.Client", "ListByResourceGroup", err.Error())
888	}
889
890	result.fn = client.listByResourceGroupNextResults
891	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, expand, top)
892	if err != nil {
893		err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", nil, "Failure preparing request")
894		return
895	}
896
897	resp, err := client.ListByResourceGroupSender(req)
898	if err != nil {
899		result.lr.Response = autorest.Response{Response: resp}
900		err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", resp, "Failure sending request")
901		return
902	}
903
904	result.lr, err = client.ListByResourceGroupResponder(resp)
905	if err != nil {
906		err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", resp, "Failure responding to request")
907		return
908	}
909	if result.lr.hasNextLink() && result.lr.IsEmpty() {
910		err = result.NextWithContext(ctx)
911		return
912	}
913
914	return
915}
916
917// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
918func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (*http.Request, error) {
919	pathParameters := map[string]interface{}{
920		"resourceGroupName": autorest.Encode("path", resourceGroupName),
921		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
922	}
923
924	const APIVersion = "2019-05-01"
925	queryParameters := map[string]interface{}{
926		"api-version": APIVersion,
927	}
928	if len(filter) > 0 {
929		queryParameters["$filter"] = autorest.Encode("query", filter)
930	}
931	if len(expand) > 0 {
932		queryParameters["$expand"] = autorest.Encode("query", expand)
933	}
934	if top != nil {
935		queryParameters["$top"] = autorest.Encode("query", *top)
936	}
937
938	preparer := autorest.CreatePreparer(
939		autorest.AsGet(),
940		autorest.WithBaseURL(client.BaseURI),
941		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources", pathParameters),
942		autorest.WithQueryParameters(queryParameters))
943	return preparer.Prepare((&http.Request{}).WithContext(ctx))
944}
945
946// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
947// http.Response Body if it receives an error.
948func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
949	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
950}
951
952// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
953// closes the http.Response Body.
954func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) {
955	err = autorest.Respond(
956		resp,
957		azure.WithErrorUnlessStatusCode(http.StatusOK),
958		autorest.ByUnmarshallingJSON(&result),
959		autorest.ByClosing())
960	result.Response = autorest.Response{Response: resp}
961	return
962}
963
964// listByResourceGroupNextResults retrieves the next set of results, if any.
965func (client Client) listByResourceGroupNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
966	req, err := lastResults.listResultPreparer(ctx)
967	if err != nil {
968		return result, autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
969	}
970	if req == nil {
971		return
972	}
973	resp, err := client.ListByResourceGroupSender(req)
974	if err != nil {
975		result.Response = autorest.Response{Response: resp}
976		return result, autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request")
977	}
978	result, err = client.ListByResourceGroupResponder(resp)
979	if err != nil {
980		err = autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
981	}
982	return
983}
984
985// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
986func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultIterator, err error) {
987	if tracing.IsEnabled() {
988		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
989		defer func() {
990			sc := -1
991			if result.Response().Response.Response != nil {
992				sc = result.page.Response().Response.Response.StatusCode
993			}
994			tracing.EndSpan(ctx, sc, err)
995		}()
996	}
997	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, expand, top)
998	return
999}
1000
1001// MoveResources the resources to move must be in the same source resource group. The target resource group may be in a
1002// different subscription. When moving resources, both the source group and the target group are locked for the
1003// duration of the operation. Write and delete operations are blocked on the groups until the move completes.
1004// Parameters:
1005// sourceResourceGroupName - the name of the resource group containing the resources to move.
1006// parameters - parameters for moving resources.
1007func (client Client) MoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (result MoveResourcesFuture, err error) {
1008	if tracing.IsEnabled() {
1009		ctx = tracing.StartSpan(ctx, fqdn+"/Client.MoveResources")
1010		defer func() {
1011			sc := -1
1012			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1013				sc = result.FutureAPI.Response().StatusCode
1014			}
1015			tracing.EndSpan(ctx, sc, err)
1016		}()
1017	}
1018	if err := validation.Validate([]validation.Validation{
1019		{TargetValue: sourceResourceGroupName,
1020			Constraints: []validation.Constraint{{Target: "sourceResourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1021				{Target: "sourceResourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1022				{Target: "sourceResourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
1023		return result, validation.NewError("resources.Client", "MoveResources", err.Error())
1024	}
1025
1026	req, err := client.MoveResourcesPreparer(ctx, sourceResourceGroupName, parameters)
1027	if err != nil {
1028		err = autorest.NewErrorWithError(err, "resources.Client", "MoveResources", nil, "Failure preparing request")
1029		return
1030	}
1031
1032	result, err = client.MoveResourcesSender(req)
1033	if err != nil {
1034		err = autorest.NewErrorWithError(err, "resources.Client", "MoveResources", nil, "Failure sending request")
1035		return
1036	}
1037
1038	return
1039}
1040
1041// MoveResourcesPreparer prepares the MoveResources request.
1042func (client Client) MoveResourcesPreparer(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (*http.Request, error) {
1043	pathParameters := map[string]interface{}{
1044		"sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName),
1045		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
1046	}
1047
1048	const APIVersion = "2019-05-01"
1049	queryParameters := map[string]interface{}{
1050		"api-version": APIVersion,
1051	}
1052
1053	preparer := autorest.CreatePreparer(
1054		autorest.AsContentType("application/json; charset=utf-8"),
1055		autorest.AsPost(),
1056		autorest.WithBaseURL(client.BaseURI),
1057		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources", pathParameters),
1058		autorest.WithJSON(parameters),
1059		autorest.WithQueryParameters(queryParameters))
1060	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1061}
1062
1063// MoveResourcesSender sends the MoveResources request. The method will close the
1064// http.Response Body if it receives an error.
1065func (client Client) MoveResourcesSender(req *http.Request) (future MoveResourcesFuture, err error) {
1066	var resp *http.Response
1067	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1068	if err != nil {
1069		return
1070	}
1071	var azf azure.Future
1072	azf, err = azure.NewFutureFromResponse(resp)
1073	future.FutureAPI = &azf
1074	future.Result = future.result
1075	return
1076}
1077
1078// MoveResourcesResponder handles the response to the MoveResources request. The method always
1079// closes the http.Response Body.
1080func (client Client) MoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) {
1081	err = autorest.Respond(
1082		resp,
1083		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
1084		autorest.ByClosing())
1085	result.Response = resp
1086	return
1087}
1088
1089// Update updates a resource.
1090// Parameters:
1091// resourceGroupName - the name of the resource group for the resource. The name is case insensitive.
1092// resourceProviderNamespace - the namespace of the resource provider.
1093// parentResourcePath - the parent resource identity.
1094// resourceType - the resource type of the resource to update.
1095// resourceName - the name of the resource to update.
1096// APIVersion - the API version to use for the operation.
1097// parameters - parameters for updating the resource.
1098func (client Client) Update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (result UpdateFuture, err error) {
1099	if tracing.IsEnabled() {
1100		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update")
1101		defer func() {
1102			sc := -1
1103			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1104				sc = result.FutureAPI.Response().StatusCode
1105			}
1106			tracing.EndSpan(ctx, sc, err)
1107		}()
1108	}
1109	if err := validation.Validate([]validation.Validation{
1110		{TargetValue: resourceGroupName,
1111			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1112				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1113				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
1114		return result, validation.NewError("resources.Client", "Update", err.Error())
1115	}
1116
1117	req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion, parameters)
1118	if err != nil {
1119		err = autorest.NewErrorWithError(err, "resources.Client", "Update", nil, "Failure preparing request")
1120		return
1121	}
1122
1123	result, err = client.UpdateSender(req)
1124	if err != nil {
1125		err = autorest.NewErrorWithError(err, "resources.Client", "Update", nil, "Failure sending request")
1126		return
1127	}
1128
1129	return
1130}
1131
1132// UpdatePreparer prepares the Update request.
1133func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (*http.Request, error) {
1134	pathParameters := map[string]interface{}{
1135		"parentResourcePath":        parentResourcePath,
1136		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1137		"resourceName":              autorest.Encode("path", resourceName),
1138		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
1139		"resourceType":              resourceType,
1140		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1141	}
1142
1143	queryParameters := map[string]interface{}{
1144		"api-version": APIVersion,
1145	}
1146
1147	preparer := autorest.CreatePreparer(
1148		autorest.AsContentType("application/json; charset=utf-8"),
1149		autorest.AsPatch(),
1150		autorest.WithBaseURL(client.BaseURI),
1151		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
1152		autorest.WithJSON(parameters),
1153		autorest.WithQueryParameters(queryParameters))
1154	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1155}
1156
1157// UpdateSender sends the Update request. The method will close the
1158// http.Response Body if it receives an error.
1159func (client Client) UpdateSender(req *http.Request) (future UpdateFuture, err error) {
1160	var resp *http.Response
1161	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1162	if err != nil {
1163		return
1164	}
1165	var azf azure.Future
1166	azf, err = azure.NewFutureFromResponse(resp)
1167	future.FutureAPI = &azf
1168	future.Result = future.result
1169	return
1170}
1171
1172// UpdateResponder handles the response to the Update request. The method always
1173// closes the http.Response Body.
1174func (client Client) UpdateResponder(resp *http.Response) (result GenericResource, err error) {
1175	err = autorest.Respond(
1176		resp,
1177		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1178		autorest.ByUnmarshallingJSON(&result),
1179		autorest.ByClosing())
1180	result.Response = autorest.Response{Response: resp}
1181	return
1182}
1183
1184// UpdateByID updates a resource by ID.
1185// Parameters:
1186// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
1187// format,
1188// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
1189// APIVersion - the API version to use for the operation.
1190// parameters - update resource parameters.
1191func (client Client) UpdateByID(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (result UpdateByIDFuture, err error) {
1192	if tracing.IsEnabled() {
1193		ctx = tracing.StartSpan(ctx, fqdn+"/Client.UpdateByID")
1194		defer func() {
1195			sc := -1
1196			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1197				sc = result.FutureAPI.Response().StatusCode
1198			}
1199			tracing.EndSpan(ctx, sc, err)
1200		}()
1201	}
1202	req, err := client.UpdateByIDPreparer(ctx, resourceID, APIVersion, parameters)
1203	if err != nil {
1204		err = autorest.NewErrorWithError(err, "resources.Client", "UpdateByID", nil, "Failure preparing request")
1205		return
1206	}
1207
1208	result, err = client.UpdateByIDSender(req)
1209	if err != nil {
1210		err = autorest.NewErrorWithError(err, "resources.Client", "UpdateByID", nil, "Failure sending request")
1211		return
1212	}
1213
1214	return
1215}
1216
1217// UpdateByIDPreparer prepares the UpdateByID request.
1218func (client Client) UpdateByIDPreparer(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (*http.Request, error) {
1219	pathParameters := map[string]interface{}{
1220		"resourceId": resourceID,
1221	}
1222
1223	queryParameters := map[string]interface{}{
1224		"api-version": APIVersion,
1225	}
1226
1227	preparer := autorest.CreatePreparer(
1228		autorest.AsContentType("application/json; charset=utf-8"),
1229		autorest.AsPatch(),
1230		autorest.WithBaseURL(client.BaseURI),
1231		autorest.WithPathParameters("/{resourceId}", pathParameters),
1232		autorest.WithJSON(parameters),
1233		autorest.WithQueryParameters(queryParameters))
1234	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1235}
1236
1237// UpdateByIDSender sends the UpdateByID request. The method will close the
1238// http.Response Body if it receives an error.
1239func (client Client) UpdateByIDSender(req *http.Request) (future UpdateByIDFuture, err error) {
1240	var resp *http.Response
1241	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1242	if err != nil {
1243		return
1244	}
1245	var azf azure.Future
1246	azf, err = azure.NewFutureFromResponse(resp)
1247	future.FutureAPI = &azf
1248	future.Result = future.result
1249	return
1250}
1251
1252// UpdateByIDResponder handles the response to the UpdateByID request. The method always
1253// closes the http.Response Body.
1254func (client Client) UpdateByIDResponder(resp *http.Response) (result GenericResource, err error) {
1255	err = autorest.Respond(
1256		resp,
1257		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1258		autorest.ByUnmarshallingJSON(&result),
1259		autorest.ByClosing())
1260	result.Response = autorest.Response{Response: resp}
1261	return
1262}
1263
1264// ValidateMoveResources this operation checks whether the specified resources can be moved to the target. The
1265// resources to move must be in the same source resource group. The target resource group may be in a different
1266// subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it
1267// returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to
1268// check the result of the long-running operation.
1269// Parameters:
1270// sourceResourceGroupName - the name of the resource group containing the resources to validate for move.
1271// parameters - parameters for moving resources.
1272func (client Client) ValidateMoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (result ValidateMoveResourcesFuture, err error) {
1273	if tracing.IsEnabled() {
1274		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ValidateMoveResources")
1275		defer func() {
1276			sc := -1
1277			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1278				sc = result.FutureAPI.Response().StatusCode
1279			}
1280			tracing.EndSpan(ctx, sc, err)
1281		}()
1282	}
1283	if err := validation.Validate([]validation.Validation{
1284		{TargetValue: sourceResourceGroupName,
1285			Constraints: []validation.Constraint{{Target: "sourceResourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1286				{Target: "sourceResourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1287				{Target: "sourceResourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
1288		return result, validation.NewError("resources.Client", "ValidateMoveResources", err.Error())
1289	}
1290
1291	req, err := client.ValidateMoveResourcesPreparer(ctx, sourceResourceGroupName, parameters)
1292	if err != nil {
1293		err = autorest.NewErrorWithError(err, "resources.Client", "ValidateMoveResources", nil, "Failure preparing request")
1294		return
1295	}
1296
1297	result, err = client.ValidateMoveResourcesSender(req)
1298	if err != nil {
1299		err = autorest.NewErrorWithError(err, "resources.Client", "ValidateMoveResources", nil, "Failure sending request")
1300		return
1301	}
1302
1303	return
1304}
1305
1306// ValidateMoveResourcesPreparer prepares the ValidateMoveResources request.
1307func (client Client) ValidateMoveResourcesPreparer(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (*http.Request, error) {
1308	pathParameters := map[string]interface{}{
1309		"sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName),
1310		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
1311	}
1312
1313	const APIVersion = "2019-05-01"
1314	queryParameters := map[string]interface{}{
1315		"api-version": APIVersion,
1316	}
1317
1318	preparer := autorest.CreatePreparer(
1319		autorest.AsContentType("application/json; charset=utf-8"),
1320		autorest.AsPost(),
1321		autorest.WithBaseURL(client.BaseURI),
1322		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources", pathParameters),
1323		autorest.WithJSON(parameters),
1324		autorest.WithQueryParameters(queryParameters))
1325	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1326}
1327
1328// ValidateMoveResourcesSender sends the ValidateMoveResources request. The method will close the
1329// http.Response Body if it receives an error.
1330func (client Client) ValidateMoveResourcesSender(req *http.Request) (future ValidateMoveResourcesFuture, err error) {
1331	var resp *http.Response
1332	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1333	if err != nil {
1334		return
1335	}
1336	var azf azure.Future
1337	azf, err = azure.NewFutureFromResponse(resp)
1338	future.FutureAPI = &azf
1339	future.Result = future.result
1340	return
1341}
1342
1343// ValidateMoveResourcesResponder handles the response to the ValidateMoveResources request. The method always
1344// closes the http.Response Body.
1345func (client Client) ValidateMoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) {
1346	err = autorest.Respond(
1347		resp,
1348		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusConflict),
1349		autorest.ByClosing())
1350	result.Response = resp
1351	return
1352}
1353