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