1 package account
2
3
4
5
6
7
8
9 import (
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
19 type DataLakeStoreAccountsClient struct {
20 BaseClient
21 }
22
23
24 func NewDataLakeStoreAccountsClient(subscriptionID string) DataLakeStoreAccountsClient {
25 return NewDataLakeStoreAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26 }
27
28
29
30
31 func NewDataLakeStoreAccountsClientWithBaseURI(baseURI string, subscriptionID string) DataLakeStoreAccountsClient {
32 return DataLakeStoreAccountsClient{NewWithBaseURI(baseURI, subscriptionID)}
33 }
34
35
36
37
38
39
40
41 func (client DataLakeStoreAccountsClient) Add(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string, parameters *AddDataLakeStoreParameters) (result autorest.Response, err error) {
42 if tracing.IsEnabled() {
43 ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.Add")
44 defer func() {
45 sc := -1
46 if result.Response != nil {
47 sc = result.Response.StatusCode
48 }
49 tracing.EndSpan(ctx, sc, err)
50 }()
51 }
52 req, err := client.AddPreparer(ctx, resourceGroupName, accountName, dataLakeStoreAccountName, parameters)
53 if err != nil {
54 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", nil, "Failure preparing request")
55 return
56 }
57
58 resp, err := client.AddSender(req)
59 if err != nil {
60 result.Response = resp
61 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", resp, "Failure sending request")
62 return
63 }
64
65 result, err = client.AddResponder(resp)
66 if err != nil {
67 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Add", resp, "Failure responding to request")
68 return
69 }
70
71 return
72 }
73
74
75 func (client DataLakeStoreAccountsClient) AddPreparer(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string, parameters *AddDataLakeStoreParameters) (*http.Request, error) {
76 pathParameters := map[string]interface{}{
77 "accountName": autorest.Encode("path", accountName),
78 "dataLakeStoreAccountName": autorest.Encode("path", dataLakeStoreAccountName),
79 "resourceGroupName": autorest.Encode("path", resourceGroupName),
80 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
81 }
82
83 const APIVersion = "2016-11-01"
84 queryParameters := map[string]interface{}{
85 "api-version": APIVersion,
86 }
87
88 preparer := autorest.CreatePreparer(
89 autorest.AsContentType("application/json; charset=utf-8"),
90 autorest.AsPut(),
91 autorest.WithBaseURL(client.BaseURI),
92 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts/{dataLakeStoreAccountName}", pathParameters),
93 autorest.WithQueryParameters(queryParameters))
94 if parameters != nil {
95 preparer = autorest.DecoratePreparer(preparer,
96 autorest.WithJSON(parameters))
97 }
98 return preparer.Prepare((&http.Request{}).WithContext(ctx))
99 }
100
101
102
103 func (client DataLakeStoreAccountsClient) AddSender(req *http.Request) (*http.Response, error) {
104 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
105 }
106
107
108
109 func (client DataLakeStoreAccountsClient) AddResponder(resp *http.Response) (result autorest.Response, err error) {
110 err = autorest.Respond(
111 resp,
112 azure.WithErrorUnlessStatusCode(http.StatusOK),
113 autorest.ByClosing())
114 result.Response = resp
115 return
116 }
117
118
119
120
121
122
123 func (client DataLakeStoreAccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (result autorest.Response, err error) {
124 if tracing.IsEnabled() {
125 ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.Delete")
126 defer func() {
127 sc := -1
128 if result.Response != nil {
129 sc = result.Response.StatusCode
130 }
131 tracing.EndSpan(ctx, sc, err)
132 }()
133 }
134 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName, dataLakeStoreAccountName)
135 if err != nil {
136 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", nil, "Failure preparing request")
137 return
138 }
139
140 resp, err := client.DeleteSender(req)
141 if err != nil {
142 result.Response = resp
143 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", resp, "Failure sending request")
144 return
145 }
146
147 result, err = client.DeleteResponder(resp)
148 if err != nil {
149 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Delete", resp, "Failure responding to request")
150 return
151 }
152
153 return
154 }
155
156
157 func (client DataLakeStoreAccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (*http.Request, error) {
158 pathParameters := map[string]interface{}{
159 "accountName": autorest.Encode("path", accountName),
160 "dataLakeStoreAccountName": autorest.Encode("path", dataLakeStoreAccountName),
161 "resourceGroupName": autorest.Encode("path", resourceGroupName),
162 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
163 }
164
165 const APIVersion = "2016-11-01"
166 queryParameters := map[string]interface{}{
167 "api-version": APIVersion,
168 }
169
170 preparer := autorest.CreatePreparer(
171 autorest.AsDelete(),
172 autorest.WithBaseURL(client.BaseURI),
173 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts/{dataLakeStoreAccountName}", pathParameters),
174 autorest.WithQueryParameters(queryParameters))
175 return preparer.Prepare((&http.Request{}).WithContext(ctx))
176 }
177
178
179
180 func (client DataLakeStoreAccountsClient) DeleteSender(req *http.Request) (*http.Response, error) {
181 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
182 }
183
184
185
186 func (client DataLakeStoreAccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
187 err = autorest.Respond(
188 resp,
189 azure.WithErrorUnlessStatusCode(http.StatusOK),
190 autorest.ByClosing())
191 result.Response = resp
192 return
193 }
194
195
196
197
198
199
200 func (client DataLakeStoreAccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (result DataLakeStoreAccountInformation, err error) {
201 if tracing.IsEnabled() {
202 ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.Get")
203 defer func() {
204 sc := -1
205 if result.Response.Response != nil {
206 sc = result.Response.Response.StatusCode
207 }
208 tracing.EndSpan(ctx, sc, err)
209 }()
210 }
211 req, err := client.GetPreparer(ctx, resourceGroupName, accountName, dataLakeStoreAccountName)
212 if err != nil {
213 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", nil, "Failure preparing request")
214 return
215 }
216
217 resp, err := client.GetSender(req)
218 if err != nil {
219 result.Response = autorest.Response{Response: resp}
220 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", resp, "Failure sending request")
221 return
222 }
223
224 result, err = client.GetResponder(resp)
225 if err != nil {
226 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "Get", resp, "Failure responding to request")
227 return
228 }
229
230 return
231 }
232
233
234 func (client DataLakeStoreAccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string, dataLakeStoreAccountName string) (*http.Request, error) {
235 pathParameters := map[string]interface{}{
236 "accountName": autorest.Encode("path", accountName),
237 "dataLakeStoreAccountName": autorest.Encode("path", dataLakeStoreAccountName),
238 "resourceGroupName": autorest.Encode("path", resourceGroupName),
239 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
240 }
241
242 const APIVersion = "2016-11-01"
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.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts/{dataLakeStoreAccountName}", pathParameters),
251 autorest.WithQueryParameters(queryParameters))
252 return preparer.Prepare((&http.Request{}).WithContext(ctx))
253 }
254
255
256
257 func (client DataLakeStoreAccountsClient) GetSender(req *http.Request) (*http.Response, error) {
258 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
259 }
260
261
262
263 func (client DataLakeStoreAccountsClient) GetResponder(resp *http.Response) (result DataLakeStoreAccountInformation, err error) {
264 err = autorest.Respond(
265 resp,
266 azure.WithErrorUnlessStatusCode(http.StatusOK),
267 autorest.ByUnmarshallingJSON(&result),
268 autorest.ByClosing())
269 result.Response = autorest.Response{Response: resp}
270 return
271 }
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288 func (client DataLakeStoreAccountsClient) ListByAccount(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountInformationListResultPage, err error) {
289 if tracing.IsEnabled() {
290 ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.ListByAccount")
291 defer func() {
292 sc := -1
293 if result.dlsailr.Response.Response != nil {
294 sc = result.dlsailr.Response.Response.StatusCode
295 }
296 tracing.EndSpan(ctx, sc, err)
297 }()
298 }
299 if err := validation.Validate([]validation.Validation{
300 {TargetValue: top,
301 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
302 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}},
303 {TargetValue: skip,
304 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
305 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}}}}}); err != nil {
306 return result, validation.NewError("account.DataLakeStoreAccountsClient", "ListByAccount", err.Error())
307 }
308
309 result.fn = client.listByAccountNextResults
310 req, err := client.ListByAccountPreparer(ctx, resourceGroupName, accountName, filter, top, skip, selectParameter, orderby, count)
311 if err != nil {
312 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", nil, "Failure preparing request")
313 return
314 }
315
316 resp, err := client.ListByAccountSender(req)
317 if err != nil {
318 result.dlsailr.Response = autorest.Response{Response: resp}
319 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", resp, "Failure sending request")
320 return
321 }
322
323 result.dlsailr, err = client.ListByAccountResponder(resp)
324 if err != nil {
325 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "ListByAccount", resp, "Failure responding to request")
326 return
327 }
328 if result.dlsailr.hasNextLink() && result.dlsailr.IsEmpty() {
329 err = result.NextWithContext(ctx)
330 return
331 }
332
333 return
334 }
335
336
337 func (client DataLakeStoreAccountsClient) ListByAccountPreparer(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (*http.Request, error) {
338 pathParameters := map[string]interface{}{
339 "accountName": autorest.Encode("path", accountName),
340 "resourceGroupName": autorest.Encode("path", resourceGroupName),
341 "subscriptionId": autorest.Encode("path", client.SubscriptionID),
342 }
343
344 const APIVersion = "2016-11-01"
345 queryParameters := map[string]interface{}{
346 "api-version": APIVersion,
347 }
348 if len(filter) > 0 {
349 queryParameters["$filter"] = autorest.Encode("query", filter)
350 }
351 if top != nil {
352 queryParameters["$top"] = autorest.Encode("query", *top)
353 }
354 if skip != nil {
355 queryParameters["$skip"] = autorest.Encode("query", *skip)
356 }
357 if len(selectParameter) > 0 {
358 queryParameters["$select"] = autorest.Encode("query", selectParameter)
359 }
360 if len(orderby) > 0 {
361 queryParameters["$orderby"] = autorest.Encode("query", orderby)
362 }
363 if count != nil {
364 queryParameters["$count"] = autorest.Encode("query", *count)
365 }
366
367 preparer := autorest.CreatePreparer(
368 autorest.AsGet(),
369 autorest.WithBaseURL(client.BaseURI),
370 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataLakeAnalytics/accounts/{accountName}/dataLakeStoreAccounts", pathParameters),
371 autorest.WithQueryParameters(queryParameters))
372 return preparer.Prepare((&http.Request{}).WithContext(ctx))
373 }
374
375
376
377 func (client DataLakeStoreAccountsClient) ListByAccountSender(req *http.Request) (*http.Response, error) {
378 return client.Send(req, azure.DoRetryWithRegistration(client.Client))
379 }
380
381
382
383 func (client DataLakeStoreAccountsClient) ListByAccountResponder(resp *http.Response) (result DataLakeStoreAccountInformationListResult, err error) {
384 err = autorest.Respond(
385 resp,
386 azure.WithErrorUnlessStatusCode(http.StatusOK),
387 autorest.ByUnmarshallingJSON(&result),
388 autorest.ByClosing())
389 result.Response = autorest.Response{Response: resp}
390 return
391 }
392
393
394 func (client DataLakeStoreAccountsClient) listByAccountNextResults(ctx context.Context, lastResults DataLakeStoreAccountInformationListResult) (result DataLakeStoreAccountInformationListResult, err error) {
395 req, err := lastResults.dataLakeStoreAccountInformationListResultPreparer(ctx)
396 if err != nil {
397 return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "listByAccountNextResults", nil, "Failure preparing next results request")
398 }
399 if req == nil {
400 return
401 }
402 resp, err := client.ListByAccountSender(req)
403 if err != nil {
404 result.Response = autorest.Response{Response: resp}
405 return result, autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "listByAccountNextResults", resp, "Failure sending next results request")
406 }
407 result, err = client.ListByAccountResponder(resp)
408 if err != nil {
409 err = autorest.NewErrorWithError(err, "account.DataLakeStoreAccountsClient", "listByAccountNextResults", resp, "Failure responding to next results request")
410 }
411 return
412 }
413
414
415 func (client DataLakeStoreAccountsClient) ListByAccountComplete(ctx context.Context, resourceGroupName string, accountName string, filter string, top *int32, skip *int32, selectParameter string, orderby string, count *bool) (result DataLakeStoreAccountInformationListResultIterator, err error) {
416 if tracing.IsEnabled() {
417 ctx = tracing.StartSpan(ctx, fqdn+"/DataLakeStoreAccountsClient.ListByAccount")
418 defer func() {
419 sc := -1
420 if result.Response().Response.Response != nil {
421 sc = result.page.Response().Response.Response.StatusCode
422 }
423 tracing.EndSpan(ctx, sc, err)
424 }()
425 }
426 result.page, err = client.ListByAccount(ctx, resourceGroupName, accountName, filter, top, skip, selectParameter, orderby, count)
427 return
428 }
429
View as plain text