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