1 package billing
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/tracing"
14 "net/http"
15 )
16
17
18 type PermissionsClient struct {
19 BaseClient
20 }
21
22
23 func NewPermissionsClient(subscriptionID string) PermissionsClient {
24 return NewPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
25 }
26
27
28
29 func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) PermissionsClient {
30 return PermissionsClient{NewWithBaseURI(baseURI, subscriptionID)}
31 }
32
33
34
35
36 func (client PermissionsClient) ListByBillingAccount(ctx context.Context, billingAccountName string) (result PermissionsListResultPage, err error) {
37 if tracing.IsEnabled() {
38 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingAccount")
39 defer func() {
40 sc := -1
41 if result.plr.Response.Response != nil {
42 sc = result.plr.Response.Response.StatusCode
43 }
44 tracing.EndSpan(ctx, sc, err)
45 }()
46 }
47 result.fn = client.listByBillingAccountNextResults
48 req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName)
49 if err != nil {
50 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingAccount", nil, "Failure preparing request")
51 return
52 }
53
54 resp, err := client.ListByBillingAccountSender(req)
55 if err != nil {
56 result.plr.Response = autorest.Response{Response: resp}
57 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingAccount", resp, "Failure sending request")
58 return
59 }
60
61 result.plr, err = client.ListByBillingAccountResponder(resp)
62 if err != nil {
63 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingAccount", resp, "Failure responding to request")
64 return
65 }
66 if result.plr.hasNextLink() && result.plr.IsEmpty() {
67 err = result.NextWithContext(ctx)
68 return
69 }
70
71 return
72 }
73
74
75 func (client PermissionsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) {
76 pathParameters := map[string]interface{}{
77 "billingAccountName": autorest.Encode("path", billingAccountName),
78 }
79
80 const APIVersion = "2020-05-01"
81 queryParameters := map[string]interface{}{
82 "api-version": APIVersion,
83 }
84
85 preparer := autorest.CreatePreparer(
86 autorest.AsGet(),
87 autorest.WithBaseURL(client.BaseURI),
88 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions", pathParameters),
89 autorest.WithQueryParameters(queryParameters))
90 return preparer.Prepare((&http.Request{}).WithContext(ctx))
91 }
92
93
94
95 func (client PermissionsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) {
96 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
97 }
98
99
100
101 func (client PermissionsClient) ListByBillingAccountResponder(resp *http.Response) (result PermissionsListResult, err error) {
102 err = autorest.Respond(
103 resp,
104 azure.WithErrorUnlessStatusCode(http.StatusOK),
105 autorest.ByUnmarshallingJSON(&result),
106 autorest.ByClosing())
107 result.Response = autorest.Response{Response: resp}
108 return
109 }
110
111
112 func (client PermissionsClient) listByBillingAccountNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) {
113 req, err := lastResults.permissionsListResultPreparer(ctx)
114 if err != nil {
115 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request")
116 }
117 if req == nil {
118 return
119 }
120 resp, err := client.ListByBillingAccountSender(req)
121 if err != nil {
122 result.Response = autorest.Response{Response: resp}
123 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request")
124 }
125 result, err = client.ListByBillingAccountResponder(resp)
126 if err != nil {
127 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request")
128 }
129 return
130 }
131
132
133 func (client PermissionsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result PermissionsListResultIterator, err error) {
134 if tracing.IsEnabled() {
135 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingAccount")
136 defer func() {
137 sc := -1
138 if result.Response().Response.Response != nil {
139 sc = result.page.Response().Response.Response.StatusCode
140 }
141 tracing.EndSpan(ctx, sc, err)
142 }()
143 }
144 result.page, err = client.ListByBillingAccount(ctx, billingAccountName)
145 return
146 }
147
148
149
150
151
152 func (client PermissionsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result PermissionsListResultPage, err error) {
153 if tracing.IsEnabled() {
154 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingProfile")
155 defer func() {
156 sc := -1
157 if result.plr.Response.Response != nil {
158 sc = result.plr.Response.Response.StatusCode
159 }
160 tracing.EndSpan(ctx, sc, err)
161 }()
162 }
163 result.fn = client.listByBillingProfileNextResults
164 req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName)
165 if err != nil {
166 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingProfile", nil, "Failure preparing request")
167 return
168 }
169
170 resp, err := client.ListByBillingProfileSender(req)
171 if err != nil {
172 result.plr.Response = autorest.Response{Response: resp}
173 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingProfile", resp, "Failure sending request")
174 return
175 }
176
177 result.plr, err = client.ListByBillingProfileResponder(resp)
178 if err != nil {
179 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingProfile", resp, "Failure responding to request")
180 return
181 }
182 if result.plr.hasNextLink() && result.plr.IsEmpty() {
183 err = result.NextWithContext(ctx)
184 return
185 }
186
187 return
188 }
189
190
191 func (client PermissionsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) {
192 pathParameters := map[string]interface{}{
193 "billingAccountName": autorest.Encode("path", billingAccountName),
194 "billingProfileName": autorest.Encode("path", billingProfileName),
195 }
196
197 const APIVersion = "2020-05-01"
198 queryParameters := map[string]interface{}{
199 "api-version": APIVersion,
200 }
201
202 preparer := autorest.CreatePreparer(
203 autorest.AsGet(),
204 autorest.WithBaseURL(client.BaseURI),
205 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingPermissions", pathParameters),
206 autorest.WithQueryParameters(queryParameters))
207 return preparer.Prepare((&http.Request{}).WithContext(ctx))
208 }
209
210
211
212 func (client PermissionsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) {
213 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
214 }
215
216
217
218 func (client PermissionsClient) ListByBillingProfileResponder(resp *http.Response) (result PermissionsListResult, err error) {
219 err = autorest.Respond(
220 resp,
221 azure.WithErrorUnlessStatusCode(http.StatusOK),
222 autorest.ByUnmarshallingJSON(&result),
223 autorest.ByClosing())
224 result.Response = autorest.Response{Response: resp}
225 return
226 }
227
228
229 func (client PermissionsClient) listByBillingProfileNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) {
230 req, err := lastResults.permissionsListResultPreparer(ctx)
231 if err != nil {
232 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request")
233 }
234 if req == nil {
235 return
236 }
237 resp, err := client.ListByBillingProfileSender(req)
238 if err != nil {
239 result.Response = autorest.Response{Response: resp}
240 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request")
241 }
242 result, err = client.ListByBillingProfileResponder(resp)
243 if err != nil {
244 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request")
245 }
246 return
247 }
248
249
250 func (client PermissionsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result PermissionsListResultIterator, err error) {
251 if tracing.IsEnabled() {
252 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingProfile")
253 defer func() {
254 sc := -1
255 if result.Response().Response.Response != nil {
256 sc = result.page.Response().Response.Response.StatusCode
257 }
258 tracing.EndSpan(ctx, sc, err)
259 }()
260 }
261 result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName)
262 return
263 }
264
265
266
267
268
269 func (client PermissionsClient) ListByCustomer(ctx context.Context, billingAccountName string, customerName string) (result PermissionsListResultPage, err error) {
270 if tracing.IsEnabled() {
271 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByCustomer")
272 defer func() {
273 sc := -1
274 if result.plr.Response.Response != nil {
275 sc = result.plr.Response.Response.StatusCode
276 }
277 tracing.EndSpan(ctx, sc, err)
278 }()
279 }
280 result.fn = client.listByCustomerNextResults
281 req, err := client.ListByCustomerPreparer(ctx, billingAccountName, customerName)
282 if err != nil {
283 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomer", nil, "Failure preparing request")
284 return
285 }
286
287 resp, err := client.ListByCustomerSender(req)
288 if err != nil {
289 result.plr.Response = autorest.Response{Response: resp}
290 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomer", resp, "Failure sending request")
291 return
292 }
293
294 result.plr, err = client.ListByCustomerResponder(resp)
295 if err != nil {
296 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomer", resp, "Failure responding to request")
297 return
298 }
299 if result.plr.hasNextLink() && result.plr.IsEmpty() {
300 err = result.NextWithContext(ctx)
301 return
302 }
303
304 return
305 }
306
307
308 func (client PermissionsClient) ListByCustomerPreparer(ctx context.Context, billingAccountName string, customerName string) (*http.Request, error) {
309 pathParameters := map[string]interface{}{
310 "billingAccountName": autorest.Encode("path", billingAccountName),
311 "customerName": autorest.Encode("path", customerName),
312 }
313
314 const APIVersion = "2020-05-01"
315 queryParameters := map[string]interface{}{
316 "api-version": APIVersion,
317 }
318
319 preparer := autorest.CreatePreparer(
320 autorest.AsGet(),
321 autorest.WithBaseURL(client.BaseURI),
322 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions", pathParameters),
323 autorest.WithQueryParameters(queryParameters))
324 return preparer.Prepare((&http.Request{}).WithContext(ctx))
325 }
326
327
328
329 func (client PermissionsClient) ListByCustomerSender(req *http.Request) (*http.Response, error) {
330 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
331 }
332
333
334
335 func (client PermissionsClient) ListByCustomerResponder(resp *http.Response) (result PermissionsListResult, err error) {
336 err = autorest.Respond(
337 resp,
338 azure.WithErrorUnlessStatusCode(http.StatusOK),
339 autorest.ByUnmarshallingJSON(&result),
340 autorest.ByClosing())
341 result.Response = autorest.Response{Response: resp}
342 return
343 }
344
345
346 func (client PermissionsClient) listByCustomerNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) {
347 req, err := lastResults.permissionsListResultPreparer(ctx)
348 if err != nil {
349 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByCustomerNextResults", nil, "Failure preparing next results request")
350 }
351 if req == nil {
352 return
353 }
354 resp, err := client.ListByCustomerSender(req)
355 if err != nil {
356 result.Response = autorest.Response{Response: resp}
357 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByCustomerNextResults", resp, "Failure sending next results request")
358 }
359 result, err = client.ListByCustomerResponder(resp)
360 if err != nil {
361 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByCustomerNextResults", resp, "Failure responding to next results request")
362 }
363 return
364 }
365
366
367 func (client PermissionsClient) ListByCustomerComplete(ctx context.Context, billingAccountName string, customerName string) (result PermissionsListResultIterator, err error) {
368 if tracing.IsEnabled() {
369 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByCustomer")
370 defer func() {
371 sc := -1
372 if result.Response().Response.Response != nil {
373 sc = result.page.Response().Response.Response.StatusCode
374 }
375 tracing.EndSpan(ctx, sc, err)
376 }()
377 }
378 result.page, err = client.ListByCustomer(ctx, billingAccountName, customerName)
379 return
380 }
381
382
383
384
385
386
387 func (client PermissionsClient) ListByInvoiceSections(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result PermissionsListResultPage, err error) {
388 if tracing.IsEnabled() {
389 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByInvoiceSections")
390 defer func() {
391 sc := -1
392 if result.plr.Response.Response != nil {
393 sc = result.plr.Response.Response.StatusCode
394 }
395 tracing.EndSpan(ctx, sc, err)
396 }()
397 }
398 result.fn = client.listByInvoiceSectionsNextResults
399 req, err := client.ListByInvoiceSectionsPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName)
400 if err != nil {
401 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByInvoiceSections", nil, "Failure preparing request")
402 return
403 }
404
405 resp, err := client.ListByInvoiceSectionsSender(req)
406 if err != nil {
407 result.plr.Response = autorest.Response{Response: resp}
408 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByInvoiceSections", resp, "Failure sending request")
409 return
410 }
411
412 result.plr, err = client.ListByInvoiceSectionsResponder(resp)
413 if err != nil {
414 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByInvoiceSections", resp, "Failure responding to request")
415 return
416 }
417 if result.plr.hasNextLink() && result.plr.IsEmpty() {
418 err = result.NextWithContext(ctx)
419 return
420 }
421
422 return
423 }
424
425
426 func (client PermissionsClient) ListByInvoiceSectionsPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (*http.Request, error) {
427 pathParameters := map[string]interface{}{
428 "billingAccountName": autorest.Encode("path", billingAccountName),
429 "billingProfileName": autorest.Encode("path", billingProfileName),
430 "invoiceSectionName": autorest.Encode("path", invoiceSectionName),
431 }
432
433 const APIVersion = "2020-05-01"
434 queryParameters := map[string]interface{}{
435 "api-version": APIVersion,
436 }
437
438 preparer := autorest.CreatePreparer(
439 autorest.AsGet(),
440 autorest.WithBaseURL(client.BaseURI),
441 autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions", pathParameters),
442 autorest.WithQueryParameters(queryParameters))
443 return preparer.Prepare((&http.Request{}).WithContext(ctx))
444 }
445
446
447
448 func (client PermissionsClient) ListByInvoiceSectionsSender(req *http.Request) (*http.Response, error) {
449 return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
450 }
451
452
453
454 func (client PermissionsClient) ListByInvoiceSectionsResponder(resp *http.Response) (result PermissionsListResult, err error) {
455 err = autorest.Respond(
456 resp,
457 azure.WithErrorUnlessStatusCode(http.StatusOK),
458 autorest.ByUnmarshallingJSON(&result),
459 autorest.ByClosing())
460 result.Response = autorest.Response{Response: resp}
461 return
462 }
463
464
465 func (client PermissionsClient) listByInvoiceSectionsNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) {
466 req, err := lastResults.permissionsListResultPreparer(ctx)
467 if err != nil {
468 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByInvoiceSectionsNextResults", nil, "Failure preparing next results request")
469 }
470 if req == nil {
471 return
472 }
473 resp, err := client.ListByInvoiceSectionsSender(req)
474 if err != nil {
475 result.Response = autorest.Response{Response: resp}
476 return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByInvoiceSectionsNextResults", resp, "Failure sending next results request")
477 }
478 result, err = client.ListByInvoiceSectionsResponder(resp)
479 if err != nil {
480 err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByInvoiceSectionsNextResults", resp, "Failure responding to next results request")
481 }
482 return
483 }
484
485
486 func (client PermissionsClient) ListByInvoiceSectionsComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result PermissionsListResultIterator, err error) {
487 if tracing.IsEnabled() {
488 ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByInvoiceSections")
489 defer func() {
490 sc := -1
491 if result.Response().Response.Response != nil {
492 sc = result.page.Response().Response.Response.StatusCode
493 }
494 tracing.EndSpan(ctx, sc, err)
495 }()
496 }
497 result.page, err = client.ListByInvoiceSections(ctx, billingAccountName, billingProfileName, invoiceSectionName)
498 return
499 }
500
View as plain text