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'. When you filter by a tag name and value, the tags
728// for each resource are not returned in the results.<br><br>You can use some properties together when
729// filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and
730// plan/name, identity and identity/principalId.
731// expand - comma-separated list of additional properties to be included in the response. Valid values include
732// `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`.
733// top - the number of results to return. If null is passed, returns all resource groups.
734func (client Client) List(ctx context.Context, filter string, expand string, top *int32) (result ListResultPage, err error) {
735	if tracing.IsEnabled() {
736		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
737		defer func() {
738			sc := -1
739			if result.lr.Response.Response != nil {
740				sc = result.lr.Response.Response.StatusCode
741			}
742			tracing.EndSpan(ctx, sc, err)
743		}()
744	}
745	result.fn = client.listNextResults
746	req, err := client.ListPreparer(ctx, filter, expand, top)
747	if err != nil {
748		err = autorest.NewErrorWithError(err, "resources.Client", "List", nil, "Failure preparing request")
749		return
750	}
751
752	resp, err := client.ListSender(req)
753	if err != nil {
754		result.lr.Response = autorest.Response{Response: resp}
755		err = autorest.NewErrorWithError(err, "resources.Client", "List", resp, "Failure sending request")
756		return
757	}
758
759	result.lr, err = client.ListResponder(resp)
760	if err != nil {
761		err = autorest.NewErrorWithError(err, "resources.Client", "List", resp, "Failure responding to request")
762		return
763	}
764	if result.lr.hasNextLink() && result.lr.IsEmpty() {
765		err = result.NextWithContext(ctx)
766		return
767	}
768
769	return
770}
771
772// ListPreparer prepares the List request.
773func (client Client) ListPreparer(ctx context.Context, filter string, expand string, top *int32) (*http.Request, error) {
774	pathParameters := map[string]interface{}{
775		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
776	}
777
778	const APIVersion = "2019-10-01"
779	queryParameters := map[string]interface{}{
780		"api-version": APIVersion,
781	}
782	if len(filter) > 0 {
783		queryParameters["$filter"] = autorest.Encode("query", filter)
784	}
785	if len(expand) > 0 {
786		queryParameters["$expand"] = autorest.Encode("query", expand)
787	}
788	if top != nil {
789		queryParameters["$top"] = autorest.Encode("query", *top)
790	}
791
792	preparer := autorest.CreatePreparer(
793		autorest.AsGet(),
794		autorest.WithBaseURL(client.BaseURI),
795		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", pathParameters),
796		autorest.WithQueryParameters(queryParameters))
797	return preparer.Prepare((&http.Request{}).WithContext(ctx))
798}
799
800// ListSender sends the List request. The method will close the
801// http.Response Body if it receives an error.
802func (client Client) ListSender(req *http.Request) (*http.Response, error) {
803	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
804}
805
806// ListResponder handles the response to the List request. The method always
807// closes the http.Response Body.
808func (client Client) ListResponder(resp *http.Response) (result ListResult, err error) {
809	err = autorest.Respond(
810		resp,
811		azure.WithErrorUnlessStatusCode(http.StatusOK),
812		autorest.ByUnmarshallingJSON(&result),
813		autorest.ByClosing())
814	result.Response = autorest.Response{Response: resp}
815	return
816}
817
818// listNextResults retrieves the next set of results, if any.
819func (client Client) listNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
820	req, err := lastResults.listResultPreparer(ctx)
821	if err != nil {
822		return result, autorest.NewErrorWithError(err, "resources.Client", "listNextResults", nil, "Failure preparing next results request")
823	}
824	if req == nil {
825		return
826	}
827	resp, err := client.ListSender(req)
828	if err != nil {
829		result.Response = autorest.Response{Response: resp}
830		return result, autorest.NewErrorWithError(err, "resources.Client", "listNextResults", resp, "Failure sending next results request")
831	}
832	result, err = client.ListResponder(resp)
833	if err != nil {
834		err = autorest.NewErrorWithError(err, "resources.Client", "listNextResults", resp, "Failure responding to next results request")
835	}
836	return
837}
838
839// ListComplete enumerates all values, automatically crossing page boundaries as required.
840func (client Client) ListComplete(ctx context.Context, filter string, expand string, top *int32) (result ListResultIterator, err error) {
841	if tracing.IsEnabled() {
842		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
843		defer func() {
844			sc := -1
845			if result.Response().Response.Response != nil {
846				sc = result.page.Response().Response.Response.StatusCode
847			}
848			tracing.EndSpan(ctx, sc, err)
849		}()
850	}
851	result.page, err = client.List(ctx, filter, expand, top)
852	return
853}
854
855// ListByResourceGroup get all the resources for a resource group.
856// Parameters:
857// resourceGroupName - the resource group with the resources to get.
858// filter - the filter to apply on the operation.<br><br>The properties you can use for eq (equals) or ne (not
859// equals) are: location, resourceType, name, resourceGroup, identity, identity/principalId, plan,
860// plan/publisher, plan/product, plan/name, plan/version, and plan/promotionCode.<br><br>For example, to filter
861// by a resource type, use: $filter=resourceType eq 'Microsoft.Network/virtualNetworks'<br><br>You can use
862// substringof(value, property) in the filter. The properties you can use for substring are: name and
863// resourceGroup.<br><br>For example, to get all resources with 'demo' anywhere in the name, use:
864// $filter=substringof('demo', name)<br><br>You can link more than one substringof together by adding and/or
865// operators.<br><br>You can filter by tag names and values. For example, to filter for a tag name and value,
866// use $filter=tagName eq 'tag1' and tagValue eq 'Value1'. When you filter by a tag name and value, the tags
867// for each resource are not returned in the results.<br><br>You can use some properties together when
868// filtering. The combinations you can use are: substringof and/or resourceType, plan and plan/publisher and
869// plan/name, identity and identity/principalId.
870// expand - comma-separated list of additional properties to be included in the response. Valid values include
871// `createdTime`, `changedTime` and `provisioningState`. For example, `$expand=createdTime,changedTime`.
872// top - the number of results to return. If null is passed, returns all resources.
873func (client Client) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultPage, err error) {
874	if tracing.IsEnabled() {
875		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
876		defer func() {
877			sc := -1
878			if result.lr.Response.Response != nil {
879				sc = result.lr.Response.Response.StatusCode
880			}
881			tracing.EndSpan(ctx, sc, err)
882		}()
883	}
884	if err := validation.Validate([]validation.Validation{
885		{TargetValue: resourceGroupName,
886			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
887				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
888				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
889		return result, validation.NewError("resources.Client", "ListByResourceGroup", err.Error())
890	}
891
892	result.fn = client.listByResourceGroupNextResults
893	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, expand, top)
894	if err != nil {
895		err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", nil, "Failure preparing request")
896		return
897	}
898
899	resp, err := client.ListByResourceGroupSender(req)
900	if err != nil {
901		result.lr.Response = autorest.Response{Response: resp}
902		err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", resp, "Failure sending request")
903		return
904	}
905
906	result.lr, err = client.ListByResourceGroupResponder(resp)
907	if err != nil {
908		err = autorest.NewErrorWithError(err, "resources.Client", "ListByResourceGroup", resp, "Failure responding to request")
909		return
910	}
911	if result.lr.hasNextLink() && result.lr.IsEmpty() {
912		err = result.NextWithContext(ctx)
913		return
914	}
915
916	return
917}
918
919// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
920func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (*http.Request, error) {
921	pathParameters := map[string]interface{}{
922		"resourceGroupName": autorest.Encode("path", resourceGroupName),
923		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
924	}
925
926	const APIVersion = "2019-10-01"
927	queryParameters := map[string]interface{}{
928		"api-version": APIVersion,
929	}
930	if len(filter) > 0 {
931		queryParameters["$filter"] = autorest.Encode("query", filter)
932	}
933	if len(expand) > 0 {
934		queryParameters["$expand"] = autorest.Encode("query", expand)
935	}
936	if top != nil {
937		queryParameters["$top"] = autorest.Encode("query", *top)
938	}
939
940	preparer := autorest.CreatePreparer(
941		autorest.AsGet(),
942		autorest.WithBaseURL(client.BaseURI),
943		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/resources", pathParameters),
944		autorest.WithQueryParameters(queryParameters))
945	return preparer.Prepare((&http.Request{}).WithContext(ctx))
946}
947
948// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
949// http.Response Body if it receives an error.
950func (client Client) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
951	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
952}
953
954// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
955// closes the http.Response Body.
956func (client Client) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) {
957	err = autorest.Respond(
958		resp,
959		azure.WithErrorUnlessStatusCode(http.StatusOK),
960		autorest.ByUnmarshallingJSON(&result),
961		autorest.ByClosing())
962	result.Response = autorest.Response{Response: resp}
963	return
964}
965
966// listByResourceGroupNextResults retrieves the next set of results, if any.
967func (client Client) listByResourceGroupNextResults(ctx context.Context, lastResults ListResult) (result ListResult, err error) {
968	req, err := lastResults.listResultPreparer(ctx)
969	if err != nil {
970		return result, autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
971	}
972	if req == nil {
973		return
974	}
975	resp, err := client.ListByResourceGroupSender(req)
976	if err != nil {
977		result.Response = autorest.Response{Response: resp}
978		return result, autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", resp, "Failure sending next results request")
979	}
980	result, err = client.ListByResourceGroupResponder(resp)
981	if err != nil {
982		err = autorest.NewErrorWithError(err, "resources.Client", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
983	}
984	return
985}
986
987// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
988func (client Client) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, expand string, top *int32) (result ListResultIterator, err error) {
989	if tracing.IsEnabled() {
990		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ListByResourceGroup")
991		defer func() {
992			sc := -1
993			if result.Response().Response.Response != nil {
994				sc = result.page.Response().Response.Response.StatusCode
995			}
996			tracing.EndSpan(ctx, sc, err)
997		}()
998	}
999	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, expand, top)
1000	return
1001}
1002
1003// MoveResources the resources to move must be in the same source resource group. The target resource group may be in a
1004// different subscription. When moving resources, both the source group and the target group are locked for the
1005// duration of the operation. Write and delete operations are blocked on the groups until the move completes.
1006// Parameters:
1007// sourceResourceGroupName - the name of the resource group containing the resources to move.
1008// parameters - parameters for moving resources.
1009func (client Client) MoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (result MoveResourcesFuture, err error) {
1010	if tracing.IsEnabled() {
1011		ctx = tracing.StartSpan(ctx, fqdn+"/Client.MoveResources")
1012		defer func() {
1013			sc := -1
1014			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1015				sc = result.FutureAPI.Response().StatusCode
1016			}
1017			tracing.EndSpan(ctx, sc, err)
1018		}()
1019	}
1020	if err := validation.Validate([]validation.Validation{
1021		{TargetValue: sourceResourceGroupName,
1022			Constraints: []validation.Constraint{{Target: "sourceResourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1023				{Target: "sourceResourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1024				{Target: "sourceResourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
1025		return result, validation.NewError("resources.Client", "MoveResources", err.Error())
1026	}
1027
1028	req, err := client.MoveResourcesPreparer(ctx, sourceResourceGroupName, parameters)
1029	if err != nil {
1030		err = autorest.NewErrorWithError(err, "resources.Client", "MoveResources", nil, "Failure preparing request")
1031		return
1032	}
1033
1034	result, err = client.MoveResourcesSender(req)
1035	if err != nil {
1036		err = autorest.NewErrorWithError(err, "resources.Client", "MoveResources", nil, "Failure sending request")
1037		return
1038	}
1039
1040	return
1041}
1042
1043// MoveResourcesPreparer prepares the MoveResources request.
1044func (client Client) MoveResourcesPreparer(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (*http.Request, error) {
1045	pathParameters := map[string]interface{}{
1046		"sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName),
1047		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
1048	}
1049
1050	const APIVersion = "2019-10-01"
1051	queryParameters := map[string]interface{}{
1052		"api-version": APIVersion,
1053	}
1054
1055	preparer := autorest.CreatePreparer(
1056		autorest.AsContentType("application/json; charset=utf-8"),
1057		autorest.AsPost(),
1058		autorest.WithBaseURL(client.BaseURI),
1059		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/moveResources", pathParameters),
1060		autorest.WithJSON(parameters),
1061		autorest.WithQueryParameters(queryParameters))
1062	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1063}
1064
1065// MoveResourcesSender sends the MoveResources request. The method will close the
1066// http.Response Body if it receives an error.
1067func (client Client) MoveResourcesSender(req *http.Request) (future MoveResourcesFuture, err error) {
1068	var resp *http.Response
1069	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1070	if err != nil {
1071		return
1072	}
1073	var azf azure.Future
1074	azf, err = azure.NewFutureFromResponse(resp)
1075	future.FutureAPI = &azf
1076	future.Result = future.result
1077	return
1078}
1079
1080// MoveResourcesResponder handles the response to the MoveResources request. The method always
1081// closes the http.Response Body.
1082func (client Client) MoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) {
1083	err = autorest.Respond(
1084		resp,
1085		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
1086		autorest.ByClosing())
1087	result.Response = resp
1088	return
1089}
1090
1091// Update updates a resource.
1092// Parameters:
1093// resourceGroupName - the name of the resource group for the resource. The name is case insensitive.
1094// resourceProviderNamespace - the namespace of the resource provider.
1095// parentResourcePath - the parent resource identity.
1096// resourceType - the resource type of the resource to update.
1097// resourceName - the name of the resource to update.
1098// APIVersion - the API version to use for the operation.
1099// parameters - parameters for updating the resource.
1100func (client Client) Update(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (result UpdateFuture, err error) {
1101	if tracing.IsEnabled() {
1102		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update")
1103		defer func() {
1104			sc := -1
1105			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1106				sc = result.FutureAPI.Response().StatusCode
1107			}
1108			tracing.EndSpan(ctx, sc, err)
1109		}()
1110	}
1111	if err := validation.Validate([]validation.Validation{
1112		{TargetValue: resourceGroupName,
1113			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1114				{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1115				{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
1116		return result, validation.NewError("resources.Client", "Update", err.Error())
1117	}
1118
1119	req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName, APIVersion, parameters)
1120	if err != nil {
1121		err = autorest.NewErrorWithError(err, "resources.Client", "Update", nil, "Failure preparing request")
1122		return
1123	}
1124
1125	result, err = client.UpdateSender(req)
1126	if err != nil {
1127		err = autorest.NewErrorWithError(err, "resources.Client", "Update", nil, "Failure sending request")
1128		return
1129	}
1130
1131	return
1132}
1133
1134// UpdatePreparer prepares the Update request.
1135func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string, APIVersion string, parameters GenericResource) (*http.Request, error) {
1136	pathParameters := map[string]interface{}{
1137		"parentResourcePath":        parentResourcePath,
1138		"resourceGroupName":         autorest.Encode("path", resourceGroupName),
1139		"resourceName":              autorest.Encode("path", resourceName),
1140		"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
1141		"resourceType":              resourceType,
1142		"subscriptionId":            autorest.Encode("path", client.SubscriptionID),
1143	}
1144
1145	queryParameters := map[string]interface{}{
1146		"api-version": APIVersion,
1147	}
1148
1149	preparer := autorest.CreatePreparer(
1150		autorest.AsContentType("application/json; charset=utf-8"),
1151		autorest.AsPatch(),
1152		autorest.WithBaseURL(client.BaseURI),
1153		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}", pathParameters),
1154		autorest.WithJSON(parameters),
1155		autorest.WithQueryParameters(queryParameters))
1156	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1157}
1158
1159// UpdateSender sends the Update request. The method will close the
1160// http.Response Body if it receives an error.
1161func (client Client) UpdateSender(req *http.Request) (future UpdateFuture, err error) {
1162	var resp *http.Response
1163	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1164	if err != nil {
1165		return
1166	}
1167	var azf azure.Future
1168	azf, err = azure.NewFutureFromResponse(resp)
1169	future.FutureAPI = &azf
1170	future.Result = future.result
1171	return
1172}
1173
1174// UpdateResponder handles the response to the Update request. The method always
1175// closes the http.Response Body.
1176func (client Client) UpdateResponder(resp *http.Response) (result GenericResource, err error) {
1177	err = autorest.Respond(
1178		resp,
1179		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1180		autorest.ByUnmarshallingJSON(&result),
1181		autorest.ByClosing())
1182	result.Response = autorest.Response{Response: resp}
1183	return
1184}
1185
1186// UpdateByID updates a resource by ID.
1187// Parameters:
1188// resourceID - the fully qualified ID of the resource, including the resource name and resource type. Use the
1189// format,
1190// /subscriptions/{guid}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
1191// APIVersion - the API version to use for the operation.
1192// parameters - update resource parameters.
1193func (client Client) UpdateByID(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (result UpdateByIDFuture, err error) {
1194	if tracing.IsEnabled() {
1195		ctx = tracing.StartSpan(ctx, fqdn+"/Client.UpdateByID")
1196		defer func() {
1197			sc := -1
1198			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1199				sc = result.FutureAPI.Response().StatusCode
1200			}
1201			tracing.EndSpan(ctx, sc, err)
1202		}()
1203	}
1204	req, err := client.UpdateByIDPreparer(ctx, resourceID, APIVersion, parameters)
1205	if err != nil {
1206		err = autorest.NewErrorWithError(err, "resources.Client", "UpdateByID", nil, "Failure preparing request")
1207		return
1208	}
1209
1210	result, err = client.UpdateByIDSender(req)
1211	if err != nil {
1212		err = autorest.NewErrorWithError(err, "resources.Client", "UpdateByID", nil, "Failure sending request")
1213		return
1214	}
1215
1216	return
1217}
1218
1219// UpdateByIDPreparer prepares the UpdateByID request.
1220func (client Client) UpdateByIDPreparer(ctx context.Context, resourceID string, APIVersion string, parameters GenericResource) (*http.Request, error) {
1221	pathParameters := map[string]interface{}{
1222		"resourceId": resourceID,
1223	}
1224
1225	queryParameters := map[string]interface{}{
1226		"api-version": APIVersion,
1227	}
1228
1229	preparer := autorest.CreatePreparer(
1230		autorest.AsContentType("application/json; charset=utf-8"),
1231		autorest.AsPatch(),
1232		autorest.WithBaseURL(client.BaseURI),
1233		autorest.WithPathParameters("/{resourceId}", pathParameters),
1234		autorest.WithJSON(parameters),
1235		autorest.WithQueryParameters(queryParameters))
1236	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1237}
1238
1239// UpdateByIDSender sends the UpdateByID request. The method will close the
1240// http.Response Body if it receives an error.
1241func (client Client) UpdateByIDSender(req *http.Request) (future UpdateByIDFuture, err error) {
1242	var resp *http.Response
1243	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
1244	if err != nil {
1245		return
1246	}
1247	var azf azure.Future
1248	azf, err = azure.NewFutureFromResponse(resp)
1249	future.FutureAPI = &azf
1250	future.Result = future.result
1251	return
1252}
1253
1254// UpdateByIDResponder handles the response to the UpdateByID request. The method always
1255// closes the http.Response Body.
1256func (client Client) UpdateByIDResponder(resp *http.Response) (result GenericResource, err error) {
1257	err = autorest.Respond(
1258		resp,
1259		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1260		autorest.ByUnmarshallingJSON(&result),
1261		autorest.ByClosing())
1262	result.Response = autorest.Response{Response: resp}
1263	return
1264}
1265
1266// ValidateMoveResources this operation checks whether the specified resources can be moved to the target. The
1267// resources to move must be in the same source resource group. The target resource group may be in a different
1268// subscription. If validation succeeds, it returns HTTP response code 204 (no content). If validation fails, it
1269// returns HTTP response code 409 (Conflict) with an error message. Retrieve the URL in the Location header value to
1270// check the result of the long-running operation.
1271// Parameters:
1272// sourceResourceGroupName - the name of the resource group containing the resources to validate for move.
1273// parameters - parameters for moving resources.
1274func (client Client) ValidateMoveResources(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (result ValidateMoveResourcesFuture, err error) {
1275	if tracing.IsEnabled() {
1276		ctx = tracing.StartSpan(ctx, fqdn+"/Client.ValidateMoveResources")
1277		defer func() {
1278			sc := -1
1279			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1280				sc = result.FutureAPI.Response().StatusCode
1281			}
1282			tracing.EndSpan(ctx, sc, err)
1283		}()
1284	}
1285	if err := validation.Validate([]validation.Validation{
1286		{TargetValue: sourceResourceGroupName,
1287			Constraints: []validation.Constraint{{Target: "sourceResourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
1288				{Target: "sourceResourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
1289				{Target: "sourceResourceGroupName", Name: validation.Pattern, Rule: `^[-\p{L}\._\(\)\w]+$`, Chain: nil}}}}); err != nil {
1290		return result, validation.NewError("resources.Client", "ValidateMoveResources", err.Error())
1291	}
1292
1293	req, err := client.ValidateMoveResourcesPreparer(ctx, sourceResourceGroupName, parameters)
1294	if err != nil {
1295		err = autorest.NewErrorWithError(err, "resources.Client", "ValidateMoveResources", nil, "Failure preparing request")
1296		return
1297	}
1298
1299	result, err = client.ValidateMoveResourcesSender(req)
1300	if err != nil {
1301		err = autorest.NewErrorWithError(err, "resources.Client", "ValidateMoveResources", nil, "Failure sending request")
1302		return
1303	}
1304
1305	return
1306}
1307
1308// ValidateMoveResourcesPreparer prepares the ValidateMoveResources request.
1309func (client Client) ValidateMoveResourcesPreparer(ctx context.Context, sourceResourceGroupName string, parameters MoveInfo) (*http.Request, error) {
1310	pathParameters := map[string]interface{}{
1311		"sourceResourceGroupName": autorest.Encode("path", sourceResourceGroupName),
1312		"subscriptionId":          autorest.Encode("path", client.SubscriptionID),
1313	}
1314
1315	const APIVersion = "2019-10-01"
1316	queryParameters := map[string]interface{}{
1317		"api-version": APIVersion,
1318	}
1319
1320	preparer := autorest.CreatePreparer(
1321		autorest.AsContentType("application/json; charset=utf-8"),
1322		autorest.AsPost(),
1323		autorest.WithBaseURL(client.BaseURI),
1324		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{sourceResourceGroupName}/validateMoveResources", pathParameters),
1325		autorest.WithJSON(parameters),
1326		autorest.WithQueryParameters(queryParameters))
1327	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1328}
1329
1330// ValidateMoveResourcesSender sends the ValidateMoveResources request. The method will close the
1331// http.Response Body if it receives an error.
1332func (client Client) ValidateMoveResourcesSender(req *http.Request) (future ValidateMoveResourcesFuture, err error) {
1333	var resp *http.Response
1334	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1335	if err != nil {
1336		return
1337	}
1338	var azf azure.Future
1339	azf, err = azure.NewFutureFromResponse(resp)
1340	future.FutureAPI = &azf
1341	future.Result = future.result
1342	return
1343}
1344
1345// ValidateMoveResourcesResponder handles the response to the ValidateMoveResources request. The method always
1346// closes the http.Response Body.
1347func (client Client) ValidateMoveResourcesResponder(resp *http.Response) (result autorest.Response, err error) {
1348	err = autorest.Respond(
1349		resp,
1350		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
1351		autorest.ByClosing())
1352	result.Response = resp
1353	return
1354}
1355