1package account
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// AccountsClient is the creates an Azure Data Lake Analytics account management client.
30type AccountsClient struct {
31	BaseClient
32}
33
34// NewAccountsClient creates an instance of the AccountsClient client.
35func NewAccountsClient(subscriptionID string) AccountsClient {
36	return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID)
37}
38
39// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client.
40func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient {
41	return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)}
42}
43
44// CheckNameAvailability checks whether the specified account name is available or taken.
45// Parameters:
46// location - the resource location without whitespace.
47// parameters - parameters supplied to check the Data Lake Analytics account name availability.
48func (client AccountsClient) CheckNameAvailability(ctx context.Context, location string, parameters CheckNameAvailabilityParameters) (result NameAvailabilityInformation, err error) {
49	if tracing.IsEnabled() {
50		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CheckNameAvailability")
51		defer func() {
52			sc := -1
53			if result.Response.Response != nil {
54				sc = result.Response.Response.StatusCode
55			}
56			tracing.EndSpan(ctx, sc, err)
57		}()
58	}
59	if err := validation.Validate([]validation.Validation{
60		{TargetValue: parameters,
61			Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil},
62				{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
63		return result, validation.NewError("account.AccountsClient", "CheckNameAvailability", err.Error())
64	}
65
66	req, err := client.CheckNameAvailabilityPreparer(ctx, location, parameters)
67	if err != nil {
68		err = autorest.NewErrorWithError(err, "account.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request")
69		return
70	}
71
72	resp, err := client.CheckNameAvailabilitySender(req)
73	if err != nil {
74		result.Response = autorest.Response{Response: resp}
75		err = autorest.NewErrorWithError(err, "account.AccountsClient", "CheckNameAvailability", resp, "Failure sending request")
76		return
77	}
78
79	result, err = client.CheckNameAvailabilityResponder(resp)
80	if err != nil {
81		err = autorest.NewErrorWithError(err, "account.AccountsClient", "CheckNameAvailability", resp, "Failure responding to request")
82	}
83
84	return
85}
86
87// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request.
88func (client AccountsClient) CheckNameAvailabilityPreparer(ctx context.Context, location string, parameters CheckNameAvailabilityParameters) (*http.Request, error) {
89	pathParameters := map[string]interface{}{
90		"location":       autorest.Encode("path", location),
91		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
92	}
93
94	const APIVersion = "2016-11-01"
95	queryParameters := map[string]interface{}{
96		"api-version": APIVersion,
97	}
98
99	preparer := autorest.CreatePreparer(
100		autorest.AsContentType("application/json; charset=utf-8"),
101		autorest.AsPost(),
102		autorest.WithBaseURL(client.BaseURI),
103		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DataLakeAnalytics/locations/{location}/checkNameAvailability", pathParameters),
104		autorest.WithJSON(parameters),
105		autorest.WithQueryParameters(queryParameters))
106	return preparer.Prepare((&http.Request{}).WithContext(ctx))
107}
108
109// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the
110// http.Response Body if it receives an error.
111func (client AccountsClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) {
112	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
113	return autorest.SendWithSender(client, req, sd...)
114}
115
116// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always
117// closes the http.Response Body.
118func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response) (result NameAvailabilityInformation, err error) {
119	err = autorest.Respond(
120		resp,
121		client.ByInspecting(),
122		azure.WithErrorUnlessStatusCode(http.StatusOK),
123		autorest.ByUnmarshallingJSON(&result),
124		autorest.ByClosing())
125	result.Response = autorest.Response{Response: resp}
126	return
127}
128
129// Create creates the specified Data Lake Analytics account. This supplies the user with computation services for Data
130// Lake Analytics workloads.
131// Parameters:
132// resourceGroupName - the name of the Azure resource group.
133// accountName - the name of the Data Lake Analytics account.
134// parameters - parameters supplied to create a new Data Lake Analytics account.
135func (client AccountsClient) Create(ctx context.Context, resourceGroupName string, accountName string, parameters CreateDataLakeAnalyticsAccountParameters) (result AccountsCreateFutureType, err error) {
136	if tracing.IsEnabled() {
137		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Create")
138		defer func() {
139			sc := -1
140			if result.Response() != nil {
141				sc = result.Response().StatusCode
142			}
143			tracing.EndSpan(ctx, sc, err)
144		}()
145	}
146	if err := validation.Validate([]validation.Validation{
147		{TargetValue: parameters,
148			Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
149				{Target: "parameters.CreateDataLakeAnalyticsAccountProperties", Name: validation.Null, Rule: true,
150					Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.DefaultDataLakeStoreAccount", Name: validation.Null, Rule: true, Chain: nil},
151						{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.DataLakeStoreAccounts", Name: validation.Null, Rule: true, Chain: nil},
152						{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MaxJobCount", Name: validation.Null, Rule: false,
153							Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MaxJobCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}},
154						{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MaxDegreeOfParallelism", Name: validation.Null, Rule: false,
155							Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MaxDegreeOfParallelism", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}},
156						{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MaxDegreeOfParallelismPerJob", Name: validation.Null, Rule: false,
157							Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MaxDegreeOfParallelismPerJob", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}},
158						{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MinPriorityPerJob", Name: validation.Null, Rule: false,
159							Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.MinPriorityPerJob", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}},
160						{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.QueryStoreRetention", Name: validation.Null, Rule: false,
161							Chain: []validation.Constraint{{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.QueryStoreRetention", Name: validation.InclusiveMaximum, Rule: int64(180), Chain: nil},
162								{Target: "parameters.CreateDataLakeAnalyticsAccountProperties.QueryStoreRetention", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
163							}},
164					}}}}}); err != nil {
165		return result, validation.NewError("account.AccountsClient", "Create", err.Error())
166	}
167
168	req, err := client.CreatePreparer(ctx, resourceGroupName, accountName, parameters)
169	if err != nil {
170		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Create", nil, "Failure preparing request")
171		return
172	}
173
174	result, err = client.CreateSender(req)
175	if err != nil {
176		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Create", result.Response(), "Failure sending request")
177		return
178	}
179
180	return
181}
182
183// CreatePreparer prepares the Create request.
184func (client AccountsClient) CreatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters CreateDataLakeAnalyticsAccountParameters) (*http.Request, error) {
185	pathParameters := map[string]interface{}{
186		"accountName":       autorest.Encode("path", accountName),
187		"resourceGroupName": autorest.Encode("path", resourceGroupName),
188		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
189	}
190
191	const APIVersion = "2016-11-01"
192	queryParameters := map[string]interface{}{
193		"api-version": APIVersion,
194	}
195
196	preparer := autorest.CreatePreparer(
197		autorest.AsContentType("application/json; charset=utf-8"),
198		autorest.AsPut(),
199		autorest.WithBaseURL(client.BaseURI),
200		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}", pathParameters),
201		autorest.WithJSON(parameters),
202		autorest.WithQueryParameters(queryParameters))
203	return preparer.Prepare((&http.Request{}).WithContext(ctx))
204}
205
206// CreateSender sends the Create request. The method will close the
207// http.Response Body if it receives an error.
208func (client AccountsClient) CreateSender(req *http.Request) (future AccountsCreateFutureType, err error) {
209	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
210	var resp *http.Response
211	resp, err = autorest.SendWithSender(client, req, sd...)
212	if err != nil {
213		return
214	}
215	future.Future, err = azure.NewFutureFromResponse(resp)
216	return
217}
218
219// CreateResponder handles the response to the Create request. The method always
220// closes the http.Response Body.
221func (client AccountsClient) CreateResponder(resp *http.Response) (result DataLakeAnalyticsAccount, err error) {
222	err = autorest.Respond(
223		resp,
224		client.ByInspecting(),
225		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
226		autorest.ByUnmarshallingJSON(&result),
227		autorest.ByClosing())
228	result.Response = autorest.Response{Response: resp}
229	return
230}
231
232// Delete begins the delete process for the Data Lake Analytics account object specified by the account name.
233// Parameters:
234// resourceGroupName - the name of the Azure resource group.
235// accountName - the name of the Data Lake Analytics account.
236func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result AccountsDeleteFutureType, err error) {
237	if tracing.IsEnabled() {
238		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete")
239		defer func() {
240			sc := -1
241			if result.Response() != nil {
242				sc = result.Response().StatusCode
243			}
244			tracing.EndSpan(ctx, sc, err)
245		}()
246	}
247	req, err := client.DeletePreparer(ctx, resourceGroupName, accountName)
248	if err != nil {
249		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Delete", nil, "Failure preparing request")
250		return
251	}
252
253	result, err = client.DeleteSender(req)
254	if err != nil {
255		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Delete", result.Response(), "Failure sending request")
256		return
257	}
258
259	return
260}
261
262// DeletePreparer prepares the Delete request.
263func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
264	pathParameters := map[string]interface{}{
265		"accountName":       autorest.Encode("path", accountName),
266		"resourceGroupName": autorest.Encode("path", resourceGroupName),
267		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
268	}
269
270	const APIVersion = "2016-11-01"
271	queryParameters := map[string]interface{}{
272		"api-version": APIVersion,
273	}
274
275	preparer := autorest.CreatePreparer(
276		autorest.AsDelete(),
277		autorest.WithBaseURL(client.BaseURI),
278		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}", pathParameters),
279		autorest.WithQueryParameters(queryParameters))
280	return preparer.Prepare((&http.Request{}).WithContext(ctx))
281}
282
283// DeleteSender sends the Delete request. The method will close the
284// http.Response Body if it receives an error.
285func (client AccountsClient) DeleteSender(req *http.Request) (future AccountsDeleteFutureType, err error) {
286	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
287	var resp *http.Response
288	resp, err = autorest.SendWithSender(client, req, sd...)
289	if err != nil {
290		return
291	}
292	future.Future, err = azure.NewFutureFromResponse(resp)
293	return
294}
295
296// DeleteResponder handles the response to the Delete request. The method always
297// closes the http.Response Body.
298func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
299	err = autorest.Respond(
300		resp,
301		client.ByInspecting(),
302		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
303		autorest.ByClosing())
304	result.Response = resp
305	return
306}
307
308// Get gets details of the specified Data Lake Analytics account.
309// Parameters:
310// resourceGroupName - the name of the Azure resource group.
311// accountName - the name of the Data Lake Analytics account.
312func (client AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result DataLakeAnalyticsAccount, err error) {
313	if tracing.IsEnabled() {
314		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get")
315		defer func() {
316			sc := -1
317			if result.Response.Response != nil {
318				sc = result.Response.Response.StatusCode
319			}
320			tracing.EndSpan(ctx, sc, err)
321		}()
322	}
323	req, err := client.GetPreparer(ctx, resourceGroupName, accountName)
324	if err != nil {
325		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Get", nil, "Failure preparing request")
326		return
327	}
328
329	resp, err := client.GetSender(req)
330	if err != nil {
331		result.Response = autorest.Response{Response: resp}
332		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Get", resp, "Failure sending request")
333		return
334	}
335
336	result, err = client.GetResponder(resp)
337	if err != nil {
338		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Get", resp, "Failure responding to request")
339	}
340
341	return
342}
343
344// GetPreparer prepares the Get request.
345func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) {
346	pathParameters := map[string]interface{}{
347		"accountName":       autorest.Encode("path", accountName),
348		"resourceGroupName": autorest.Encode("path", resourceGroupName),
349		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
350	}
351
352	const APIVersion = "2016-11-01"
353	queryParameters := map[string]interface{}{
354		"api-version": APIVersion,
355	}
356
357	preparer := autorest.CreatePreparer(
358		autorest.AsGet(),
359		autorest.WithBaseURL(client.BaseURI),
360		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}", pathParameters),
361		autorest.WithQueryParameters(queryParameters))
362	return preparer.Prepare((&http.Request{}).WithContext(ctx))
363}
364
365// GetSender sends the Get request. The method will close the
366// http.Response Body if it receives an error.
367func (client AccountsClient) GetSender(req *http.Request) (*http.Response, error) {
368	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
369	return autorest.SendWithSender(client, req, sd...)
370}
371
372// GetResponder handles the response to the Get request. The method always
373// closes the http.Response Body.
374func (client AccountsClient) GetResponder(resp *http.Response) (result DataLakeAnalyticsAccount, err error) {
375	err = autorest.Respond(
376		resp,
377		client.ByInspecting(),
378		azure.WithErrorUnlessStatusCode(http.StatusOK),
379		autorest.ByUnmarshallingJSON(&result),
380		autorest.ByClosing())
381	result.Response = autorest.Response{Response: resp}
382	return
383}
384
385// List gets the first page of Data Lake Analytics accounts, if any, within the current subscription. This includes a
386// link to the next page, if any.
387// Parameters:
388// filter - oData filter. Optional.
389// top - the number of items to return. Optional.
390// skip - the number of items to skip over before returning elements. Optional.
391// selectParameter - oData Select statement. Limits the properties on each entry to just those requested, e.g.
392// Categories?$select=CategoryName,Description. Optional.
393// orderby - orderBy clause. One or more comma-separated expressions with an optional "asc" (the default) or
394// "desc" depending on the order you'd like the values sorted, e.g. Categories?$orderby=CategoryName desc.
395// Optional.
396// count - the Boolean value of true or false to request a count of the matching resources included with the
397// resources in the response, e.g. Categories?$count=true. Optional.
398func (client AccountsClient) List(ctx context.Context, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeAnalyticsAccountListResultPage, err error) {
399	if tracing.IsEnabled() {
400		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List")
401		defer func() {
402			sc := -1
403			if result.dlaalr.Response.Response != nil {
404				sc = result.dlaalr.Response.Response.StatusCode
405			}
406			tracing.EndSpan(ctx, sc, err)
407		}()
408	}
409	if err := validation.Validate([]validation.Validation{
410		{TargetValue: top,
411			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
412				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
413		{TargetValue: skip,
414			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
415				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}}); err != nil {
416		return result, validation.NewError("account.AccountsClient", "List", err.Error())
417	}
418
419	result.fn = client.listNextResults
420	req, err := client.ListPreparer(ctx, filter, top, skip, selectParameter, orderby, count)
421	if err != nil {
422		err = autorest.NewErrorWithError(err, "account.AccountsClient", "List", nil, "Failure preparing request")
423		return
424	}
425
426	resp, err := client.ListSender(req)
427	if err != nil {
428		result.dlaalr.Response = autorest.Response{Response: resp}
429		err = autorest.NewErrorWithError(err, "account.AccountsClient", "List", resp, "Failure sending request")
430		return
431	}
432
433	result.dlaalr, err = client.ListResponder(resp)
434	if err != nil {
435		err = autorest.NewErrorWithError(err, "account.AccountsClient", "List", resp, "Failure responding to request")
436	}
437
438	return
439}
440
441// ListPreparer prepares the List request.
442func (client AccountsClient) ListPreparer(ctx context.Context, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (*http.Request, error) {
443	pathParameters := map[string]interface{}{
444		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
445	}
446
447	const APIVersion = "2016-11-01"
448	queryParameters := map[string]interface{}{
449		"api-version": APIVersion,
450	}
451	if len(filter) > 0 {
452		queryParameters["$filter"] = autorest.Encode("query", filter)
453	}
454	if top != nil {
455		queryParameters["$top"] = autorest.Encode("query", *top)
456	}
457	if skip != nil {
458		queryParameters["$skip"] = autorest.Encode("query", *skip)
459	}
460	if len(selectParameter) > 0 {
461		queryParameters["$select"] = autorest.Encode("query", selectParameter)
462	}
463	if len(orderby) > 0 {
464		queryParameters["$orderby"] = autorest.Encode("query", orderby)
465	}
466	if count != nil {
467		queryParameters["$count"] = autorest.Encode("query", *count)
468	}
469
470	preparer := autorest.CreatePreparer(
471		autorest.AsGet(),
472		autorest.WithBaseURL(client.BaseURI),
473		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.DataLakeAnalytics/accounts", pathParameters),
474		autorest.WithQueryParameters(queryParameters))
475	return preparer.Prepare((&http.Request{}).WithContext(ctx))
476}
477
478// ListSender sends the List request. The method will close the
479// http.Response Body if it receives an error.
480func (client AccountsClient) ListSender(req *http.Request) (*http.Response, error) {
481	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
482	return autorest.SendWithSender(client, req, sd...)
483}
484
485// ListResponder handles the response to the List request. The method always
486// closes the http.Response Body.
487func (client AccountsClient) ListResponder(resp *http.Response) (result DataLakeAnalyticsAccountListResult, err error) {
488	err = autorest.Respond(
489		resp,
490		client.ByInspecting(),
491		azure.WithErrorUnlessStatusCode(http.StatusOK),
492		autorest.ByUnmarshallingJSON(&result),
493		autorest.ByClosing())
494	result.Response = autorest.Response{Response: resp}
495	return
496}
497
498// listNextResults retrieves the next set of results, if any.
499func (client AccountsClient) listNextResults(ctx context.Context, lastResults DataLakeAnalyticsAccountListResult) (result DataLakeAnalyticsAccountListResult, err error) {
500	req, err := lastResults.dataLakeAnalyticsAccountListResultPreparer(ctx)
501	if err != nil {
502		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listNextResults", nil, "Failure preparing next results request")
503	}
504	if req == nil {
505		return
506	}
507	resp, err := client.ListSender(req)
508	if err != nil {
509		result.Response = autorest.Response{Response: resp}
510		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listNextResults", resp, "Failure sending next results request")
511	}
512	result, err = client.ListResponder(resp)
513	if err != nil {
514		err = autorest.NewErrorWithError(err, "account.AccountsClient", "listNextResults", resp, "Failure responding to next results request")
515	}
516	return
517}
518
519// ListComplete enumerates all values, automatically crossing page boundaries as required.
520func (client AccountsClient) ListComplete(ctx context.Context, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeAnalyticsAccountListResultIterator, err error) {
521	if tracing.IsEnabled() {
522		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List")
523		defer func() {
524			sc := -1
525			if result.Response().Response.Response != nil {
526				sc = result.page.Response().Response.Response.StatusCode
527			}
528			tracing.EndSpan(ctx, sc, err)
529		}()
530	}
531	result.page, err = client.List(ctx, filter, top, skip, selectParameter, orderby, count)
532	return
533}
534
535// ListByResourceGroup gets the first page of Data Lake Analytics accounts, if any, within a specific resource group.
536// This includes a link to the next page, if any.
537// Parameters:
538// resourceGroupName - the name of the Azure resource group.
539// filter - oData filter. Optional.
540// top - the number of items to return. Optional.
541// skip - the number of items to skip over before returning elements. Optional.
542// selectParameter - oData Select statement. Limits the properties on each entry to just those requested, e.g.
543// Categories?$select=CategoryName,Description. Optional.
544// orderby - orderBy clause. One or more comma-separated expressions with an optional "asc" (the default) or
545// "desc" depending on the order you'd like the values sorted, e.g. Categories?$orderby=CategoryName desc.
546// Optional.
547// count - the Boolean value of true or false to request a count of the matching resources included with the
548// resources in the response, e.g. Categories?$count=true. Optional.
549func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeAnalyticsAccountListResultPage, err error) {
550	if tracing.IsEnabled() {
551		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup")
552		defer func() {
553			sc := -1
554			if result.dlaalr.Response.Response != nil {
555				sc = result.dlaalr.Response.Response.StatusCode
556			}
557			tracing.EndSpan(ctx, sc, err)
558		}()
559	}
560	if err := validation.Validate([]validation.Validation{
561		{TargetValue: top,
562			Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
563				Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
564		{TargetValue: skip,
565			Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
566				Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}}); err != nil {
567		return result, validation.NewError("account.AccountsClient", "ListByResourceGroup", err.Error())
568	}
569
570	result.fn = client.listByResourceGroupNextResults
571	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, filter, top, skip, selectParameter, orderby, count)
572	if err != nil {
573		err = autorest.NewErrorWithError(err, "account.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request")
574		return
575	}
576
577	resp, err := client.ListByResourceGroupSender(req)
578	if err != nil {
579		result.dlaalr.Response = autorest.Response{Response: resp}
580		err = autorest.NewErrorWithError(err, "account.AccountsClient", "ListByResourceGroup", resp, "Failure sending request")
581		return
582	}
583
584	result.dlaalr, err = client.ListByResourceGroupResponder(resp)
585	if err != nil {
586		err = autorest.NewErrorWithError(err, "account.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request")
587	}
588
589	return
590}
591
592// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
593func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (*http.Request, error) {
594	pathParameters := map[string]interface{}{
595		"resourceGroupName": autorest.Encode("path", resourceGroupName),
596		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
597	}
598
599	const APIVersion = "2016-11-01"
600	queryParameters := map[string]interface{}{
601		"api-version": APIVersion,
602	}
603	if len(filter) > 0 {
604		queryParameters["$filter"] = autorest.Encode("query", filter)
605	}
606	if top != nil {
607		queryParameters["$top"] = autorest.Encode("query", *top)
608	}
609	if skip != nil {
610		queryParameters["$skip"] = autorest.Encode("query", *skip)
611	}
612	if len(selectParameter) > 0 {
613		queryParameters["$select"] = autorest.Encode("query", selectParameter)
614	}
615	if len(orderby) > 0 {
616		queryParameters["$orderby"] = autorest.Encode("query", orderby)
617	}
618	if count != nil {
619		queryParameters["$count"] = autorest.Encode("query", *count)
620	}
621
622	preparer := autorest.CreatePreparer(
623		autorest.AsGet(),
624		autorest.WithBaseURL(client.BaseURI),
625		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts", pathParameters),
626		autorest.WithQueryParameters(queryParameters))
627	return preparer.Prepare((&http.Request{}).WithContext(ctx))
628}
629
630// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
631// http.Response Body if it receives an error.
632func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
633	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
634	return autorest.SendWithSender(client, req, sd...)
635}
636
637// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
638// closes the http.Response Body.
639func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result DataLakeAnalyticsAccountListResult, err error) {
640	err = autorest.Respond(
641		resp,
642		client.ByInspecting(),
643		azure.WithErrorUnlessStatusCode(http.StatusOK),
644		autorest.ByUnmarshallingJSON(&result),
645		autorest.ByClosing())
646	result.Response = autorest.Response{Response: resp}
647	return
648}
649
650// listByResourceGroupNextResults retrieves the next set of results, if any.
651func (client AccountsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DataLakeAnalyticsAccountListResult) (result DataLakeAnalyticsAccountListResult, err error) {
652	req, err := lastResults.dataLakeAnalyticsAccountListResultPreparer(ctx)
653	if err != nil {
654		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
655	}
656	if req == nil {
657		return
658	}
659	resp, err := client.ListByResourceGroupSender(req)
660	if err != nil {
661		result.Response = autorest.Response{Response: resp}
662		return result, autorest.NewErrorWithError(err, "account.AccountsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
663	}
664	result, err = client.ListByResourceGroupResponder(resp)
665	if err != nil {
666		err = autorest.NewErrorWithError(err, "account.AccountsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
667	}
668	return
669}
670
671// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
672func (client AccountsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeAnalyticsAccountListResultIterator, err error) {
673	if tracing.IsEnabled() {
674		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup")
675		defer func() {
676			sc := -1
677			if result.Response().Response.Response != nil {
678				sc = result.page.Response().Response.Response.StatusCode
679			}
680			tracing.EndSpan(ctx, sc, err)
681		}()
682	}
683	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, filter, top, skip, selectParameter, orderby, count)
684	return
685}
686
687// Update updates the Data Lake Analytics account object specified by the accountName with the contents of the account
688// object.
689// Parameters:
690// resourceGroupName - the name of the Azure resource group.
691// accountName - the name of the Data Lake Analytics account.
692// parameters - parameters supplied to the update Data Lake Analytics account operation.
693func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters *UpdateDataLakeAnalyticsAccountParameters) (result AccountsUpdateFutureType, err error) {
694	if tracing.IsEnabled() {
695		ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update")
696		defer func() {
697			sc := -1
698			if result.Response() != nil {
699				sc = result.Response().StatusCode
700			}
701			tracing.EndSpan(ctx, sc, err)
702		}()
703	}
704	req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, parameters)
705	if err != nil {
706		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Update", nil, "Failure preparing request")
707		return
708	}
709
710	result, err = client.UpdateSender(req)
711	if err != nil {
712		err = autorest.NewErrorWithError(err, "account.AccountsClient", "Update", result.Response(), "Failure sending request")
713		return
714	}
715
716	return
717}
718
719// UpdatePreparer prepares the Update request.
720func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters *UpdateDataLakeAnalyticsAccountParameters) (*http.Request, error) {
721	pathParameters := map[string]interface{}{
722		"accountName":       autorest.Encode("path", accountName),
723		"resourceGroupName": autorest.Encode("path", resourceGroupName),
724		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
725	}
726
727	const APIVersion = "2016-11-01"
728	queryParameters := map[string]interface{}{
729		"api-version": APIVersion,
730	}
731
732	preparer := autorest.CreatePreparer(
733		autorest.AsContentType("application/json; charset=utf-8"),
734		autorest.AsPatch(),
735		autorest.WithBaseURL(client.BaseURI),
736		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}", pathParameters),
737		autorest.WithQueryParameters(queryParameters))
738	if parameters != nil {
739		preparer = autorest.DecoratePreparer(preparer,
740			autorest.WithJSON(parameters))
741	}
742	return preparer.Prepare((&http.Request{}).WithContext(ctx))
743}
744
745// UpdateSender sends the Update request. The method will close the
746// http.Response Body if it receives an error.
747func (client AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFutureType, err error) {
748	sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
749	var resp *http.Response
750	resp, err = autorest.SendWithSender(client, req, sd...)
751	if err != nil {
752		return
753	}
754	future.Future, err = azure.NewFutureFromResponse(resp)
755	return
756}
757
758// UpdateResponder handles the response to the Update request. The method always
759// closes the http.Response Body.
760func (client AccountsClient) UpdateResponder(resp *http.Response) (result DataLakeAnalyticsAccount, err error) {
761	err = autorest.Respond(
762		resp,
763		client.ByInspecting(),
764		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
765		autorest.ByUnmarshallingJSON(&result),
766		autorest.ByClosing())
767	result.Response = autorest.Response{Response: resp}
768	return
769}
770