1package maps
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// AccountsClient is the resource Provider
19type AccountsClient struct {
20	BaseClient
21}
22
23// NewAccountsClient creates an instance of the AccountsClient client.
24func NewAccountsClient(subscriptionID string) AccountsClient {
25	return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client using a custom endpoint.  Use this
29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient {
31	return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CreateOrUpdate create or update a Maps Account. A Maps Account holds the keys which allow access to the Maps REST
35// APIs.
36// Parameters:
37// resourceGroupName - the name of the Azure Resource Group.
38// accountName - the name of the Maps Account.
39// mapsAccountCreateParameters - the new or updated parameters for the Maps Account.
40func (client AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, mapsAccountCreateParameters AccountCreateParameters) (result Account, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CreateOrUpdate")
43		defer func() {
44			sc := -1
45			if result.Response.Response != nil {
46				sc = result.Response.Response.StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: mapsAccountCreateParameters,
53			Constraints: []validation.Constraint{{Target: "mapsAccountCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil},
54				{Target: "mapsAccountCreateParameters.Sku", Name: validation.Null, Rule: true,
55					Chain: []validation.Constraint{{Target: "mapsAccountCreateParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
56		return result, validation.NewError("maps.AccountsClient", "CreateOrUpdate", err.Error())
57	}
58
59	req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, mapsAccountCreateParameters)
60	if err != nil {
61		err = autorest.NewErrorWithError(err, "maps.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, "maps.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, "maps.AccountsClient", "CreateOrUpdate", resp, "Failure responding to request")
75		return
76	}
77
78	return
79}
80
81// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
82func (client AccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, mapsAccountCreateParameters AccountCreateParameters) (*http.Request, error) {
83	pathParameters := map[string]interface{}{
84		"accountName":       autorest.Encode("path", accountName),
85		"resourceGroupName": autorest.Encode("path", resourceGroupName),
86		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
87	}
88
89	const APIVersion = "2017-01-01-preview"
90	queryParameters := map[string]interface{}{
91		"api-version": APIVersion,
92	}
93
94	preparer := autorest.CreatePreparer(
95		autorest.AsContentType("application/json; charset=utf-8"),
96		autorest.AsPut(),
97		autorest.WithBaseURL(client.BaseURI),
98		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters),
99		autorest.WithJSON(mapsAccountCreateParameters),
100		autorest.WithQueryParameters(queryParameters))
101	return preparer.Prepare((&http.Request{}).WithContext(ctx))
102}
103
104// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
105// http.Response Body if it receives an error.
106func (client AccountsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
107	return client.Send(req, 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 Account, err error) {
113	err = autorest.Respond(
114		resp,
115		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
116		autorest.ByUnmarshallingJSON(&result),
117		autorest.ByClosing())
118	result.Response = autorest.Response{Response: resp}
119	return
120}
121
122// Delete delete a Maps Account.
123// Parameters:
124// resourceGroupName - the name of the Azure Resource Group.
125// accountName - the name of the Maps Account.
126func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) {
127	if tracing.IsEnabled() {
128		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete")
129		defer func() {
130			sc := -1
131			if result.Response != nil {
132				sc = result.Response.StatusCode
133			}
134			tracing.EndSpan(ctx, sc, err)
135		}()
136	}
137	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName)
138	if err != nil {
139		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", nil, "Failure preparing request")
140		return
141	}
142
143	resp, err := client.DeleteSender(req)
144	if err != nil {
145		result.Response = resp
146		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", resp, "Failure sending request")
147		return
148	}
149
150	result, err = client.DeleteResponder(resp)
151	if err != nil {
152		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Delete", resp, "Failure responding to request")
153		return
154	}
155
156	return
157}
158
159// DeletePreparer prepares the Delete request.
160func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
161	pathParameters := map[string]interface{}{
162		"accountName":       autorest.Encode("path", accountName),
163		"resourceGroupName": autorest.Encode("path", resourceGroupName),
164		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
165	}
166
167	const APIVersion = "2017-01-01-preview"
168	queryParameters := map[string]interface{}{
169		"api-version": APIVersion,
170	}
171
172	preparer := autorest.CreatePreparer(
173		autorest.AsDelete(),
174		autorest.WithBaseURL(client.BaseURI),
175		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters),
176		autorest.WithQueryParameters(queryParameters))
177	return preparer.Prepare((&http.Request{}).WithContext(ctx))
178}
179
180// DeleteSender sends the Delete request. The method will close the
181// http.Response Body if it receives an error.
182func (client AccountsClient) DeleteSender(req *http.Request) (*http.Response, error) {
183	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
184}
185
186// DeleteResponder handles the response to the Delete request. The method always
187// closes the http.Response Body.
188func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
189	err = autorest.Respond(
190		resp,
191		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
192		autorest.ByClosing())
193	result.Response = resp
194	return
195}
196
197// Get get a Maps Account.
198// Parameters:
199// resourceGroupName - the name of the Azure Resource Group.
200// accountName - the name of the Maps Account.
201func (client AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) {
202	if tracing.IsEnabled() {
203		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get")
204		defer func() {
205			sc := -1
206			if result.Response.Response != nil {
207				sc = result.Response.Response.StatusCode
208			}
209			tracing.EndSpan(ctx, sc, err)
210		}()
211	}
212	req, err := client.GetPreparer(ctx, resourceGroupName, accountName)
213	if err != nil {
214		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", nil, "Failure preparing request")
215		return
216	}
217
218	resp, err := client.GetSender(req)
219	if err != nil {
220		result.Response = autorest.Response{Response: resp}
221		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", resp, "Failure sending request")
222		return
223	}
224
225	result, err = client.GetResponder(resp)
226	if err != nil {
227		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Get", resp, "Failure responding to request")
228		return
229	}
230
231	return
232}
233
234// GetPreparer prepares the Get request.
235func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
236	pathParameters := map[string]interface{}{
237		"accountName":       autorest.Encode("path", accountName),
238		"resourceGroupName": autorest.Encode("path", resourceGroupName),
239		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
240	}
241
242	const APIVersion = "2017-01-01-preview"
243	queryParameters := map[string]interface{}{
244		"api-version": APIVersion,
245	}
246
247	preparer := autorest.CreatePreparer(
248		autorest.AsGet(),
249		autorest.WithBaseURL(client.BaseURI),
250		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters),
251		autorest.WithQueryParameters(queryParameters))
252	return preparer.Prepare((&http.Request{}).WithContext(ctx))
253}
254
255// GetSender sends the Get request. The method will close the
256// http.Response Body if it receives an error.
257func (client AccountsClient) GetSender(req *http.Request) (*http.Response, error) {
258	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
259}
260
261// GetResponder handles the response to the Get request. The method always
262// closes the http.Response Body.
263func (client AccountsClient) GetResponder(resp *http.Response) (result Account, err error) {
264	err = autorest.Respond(
265		resp,
266		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
267		autorest.ByUnmarshallingJSON(&result),
268		autorest.ByClosing())
269	result.Response = autorest.Response{Response: resp}
270	return
271}
272
273// ListByResourceGroup get all Maps Accounts in a Resource Group
274// Parameters:
275// resourceGroupName - the name of the Azure Resource Group.
276func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result Accounts, err error) {
277	if tracing.IsEnabled() {
278		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup")
279		defer func() {
280			sc := -1
281			if result.Response.Response != nil {
282				sc = result.Response.Response.StatusCode
283			}
284			tracing.EndSpan(ctx, sc, err)
285		}()
286	}
287	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
288	if err != nil {
289		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request")
290		return
291	}
292
293	resp, err := client.ListByResourceGroupSender(req)
294	if err != nil {
295		result.Response = autorest.Response{Response: resp}
296		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", resp, "Failure sending request")
297		return
298	}
299
300	result, err = client.ListByResourceGroupResponder(resp)
301	if err != nil {
302		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request")
303		return
304	}
305
306	return
307}
308
309// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
310func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
311	pathParameters := map[string]interface{}{
312		"resourceGroupName": autorest.Encode("path", resourceGroupName),
313		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
314	}
315
316	const APIVersion = "2017-01-01-preview"
317	queryParameters := map[string]interface{}{
318		"api-version": APIVersion,
319	}
320
321	preparer := autorest.CreatePreparer(
322		autorest.AsGet(),
323		autorest.WithBaseURL(client.BaseURI),
324		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts", pathParameters),
325		autorest.WithQueryParameters(queryParameters))
326	return preparer.Prepare((&http.Request{}).WithContext(ctx))
327}
328
329// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
330// http.Response Body if it receives an error.
331func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
332	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
333}
334
335// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
336// closes the http.Response Body.
337func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result Accounts, err error) {
338	err = autorest.Respond(
339		resp,
340		azure.WithErrorUnlessStatusCode(http.StatusOK),
341		autorest.ByUnmarshallingJSON(&result),
342		autorest.ByClosing())
343	result.Response = autorest.Response{Response: resp}
344	return
345}
346
347// ListBySubscription get all Maps Accounts in a Subscription
348func (client AccountsClient) ListBySubscription(ctx context.Context) (result Accounts, err error) {
349	if tracing.IsEnabled() {
350		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListBySubscription")
351		defer func() {
352			sc := -1
353			if result.Response.Response != nil {
354				sc = result.Response.Response.StatusCode
355			}
356			tracing.EndSpan(ctx, sc, err)
357		}()
358	}
359	req, err := client.ListBySubscriptionPreparer(ctx)
360	if err != nil {
361		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", nil, "Failure preparing request")
362		return
363	}
364
365	resp, err := client.ListBySubscriptionSender(req)
366	if err != nil {
367		result.Response = autorest.Response{Response: resp}
368		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", resp, "Failure sending request")
369		return
370	}
371
372	result, err = client.ListBySubscriptionResponder(resp)
373	if err != nil {
374		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListBySubscription", resp, "Failure responding to request")
375		return
376	}
377
378	return
379}
380
381// ListBySubscriptionPreparer prepares the ListBySubscription request.
382func (client AccountsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
383	pathParameters := map[string]interface{}{
384		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
385	}
386
387	const APIVersion = "2017-01-01-preview"
388	queryParameters := map[string]interface{}{
389		"api-version": APIVersion,
390	}
391
392	preparer := autorest.CreatePreparer(
393		autorest.AsGet(),
394		autorest.WithBaseURL(client.BaseURI),
395		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Maps/accounts", pathParameters),
396		autorest.WithQueryParameters(queryParameters))
397	return preparer.Prepare((&http.Request{}).WithContext(ctx))
398}
399
400// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
401// http.Response Body if it receives an error.
402func (client AccountsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
403	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
404}
405
406// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
407// closes the http.Response Body.
408func (client AccountsClient) ListBySubscriptionResponder(resp *http.Response) (result Accounts, err error) {
409	err = autorest.Respond(
410		resp,
411		azure.WithErrorUnlessStatusCode(http.StatusOK),
412		autorest.ByUnmarshallingJSON(&result),
413		autorest.ByClosing())
414	result.Response = autorest.Response{Response: resp}
415	return
416}
417
418// ListKeys get the keys to use with the Maps APIs. A key is used to authenticate and authorize access to the Maps REST
419// APIs. Only one key is needed at a time; two are given to provide seamless key regeneration.
420// Parameters:
421// resourceGroupName - the name of the Azure Resource Group.
422// accountName - the name of the Maps Account.
423func (client AccountsClient) ListKeys(ctx context.Context, resourceGroupName string, accountName string) (result AccountKeys, err error) {
424	if tracing.IsEnabled() {
425		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListKeys")
426		defer func() {
427			sc := -1
428			if result.Response.Response != nil {
429				sc = result.Response.Response.StatusCode
430			}
431			tracing.EndSpan(ctx, sc, err)
432		}()
433	}
434	req, err := client.ListKeysPreparer(ctx, resourceGroupName, accountName)
435	if err != nil {
436		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", nil, "Failure preparing request")
437		return
438	}
439
440	resp, err := client.ListKeysSender(req)
441	if err != nil {
442		result.Response = autorest.Response{Response: resp}
443		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", resp, "Failure sending request")
444		return
445	}
446
447	result, err = client.ListKeysResponder(resp)
448	if err != nil {
449		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListKeys", resp, "Failure responding to request")
450		return
451	}
452
453	return
454}
455
456// ListKeysPreparer prepares the ListKeys request.
457func (client AccountsClient) ListKeysPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
458	pathParameters := map[string]interface{}{
459		"accountName":       autorest.Encode("path", accountName),
460		"resourceGroupName": autorest.Encode("path", resourceGroupName),
461		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
462	}
463
464	const APIVersion = "2017-01-01-preview"
465	queryParameters := map[string]interface{}{
466		"api-version": APIVersion,
467	}
468
469	preparer := autorest.CreatePreparer(
470		autorest.AsPost(),
471		autorest.WithBaseURL(client.BaseURI),
472		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/listKeys", pathParameters),
473		autorest.WithQueryParameters(queryParameters))
474	return preparer.Prepare((&http.Request{}).WithContext(ctx))
475}
476
477// ListKeysSender sends the ListKeys request. The method will close the
478// http.Response Body if it receives an error.
479func (client AccountsClient) ListKeysSender(req *http.Request) (*http.Response, error) {
480	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
481}
482
483// ListKeysResponder handles the response to the ListKeys request. The method always
484// closes the http.Response Body.
485func (client AccountsClient) ListKeysResponder(resp *http.Response) (result AccountKeys, err error) {
486	err = autorest.Respond(
487		resp,
488		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
489		autorest.ByUnmarshallingJSON(&result),
490		autorest.ByClosing())
491	result.Response = autorest.Response{Response: resp}
492	return
493}
494
495// ListOperations list operations available for the Maps Resource Provider
496func (client AccountsClient) ListOperations(ctx context.Context) (result Operations, err error) {
497	if tracing.IsEnabled() {
498		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListOperations")
499		defer func() {
500			sc := -1
501			if result.Response.Response != nil {
502				sc = result.Response.Response.StatusCode
503			}
504			tracing.EndSpan(ctx, sc, err)
505		}()
506	}
507	req, err := client.ListOperationsPreparer(ctx)
508	if err != nil {
509		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", nil, "Failure preparing request")
510		return
511	}
512
513	resp, err := client.ListOperationsSender(req)
514	if err != nil {
515		result.Response = autorest.Response{Response: resp}
516		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", resp, "Failure sending request")
517		return
518	}
519
520	result, err = client.ListOperationsResponder(resp)
521	if err != nil {
522		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "ListOperations", resp, "Failure responding to request")
523		return
524	}
525
526	return
527}
528
529// ListOperationsPreparer prepares the ListOperations request.
530func (client AccountsClient) ListOperationsPreparer(ctx context.Context) (*http.Request, error) {
531	const APIVersion = "2017-01-01-preview"
532	queryParameters := map[string]interface{}{
533		"api-version": APIVersion,
534	}
535
536	preparer := autorest.CreatePreparer(
537		autorest.AsGet(),
538		autorest.WithBaseURL(client.BaseURI),
539		autorest.WithPath("/providers/Microsoft.Maps/operations"),
540		autorest.WithQueryParameters(queryParameters))
541	return preparer.Prepare((&http.Request{}).WithContext(ctx))
542}
543
544// ListOperationsSender sends the ListOperations request. The method will close the
545// http.Response Body if it receives an error.
546func (client AccountsClient) ListOperationsSender(req *http.Request) (*http.Response, error) {
547	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
548}
549
550// ListOperationsResponder handles the response to the ListOperations request. The method always
551// closes the http.Response Body.
552func (client AccountsClient) ListOperationsResponder(resp *http.Response) (result Operations, err error) {
553	err = autorest.Respond(
554		resp,
555		azure.WithErrorUnlessStatusCode(http.StatusOK),
556		autorest.ByUnmarshallingJSON(&result),
557		autorest.ByClosing())
558	result.Response = autorest.Response{Response: resp}
559	return
560}
561
562// Move moves Maps Accounts from one ResourceGroup (or Subscription) to another
563// Parameters:
564// resourceGroupName - the name of the resource group that contains Maps Account to move.
565// moveRequest - the details of the Maps Account move.
566func (client AccountsClient) Move(ctx context.Context, resourceGroupName string, moveRequest AccountsMoveRequest) (result autorest.Response, err error) {
567	if tracing.IsEnabled() {
568		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Move")
569		defer func() {
570			sc := -1
571			if result.Response != nil {
572				sc = result.Response.StatusCode
573			}
574			tracing.EndSpan(ctx, sc, err)
575		}()
576	}
577	if err := validation.Validate([]validation.Validation{
578		{TargetValue: moveRequest,
579			Constraints: []validation.Constraint{{Target: "moveRequest.TargetResourceGroup", Name: validation.Null, Rule: true, Chain: nil},
580				{Target: "moveRequest.ResourceIds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
581		return result, validation.NewError("maps.AccountsClient", "Move", err.Error())
582	}
583
584	req, err := client.MovePreparer(ctx, resourceGroupName, moveRequest)
585	if err != nil {
586		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", nil, "Failure preparing request")
587		return
588	}
589
590	resp, err := client.MoveSender(req)
591	if err != nil {
592		result.Response = resp
593		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", resp, "Failure sending request")
594		return
595	}
596
597	result, err = client.MoveResponder(resp)
598	if err != nil {
599		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Move", resp, "Failure responding to request")
600		return
601	}
602
603	return
604}
605
606// MovePreparer prepares the Move request.
607func (client AccountsClient) MovePreparer(ctx context.Context, resourceGroupName string, moveRequest AccountsMoveRequest) (*http.Request, error) {
608	pathParameters := map[string]interface{}{
609		"resourceGroupName": autorest.Encode("path", resourceGroupName),
610		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
611	}
612
613	const APIVersion = "2017-01-01-preview"
614	queryParameters := map[string]interface{}{
615		"api-version": APIVersion,
616	}
617
618	preparer := autorest.CreatePreparer(
619		autorest.AsContentType("application/json; charset=utf-8"),
620		autorest.AsPost(),
621		autorest.WithBaseURL(client.BaseURI),
622		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources", pathParameters),
623		autorest.WithJSON(moveRequest),
624		autorest.WithQueryParameters(queryParameters))
625	return preparer.Prepare((&http.Request{}).WithContext(ctx))
626}
627
628// MoveSender sends the Move request. The method will close the
629// http.Response Body if it receives an error.
630func (client AccountsClient) MoveSender(req *http.Request) (*http.Response, error) {
631	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
632}
633
634// MoveResponder handles the response to the Move request. The method always
635// closes the http.Response Body.
636func (client AccountsClient) MoveResponder(resp *http.Response) (result autorest.Response, err error) {
637	err = autorest.Respond(
638		resp,
639		azure.WithErrorUnlessStatusCode(http.StatusOK),
640		autorest.ByClosing())
641	result.Response = resp
642	return
643}
644
645// RegenerateKeys regenerate either the primary or secondary key for use with the Maps APIs. The old key will stop
646// working immediately.
647// Parameters:
648// resourceGroupName - the name of the Azure Resource Group.
649// accountName - the name of the Maps Account.
650// keySpecification - which key to regenerate:  primary or secondary.
651func (client AccountsClient) RegenerateKeys(ctx context.Context, resourceGroupName string, accountName string, keySpecification KeySpecification) (result AccountKeys, err error) {
652	if tracing.IsEnabled() {
653		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.RegenerateKeys")
654		defer func() {
655			sc := -1
656			if result.Response.Response != nil {
657				sc = result.Response.Response.StatusCode
658			}
659			tracing.EndSpan(ctx, sc, err)
660		}()
661	}
662	req, err := client.RegenerateKeysPreparer(ctx, resourceGroupName, accountName, keySpecification)
663	if err != nil {
664		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", nil, "Failure preparing request")
665		return
666	}
667
668	resp, err := client.RegenerateKeysSender(req)
669	if err != nil {
670		result.Response = autorest.Response{Response: resp}
671		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", resp, "Failure sending request")
672		return
673	}
674
675	result, err = client.RegenerateKeysResponder(resp)
676	if err != nil {
677		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "RegenerateKeys", resp, "Failure responding to request")
678		return
679	}
680
681	return
682}
683
684// RegenerateKeysPreparer prepares the RegenerateKeys request.
685func (client AccountsClient) RegenerateKeysPreparer(ctx context.Context, resourceGroupName string, accountName string, keySpecification KeySpecification) (*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.AsPost(),
700		autorest.WithBaseURL(client.BaseURI),
701		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}/regenerateKey", pathParameters),
702		autorest.WithJSON(keySpecification),
703		autorest.WithQueryParameters(queryParameters))
704	return preparer.Prepare((&http.Request{}).WithContext(ctx))
705}
706
707// RegenerateKeysSender sends the RegenerateKeys request. The method will close the
708// http.Response Body if it receives an error.
709func (client AccountsClient) RegenerateKeysSender(req *http.Request) (*http.Response, error) {
710	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
711}
712
713// RegenerateKeysResponder handles the response to the RegenerateKeys request. The method always
714// closes the http.Response Body.
715func (client AccountsClient) RegenerateKeysResponder(resp *http.Response) (result AccountKeys, err error) {
716	err = autorest.Respond(
717		resp,
718		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
719		autorest.ByUnmarshallingJSON(&result),
720		autorest.ByClosing())
721	result.Response = autorest.Response{Response: resp}
722	return
723}
724
725// Update updates a Maps Account. Only a subset of the parameters may be updated after creation, such as Sku and Tags.
726// Parameters:
727// resourceGroupName - the name of the Azure Resource Group.
728// accountName - the name of the Maps Account.
729// mapsAccountUpdateParameters - the updated parameters for the Maps Account.
730func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters AccountUpdateParameters) (result Account, err error) {
731	if tracing.IsEnabled() {
732		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update")
733		defer func() {
734			sc := -1
735			if result.Response.Response != nil {
736				sc = result.Response.Response.StatusCode
737			}
738			tracing.EndSpan(ctx, sc, err)
739		}()
740	}
741	req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, mapsAccountUpdateParameters)
742	if err != nil {
743		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", nil, "Failure preparing request")
744		return
745	}
746
747	resp, err := client.UpdateSender(req)
748	if err != nil {
749		result.Response = autorest.Response{Response: resp}
750		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", resp, "Failure sending request")
751		return
752	}
753
754	result, err = client.UpdateResponder(resp)
755	if err != nil {
756		err = autorest.NewErrorWithError(err, "maps.AccountsClient", "Update", resp, "Failure responding to request")
757		return
758	}
759
760	return
761}
762
763// UpdatePreparer prepares the Update request.
764func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, mapsAccountUpdateParameters AccountUpdateParameters) (*http.Request, error) {
765	pathParameters := map[string]interface{}{
766		"accountName":       autorest.Encode("path", accountName),
767		"resourceGroupName": autorest.Encode("path", resourceGroupName),
768		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
769	}
770
771	const APIVersion = "2017-01-01-preview"
772	queryParameters := map[string]interface{}{
773		"api-version": APIVersion,
774	}
775
776	preparer := autorest.CreatePreparer(
777		autorest.AsContentType("application/json; charset=utf-8"),
778		autorest.AsPatch(),
779		autorest.WithBaseURL(client.BaseURI),
780		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maps/accounts/{accountName}", pathParameters),
781		autorest.WithJSON(mapsAccountUpdateParameters),
782		autorest.WithQueryParameters(queryParameters))
783	return preparer.Prepare((&http.Request{}).WithContext(ctx))
784}
785
786// UpdateSender sends the Update request. The method will close the
787// http.Response Body if it receives an error.
788func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) {
789	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
790}
791
792// UpdateResponder handles the response to the Update request. The method always
793// closes the http.Response Body.
794func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) {
795	err = autorest.Respond(
796		resp,
797		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound),
798		autorest.ByUnmarshallingJSON(&result),
799		autorest.ByClosing())
800	result.Response = autorest.Response{Response: resp}
801	return
802}
803