...

Source file src/github.com/Azure/azure-sdk-for-go/services/consumption/mgmt/2019-10-01/consumption/budgets.go

Documentation: github.com/Azure/azure-sdk-for-go/services/consumption/mgmt/2019-10-01/consumption

     1  package consumption
     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  
     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  // BudgetsClient is the consumption management client provides access to consumption resources for Azure Enterprise
    19  // Subscriptions.
    20  type BudgetsClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewBudgetsClient creates an instance of the BudgetsClient client.
    25  func NewBudgetsClient(subscriptionID string) BudgetsClient {
    26  	return NewBudgetsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    27  }
    28  
    29  // NewBudgetsClientWithBaseURI creates an instance of the BudgetsClient client using a custom endpoint.  Use this when
    30  // interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    31  func NewBudgetsClientWithBaseURI(baseURI string, subscriptionID string) BudgetsClient {
    32  	return BudgetsClient{NewWithBaseURI(baseURI, subscriptionID)}
    33  }
    34  
    35  // CreateOrUpdate the operation to create or update a budget. You can optionally provide an eTag if desired as a form
    36  // of concurrency control. To obtain the latest eTag for a given budget, perform a get operation prior to your put
    37  // operation.
    38  // Parameters:
    39  // scope - the scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for
    40  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
    41  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope,
    42  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
    43  // scope,
    44  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
    45  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for
    46  // Management Group scope,
    47  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
    48  // billingProfile scope,
    49  // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for
    50  // invoiceSection scope.
    51  // budgetName - budget Name.
    52  // parameters - parameters supplied to the Create Budget operation.
    53  func (client BudgetsClient) CreateOrUpdate(ctx context.Context, scope string, budgetName string, parameters Budget) (result Budget, err error) {
    54  	if tracing.IsEnabled() {
    55  		ctx = tracing.StartSpan(ctx, fqdn+"/BudgetsClient.CreateOrUpdate")
    56  		defer func() {
    57  			sc := -1
    58  			if result.Response.Response != nil {
    59  				sc = result.Response.Response.StatusCode
    60  			}
    61  			tracing.EndSpan(ctx, sc, err)
    62  		}()
    63  	}
    64  	if err := validation.Validate([]validation.Validation{
    65  		{TargetValue: parameters,
    66  			Constraints: []validation.Constraint{{Target: "parameters.BudgetProperties", Name: validation.Null, Rule: false,
    67  				Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Category", Name: validation.Null, Rule: true, Chain: nil},
    68  					{Target: "parameters.BudgetProperties.Amount", Name: validation.Null, Rule: true, Chain: nil},
    69  					{Target: "parameters.BudgetProperties.TimePeriod", Name: validation.Null, Rule: true,
    70  						Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.TimePeriod.StartDate", Name: validation.Null, Rule: true, Chain: nil}}},
    71  					{Target: "parameters.BudgetProperties.Filter", Name: validation.Null, Rule: false,
    72  						Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.And", Name: validation.Null, Rule: false,
    73  							Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.And", Name: validation.MinItems, Rule: 0, Chain: nil}}},
    74  							{Target: "parameters.BudgetProperties.Filter.Not", Name: validation.Null, Rule: false,
    75  								Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Not.Dimensions", Name: validation.Null, Rule: false,
    76  									Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Not.Dimensions.Name", Name: validation.Null, Rule: true, Chain: nil},
    77  										{Target: "parameters.BudgetProperties.Filter.Not.Dimensions.Operator", Name: validation.Null, Rule: true, Chain: nil},
    78  										{Target: "parameters.BudgetProperties.Filter.Not.Dimensions.Values", Name: validation.Null, Rule: true,
    79  											Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Not.Dimensions.Values", Name: validation.MinItems, Rule: 0, Chain: nil}}},
    80  									}},
    81  									{Target: "parameters.BudgetProperties.Filter.Not.Tags", Name: validation.Null, Rule: false,
    82  										Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Not.Tags.Name", Name: validation.Null, Rule: true, Chain: nil},
    83  											{Target: "parameters.BudgetProperties.Filter.Not.Tags.Operator", Name: validation.Null, Rule: true, Chain: nil},
    84  											{Target: "parameters.BudgetProperties.Filter.Not.Tags.Values", Name: validation.Null, Rule: true,
    85  												Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Not.Tags.Values", Name: validation.MinItems, Rule: 0, Chain: nil}}},
    86  										}},
    87  								}},
    88  							{Target: "parameters.BudgetProperties.Filter.Dimensions", Name: validation.Null, Rule: false,
    89  								Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Dimensions.Name", Name: validation.Null, Rule: true, Chain: nil},
    90  									{Target: "parameters.BudgetProperties.Filter.Dimensions.Operator", Name: validation.Null, Rule: true, Chain: nil},
    91  									{Target: "parameters.BudgetProperties.Filter.Dimensions.Values", Name: validation.Null, Rule: true,
    92  										Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Dimensions.Values", Name: validation.MinItems, Rule: 0, Chain: nil}}},
    93  								}},
    94  							{Target: "parameters.BudgetProperties.Filter.Tags", Name: validation.Null, Rule: false,
    95  								Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Tags.Name", Name: validation.Null, Rule: true, Chain: nil},
    96  									{Target: "parameters.BudgetProperties.Filter.Tags.Operator", Name: validation.Null, Rule: true, Chain: nil},
    97  									{Target: "parameters.BudgetProperties.Filter.Tags.Values", Name: validation.Null, Rule: true,
    98  										Chain: []validation.Constraint{{Target: "parameters.BudgetProperties.Filter.Tags.Values", Name: validation.MinItems, Rule: 0, Chain: nil}}},
    99  								}},
   100  						}},
   101  				}}}}}); err != nil {
   102  		return result, validation.NewError("consumption.BudgetsClient", "CreateOrUpdate", err.Error())
   103  	}
   104  
   105  	req, err := client.CreateOrUpdatePreparer(ctx, scope, budgetName, parameters)
   106  	if err != nil {
   107  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "CreateOrUpdate", nil, "Failure preparing request")
   108  		return
   109  	}
   110  
   111  	resp, err := client.CreateOrUpdateSender(req)
   112  	if err != nil {
   113  		result.Response = autorest.Response{Response: resp}
   114  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "CreateOrUpdate", resp, "Failure sending request")
   115  		return
   116  	}
   117  
   118  	result, err = client.CreateOrUpdateResponder(resp)
   119  	if err != nil {
   120  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "CreateOrUpdate", resp, "Failure responding to request")
   121  		return
   122  	}
   123  
   124  	return
   125  }
   126  
   127  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
   128  func (client BudgetsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, budgetName string, parameters Budget) (*http.Request, error) {
   129  	pathParameters := map[string]interface{}{
   130  		"budgetName": autorest.Encode("path", budgetName),
   131  		"scope":      scope,
   132  	}
   133  
   134  	const APIVersion = "2019-10-01"
   135  	queryParameters := map[string]interface{}{
   136  		"api-version": APIVersion,
   137  	}
   138  
   139  	preparer := autorest.CreatePreparer(
   140  		autorest.AsContentType("application/json; charset=utf-8"),
   141  		autorest.AsPut(),
   142  		autorest.WithBaseURL(client.BaseURI),
   143  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}", pathParameters),
   144  		autorest.WithJSON(parameters),
   145  		autorest.WithQueryParameters(queryParameters))
   146  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   147  }
   148  
   149  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   150  // http.Response Body if it receives an error.
   151  func (client BudgetsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   152  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   153  }
   154  
   155  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   156  // closes the http.Response Body.
   157  func (client BudgetsClient) CreateOrUpdateResponder(resp *http.Response) (result Budget, err error) {
   158  	err = autorest.Respond(
   159  		resp,
   160  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   161  		autorest.ByUnmarshallingJSON(&result),
   162  		autorest.ByClosing())
   163  	result.Response = autorest.Response{Response: resp}
   164  	return
   165  }
   166  
   167  // Delete the operation to delete a budget.
   168  // Parameters:
   169  // scope - the scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for
   170  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   171  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope,
   172  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   173  // scope,
   174  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   175  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for
   176  // Management Group scope,
   177  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   178  // billingProfile scope,
   179  // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for
   180  // invoiceSection scope.
   181  // budgetName - budget Name.
   182  func (client BudgetsClient) Delete(ctx context.Context, scope string, budgetName string) (result autorest.Response, err error) {
   183  	if tracing.IsEnabled() {
   184  		ctx = tracing.StartSpan(ctx, fqdn+"/BudgetsClient.Delete")
   185  		defer func() {
   186  			sc := -1
   187  			if result.Response != nil {
   188  				sc = result.Response.StatusCode
   189  			}
   190  			tracing.EndSpan(ctx, sc, err)
   191  		}()
   192  	}
   193  	req, err := client.DeletePreparer(ctx, scope, budgetName)
   194  	if err != nil {
   195  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "Delete", nil, "Failure preparing request")
   196  		return
   197  	}
   198  
   199  	resp, err := client.DeleteSender(req)
   200  	if err != nil {
   201  		result.Response = resp
   202  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "Delete", resp, "Failure sending request")
   203  		return
   204  	}
   205  
   206  	result, err = client.DeleteResponder(resp)
   207  	if err != nil {
   208  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "Delete", resp, "Failure responding to request")
   209  		return
   210  	}
   211  
   212  	return
   213  }
   214  
   215  // DeletePreparer prepares the Delete request.
   216  func (client BudgetsClient) DeletePreparer(ctx context.Context, scope string, budgetName string) (*http.Request, error) {
   217  	pathParameters := map[string]interface{}{
   218  		"budgetName": autorest.Encode("path", budgetName),
   219  		"scope":      scope,
   220  	}
   221  
   222  	const APIVersion = "2019-10-01"
   223  	queryParameters := map[string]interface{}{
   224  		"api-version": APIVersion,
   225  	}
   226  
   227  	preparer := autorest.CreatePreparer(
   228  		autorest.AsDelete(),
   229  		autorest.WithBaseURL(client.BaseURI),
   230  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}", pathParameters),
   231  		autorest.WithQueryParameters(queryParameters))
   232  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   233  }
   234  
   235  // DeleteSender sends the Delete request. The method will close the
   236  // http.Response Body if it receives an error.
   237  func (client BudgetsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   238  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   239  }
   240  
   241  // DeleteResponder handles the response to the Delete request. The method always
   242  // closes the http.Response Body.
   243  func (client BudgetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   244  	err = autorest.Respond(
   245  		resp,
   246  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   247  		autorest.ByClosing())
   248  	result.Response = resp
   249  	return
   250  }
   251  
   252  // Get gets the budget for the scope by budget name.
   253  // Parameters:
   254  // scope - the scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for
   255  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   256  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope,
   257  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   258  // scope,
   259  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   260  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for
   261  // Management Group scope,
   262  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   263  // billingProfile scope,
   264  // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for
   265  // invoiceSection scope.
   266  // budgetName - budget Name.
   267  func (client BudgetsClient) Get(ctx context.Context, scope string, budgetName string) (result Budget, err error) {
   268  	if tracing.IsEnabled() {
   269  		ctx = tracing.StartSpan(ctx, fqdn+"/BudgetsClient.Get")
   270  		defer func() {
   271  			sc := -1
   272  			if result.Response.Response != nil {
   273  				sc = result.Response.Response.StatusCode
   274  			}
   275  			tracing.EndSpan(ctx, sc, err)
   276  		}()
   277  	}
   278  	req, err := client.GetPreparer(ctx, scope, budgetName)
   279  	if err != nil {
   280  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "Get", nil, "Failure preparing request")
   281  		return
   282  	}
   283  
   284  	resp, err := client.GetSender(req)
   285  	if err != nil {
   286  		result.Response = autorest.Response{Response: resp}
   287  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "Get", resp, "Failure sending request")
   288  		return
   289  	}
   290  
   291  	result, err = client.GetResponder(resp)
   292  	if err != nil {
   293  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "Get", resp, "Failure responding to request")
   294  		return
   295  	}
   296  
   297  	return
   298  }
   299  
   300  // GetPreparer prepares the Get request.
   301  func (client BudgetsClient) GetPreparer(ctx context.Context, scope string, budgetName string) (*http.Request, error) {
   302  	pathParameters := map[string]interface{}{
   303  		"budgetName": autorest.Encode("path", budgetName),
   304  		"scope":      scope,
   305  	}
   306  
   307  	const APIVersion = "2019-10-01"
   308  	queryParameters := map[string]interface{}{
   309  		"api-version": APIVersion,
   310  	}
   311  
   312  	preparer := autorest.CreatePreparer(
   313  		autorest.AsGet(),
   314  		autorest.WithBaseURL(client.BaseURI),
   315  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}", pathParameters),
   316  		autorest.WithQueryParameters(queryParameters))
   317  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   318  }
   319  
   320  // GetSender sends the Get request. The method will close the
   321  // http.Response Body if it receives an error.
   322  func (client BudgetsClient) GetSender(req *http.Request) (*http.Response, error) {
   323  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   324  }
   325  
   326  // GetResponder handles the response to the Get request. The method always
   327  // closes the http.Response Body.
   328  func (client BudgetsClient) GetResponder(resp *http.Response) (result Budget, err error) {
   329  	err = autorest.Respond(
   330  		resp,
   331  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   332  		autorest.ByUnmarshallingJSON(&result),
   333  		autorest.ByClosing())
   334  	result.Response = autorest.Response{Response: resp}
   335  	return
   336  }
   337  
   338  // List lists all budgets for the defined scope.
   339  // Parameters:
   340  // scope - the scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for
   341  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   342  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope,
   343  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   344  // scope,
   345  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   346  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for
   347  // Management Group scope,
   348  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   349  // billingProfile scope,
   350  // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for
   351  // invoiceSection scope.
   352  func (client BudgetsClient) List(ctx context.Context, scope string) (result BudgetsListResultPage, err error) {
   353  	if tracing.IsEnabled() {
   354  		ctx = tracing.StartSpan(ctx, fqdn+"/BudgetsClient.List")
   355  		defer func() {
   356  			sc := -1
   357  			if result.blr.Response.Response != nil {
   358  				sc = result.blr.Response.Response.StatusCode
   359  			}
   360  			tracing.EndSpan(ctx, sc, err)
   361  		}()
   362  	}
   363  	result.fn = client.listNextResults
   364  	req, err := client.ListPreparer(ctx, scope)
   365  	if err != nil {
   366  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "List", nil, "Failure preparing request")
   367  		return
   368  	}
   369  
   370  	resp, err := client.ListSender(req)
   371  	if err != nil {
   372  		result.blr.Response = autorest.Response{Response: resp}
   373  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "List", resp, "Failure sending request")
   374  		return
   375  	}
   376  
   377  	result.blr, err = client.ListResponder(resp)
   378  	if err != nil {
   379  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "List", resp, "Failure responding to request")
   380  		return
   381  	}
   382  	if result.blr.hasNextLink() && result.blr.IsEmpty() {
   383  		err = result.NextWithContext(ctx)
   384  		return
   385  	}
   386  
   387  	return
   388  }
   389  
   390  // ListPreparer prepares the List request.
   391  func (client BudgetsClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) {
   392  	pathParameters := map[string]interface{}{
   393  		"scope": scope,
   394  	}
   395  
   396  	const APIVersion = "2019-10-01"
   397  	queryParameters := map[string]interface{}{
   398  		"api-version": APIVersion,
   399  	}
   400  
   401  	preparer := autorest.CreatePreparer(
   402  		autorest.AsGet(),
   403  		autorest.WithBaseURL(client.BaseURI),
   404  		autorest.WithPathParameters("/{scope}/providers/Microsoft.Consumption/budgets", pathParameters),
   405  		autorest.WithQueryParameters(queryParameters))
   406  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   407  }
   408  
   409  // ListSender sends the List request. The method will close the
   410  // http.Response Body if it receives an error.
   411  func (client BudgetsClient) ListSender(req *http.Request) (*http.Response, error) {
   412  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   413  }
   414  
   415  // ListResponder handles the response to the List request. The method always
   416  // closes the http.Response Body.
   417  func (client BudgetsClient) ListResponder(resp *http.Response) (result BudgetsListResult, err error) {
   418  	err = autorest.Respond(
   419  		resp,
   420  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   421  		autorest.ByUnmarshallingJSON(&result),
   422  		autorest.ByClosing())
   423  	result.Response = autorest.Response{Response: resp}
   424  	return
   425  }
   426  
   427  // listNextResults retrieves the next set of results, if any.
   428  func (client BudgetsClient) listNextResults(ctx context.Context, lastResults BudgetsListResult) (result BudgetsListResult, err error) {
   429  	req, err := lastResults.budgetsListResultPreparer(ctx)
   430  	if err != nil {
   431  		return result, autorest.NewErrorWithError(err, "consumption.BudgetsClient", "listNextResults", nil, "Failure preparing next results request")
   432  	}
   433  	if req == nil {
   434  		return
   435  	}
   436  	resp, err := client.ListSender(req)
   437  	if err != nil {
   438  		result.Response = autorest.Response{Response: resp}
   439  		return result, autorest.NewErrorWithError(err, "consumption.BudgetsClient", "listNextResults", resp, "Failure sending next results request")
   440  	}
   441  	result, err = client.ListResponder(resp)
   442  	if err != nil {
   443  		err = autorest.NewErrorWithError(err, "consumption.BudgetsClient", "listNextResults", resp, "Failure responding to next results request")
   444  	}
   445  	return
   446  }
   447  
   448  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   449  func (client BudgetsClient) ListComplete(ctx context.Context, scope string) (result BudgetsListResultIterator, err error) {
   450  	if tracing.IsEnabled() {
   451  		ctx = tracing.StartSpan(ctx, fqdn+"/BudgetsClient.List")
   452  		defer func() {
   453  			sc := -1
   454  			if result.Response().Response.Response != nil {
   455  				sc = result.page.Response().Response.Response.StatusCode
   456  			}
   457  			tracing.EndSpan(ctx, sc, err)
   458  		}()
   459  	}
   460  	result.page, err = client.List(ctx, scope)
   461  	return
   462  }
   463  

View as plain text