...

Source file src/github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2020-06-01/costmanagement/exports.go

Documentation: github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2020-06-01/costmanagement

     1  package costmanagement
     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  // ExportsClient is the client for the Exports methods of the Costmanagement service.
    19  type ExportsClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewExportsClient creates an instance of the ExportsClient client.
    24  func NewExportsClient(subscriptionID string) ExportsClient {
    25  	return NewExportsClientWithBaseURI(DefaultBaseURI, subscriptionID)
    26  }
    27  
    28  // NewExportsClientWithBaseURI creates an instance of the ExportsClient client using a custom endpoint.  Use this when
    29  // interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
    30  func NewExportsClientWithBaseURI(baseURI string, subscriptionID string) ExportsClient {
    31  	return ExportsClient{NewWithBaseURI(baseURI, subscriptionID)}
    32  }
    33  
    34  // CreateOrUpdate the operation to create or update a export. Update operation requires latest eTag to be set in the
    35  // request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag.
    36  // Parameters:
    37  // scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for
    38  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
    39  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and
    40  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
    41  // scope,
    42  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
    43  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for
    44  // Management Group scope,
    45  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
    46  // billingProfile scope,
    47  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}'
    48  // for invoiceSection scope, and
    49  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for
    50  // partners.
    51  // exportName - export Name.
    52  // parameters - parameters supplied to the CreateOrUpdate Export operation.
    53  func (client ExportsClient) CreateOrUpdate(ctx context.Context, scope string, exportName string, parameters Export) (result Export, err error) {
    54  	if tracing.IsEnabled() {
    55  		ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.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.ExportProperties", Name: validation.Null, Rule: false,
    67  				Chain: []validation.Constraint{{Target: "parameters.ExportProperties.Schedule", Name: validation.Null, Rule: false,
    68  					Chain: []validation.Constraint{{Target: "parameters.ExportProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: false,
    69  						Chain: []validation.Constraint{{Target: "parameters.ExportProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}},
    70  					}},
    71  				}}}}}); err != nil {
    72  		return result, validation.NewError("costmanagement.ExportsClient", "CreateOrUpdate", err.Error())
    73  	}
    74  
    75  	req, err := client.CreateOrUpdatePreparer(ctx, scope, exportName, parameters)
    76  	if err != nil {
    77  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "CreateOrUpdate", nil, "Failure preparing request")
    78  		return
    79  	}
    80  
    81  	resp, err := client.CreateOrUpdateSender(req)
    82  	if err != nil {
    83  		result.Response = autorest.Response{Response: resp}
    84  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "CreateOrUpdate", resp, "Failure sending request")
    85  		return
    86  	}
    87  
    88  	result, err = client.CreateOrUpdateResponder(resp)
    89  	if err != nil {
    90  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "CreateOrUpdate", resp, "Failure responding to request")
    91  		return
    92  	}
    93  
    94  	return
    95  }
    96  
    97  // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
    98  func (client ExportsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, exportName string, parameters Export) (*http.Request, error) {
    99  	pathParameters := map[string]interface{}{
   100  		"exportName": autorest.Encode("path", exportName),
   101  		"scope":      scope,
   102  	}
   103  
   104  	const APIVersion = "2020-06-01"
   105  	queryParameters := map[string]interface{}{
   106  		"api-version": APIVersion,
   107  	}
   108  
   109  	preparer := autorest.CreatePreparer(
   110  		autorest.AsContentType("application/json; charset=utf-8"),
   111  		autorest.AsPut(),
   112  		autorest.WithBaseURL(client.BaseURI),
   113  		autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}", pathParameters),
   114  		autorest.WithJSON(parameters),
   115  		autorest.WithQueryParameters(queryParameters))
   116  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   117  }
   118  
   119  // CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
   120  // http.Response Body if it receives an error.
   121  func (client ExportsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
   122  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   123  }
   124  
   125  // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
   126  // closes the http.Response Body.
   127  func (client ExportsClient) CreateOrUpdateResponder(resp *http.Response) (result Export, err error) {
   128  	err = autorest.Respond(
   129  		resp,
   130  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
   131  		autorest.ByUnmarshallingJSON(&result),
   132  		autorest.ByClosing())
   133  	result.Response = autorest.Response{Response: resp}
   134  	return
   135  }
   136  
   137  // Delete the operation to delete a export.
   138  // Parameters:
   139  // scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for
   140  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   141  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and
   142  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   143  // scope,
   144  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   145  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for
   146  // Management Group scope,
   147  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   148  // billingProfile scope,
   149  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}'
   150  // for invoiceSection scope, and
   151  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for
   152  // partners.
   153  // exportName - export Name.
   154  func (client ExportsClient) Delete(ctx context.Context, scope string, exportName string) (result autorest.Response, err error) {
   155  	if tracing.IsEnabled() {
   156  		ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.Delete")
   157  		defer func() {
   158  			sc := -1
   159  			if result.Response != nil {
   160  				sc = result.Response.StatusCode
   161  			}
   162  			tracing.EndSpan(ctx, sc, err)
   163  		}()
   164  	}
   165  	req, err := client.DeletePreparer(ctx, scope, exportName)
   166  	if err != nil {
   167  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Delete", nil, "Failure preparing request")
   168  		return
   169  	}
   170  
   171  	resp, err := client.DeleteSender(req)
   172  	if err != nil {
   173  		result.Response = resp
   174  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Delete", resp, "Failure sending request")
   175  		return
   176  	}
   177  
   178  	result, err = client.DeleteResponder(resp)
   179  	if err != nil {
   180  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Delete", resp, "Failure responding to request")
   181  		return
   182  	}
   183  
   184  	return
   185  }
   186  
   187  // DeletePreparer prepares the Delete request.
   188  func (client ExportsClient) DeletePreparer(ctx context.Context, scope string, exportName string) (*http.Request, error) {
   189  	pathParameters := map[string]interface{}{
   190  		"exportName": autorest.Encode("path", exportName),
   191  		"scope":      scope,
   192  	}
   193  
   194  	const APIVersion = "2020-06-01"
   195  	queryParameters := map[string]interface{}{
   196  		"api-version": APIVersion,
   197  	}
   198  
   199  	preparer := autorest.CreatePreparer(
   200  		autorest.AsDelete(),
   201  		autorest.WithBaseURL(client.BaseURI),
   202  		autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}", pathParameters),
   203  		autorest.WithQueryParameters(queryParameters))
   204  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   205  }
   206  
   207  // DeleteSender sends the Delete request. The method will close the
   208  // http.Response Body if it receives an error.
   209  func (client ExportsClient) DeleteSender(req *http.Request) (*http.Response, error) {
   210  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   211  }
   212  
   213  // DeleteResponder handles the response to the Delete request. The method always
   214  // closes the http.Response Body.
   215  func (client ExportsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
   216  	err = autorest.Respond(
   217  		resp,
   218  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   219  		autorest.ByClosing())
   220  	result.Response = resp
   221  	return
   222  }
   223  
   224  // Execute the operation to execute an export.
   225  // Parameters:
   226  // scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for
   227  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   228  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and
   229  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   230  // scope,
   231  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   232  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for
   233  // Management Group scope,
   234  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   235  // billingProfile scope,
   236  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}'
   237  // for invoiceSection scope, and
   238  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for
   239  // partners.
   240  // exportName - export Name.
   241  func (client ExportsClient) Execute(ctx context.Context, scope string, exportName string) (result autorest.Response, err error) {
   242  	if tracing.IsEnabled() {
   243  		ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.Execute")
   244  		defer func() {
   245  			sc := -1
   246  			if result.Response != nil {
   247  				sc = result.Response.StatusCode
   248  			}
   249  			tracing.EndSpan(ctx, sc, err)
   250  		}()
   251  	}
   252  	req, err := client.ExecutePreparer(ctx, scope, exportName)
   253  	if err != nil {
   254  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Execute", nil, "Failure preparing request")
   255  		return
   256  	}
   257  
   258  	resp, err := client.ExecuteSender(req)
   259  	if err != nil {
   260  		result.Response = resp
   261  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Execute", resp, "Failure sending request")
   262  		return
   263  	}
   264  
   265  	result, err = client.ExecuteResponder(resp)
   266  	if err != nil {
   267  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Execute", resp, "Failure responding to request")
   268  		return
   269  	}
   270  
   271  	return
   272  }
   273  
   274  // ExecutePreparer prepares the Execute request.
   275  func (client ExportsClient) ExecutePreparer(ctx context.Context, scope string, exportName string) (*http.Request, error) {
   276  	pathParameters := map[string]interface{}{
   277  		"exportName": autorest.Encode("path", exportName),
   278  		"scope":      scope,
   279  	}
   280  
   281  	const APIVersion = "2020-06-01"
   282  	queryParameters := map[string]interface{}{
   283  		"api-version": APIVersion,
   284  	}
   285  
   286  	preparer := autorest.CreatePreparer(
   287  		autorest.AsPost(),
   288  		autorest.WithBaseURL(client.BaseURI),
   289  		autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run", pathParameters),
   290  		autorest.WithQueryParameters(queryParameters))
   291  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   292  }
   293  
   294  // ExecuteSender sends the Execute request. The method will close the
   295  // http.Response Body if it receives an error.
   296  func (client ExportsClient) ExecuteSender(req *http.Request) (*http.Response, error) {
   297  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   298  }
   299  
   300  // ExecuteResponder handles the response to the Execute request. The method always
   301  // closes the http.Response Body.
   302  func (client ExportsClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) {
   303  	err = autorest.Respond(
   304  		resp,
   305  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   306  		autorest.ByClosing())
   307  	result.Response = resp
   308  	return
   309  }
   310  
   311  // Get the operation to get the export for the defined scope by export name.
   312  // Parameters:
   313  // scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for
   314  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   315  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and
   316  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   317  // scope,
   318  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   319  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for
   320  // Management Group scope,
   321  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   322  // billingProfile scope,
   323  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}'
   324  // for invoiceSection scope, and
   325  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for
   326  // partners.
   327  // exportName - export Name.
   328  // expand - may be used to expand the properties within an export. Currently only 'runHistory' is supported and
   329  // will return information for the last 10 executions of the export.
   330  func (client ExportsClient) Get(ctx context.Context, scope string, exportName string, expand string) (result Export, err error) {
   331  	if tracing.IsEnabled() {
   332  		ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.Get")
   333  		defer func() {
   334  			sc := -1
   335  			if result.Response.Response != nil {
   336  				sc = result.Response.Response.StatusCode
   337  			}
   338  			tracing.EndSpan(ctx, sc, err)
   339  		}()
   340  	}
   341  	req, err := client.GetPreparer(ctx, scope, exportName, expand)
   342  	if err != nil {
   343  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Get", nil, "Failure preparing request")
   344  		return
   345  	}
   346  
   347  	resp, err := client.GetSender(req)
   348  	if err != nil {
   349  		result.Response = autorest.Response{Response: resp}
   350  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Get", resp, "Failure sending request")
   351  		return
   352  	}
   353  
   354  	result, err = client.GetResponder(resp)
   355  	if err != nil {
   356  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Get", resp, "Failure responding to request")
   357  		return
   358  	}
   359  
   360  	return
   361  }
   362  
   363  // GetPreparer prepares the Get request.
   364  func (client ExportsClient) GetPreparer(ctx context.Context, scope string, exportName string, expand string) (*http.Request, error) {
   365  	pathParameters := map[string]interface{}{
   366  		"exportName": autorest.Encode("path", exportName),
   367  		"scope":      scope,
   368  	}
   369  
   370  	const APIVersion = "2020-06-01"
   371  	queryParameters := map[string]interface{}{
   372  		"api-version": APIVersion,
   373  	}
   374  	if len(expand) > 0 {
   375  		queryParameters["$expand"] = autorest.Encode("query", expand)
   376  	}
   377  
   378  	preparer := autorest.CreatePreparer(
   379  		autorest.AsGet(),
   380  		autorest.WithBaseURL(client.BaseURI),
   381  		autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}", pathParameters),
   382  		autorest.WithQueryParameters(queryParameters))
   383  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   384  }
   385  
   386  // GetSender sends the Get request. The method will close the
   387  // http.Response Body if it receives an error.
   388  func (client ExportsClient) GetSender(req *http.Request) (*http.Response, error) {
   389  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   390  }
   391  
   392  // GetResponder handles the response to the Get request. The method always
   393  // closes the http.Response Body.
   394  func (client ExportsClient) GetResponder(resp *http.Response) (result Export, err error) {
   395  	err = autorest.Respond(
   396  		resp,
   397  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   398  		autorest.ByUnmarshallingJSON(&result),
   399  		autorest.ByClosing())
   400  	result.Response = autorest.Response{Response: resp}
   401  	return
   402  }
   403  
   404  // GetExecutionHistory the operation to get the execution history of an export for the defined scope and export name.
   405  // Parameters:
   406  // scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for
   407  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   408  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and
   409  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   410  // scope,
   411  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   412  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for
   413  // Management Group scope,
   414  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   415  // billingProfile scope,
   416  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}'
   417  // for invoiceSection scope, and
   418  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for
   419  // partners.
   420  // exportName - export Name.
   421  func (client ExportsClient) GetExecutionHistory(ctx context.Context, scope string, exportName string) (result ExportExecutionListResult, err error) {
   422  	if tracing.IsEnabled() {
   423  		ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.GetExecutionHistory")
   424  		defer func() {
   425  			sc := -1
   426  			if result.Response.Response != nil {
   427  				sc = result.Response.Response.StatusCode
   428  			}
   429  			tracing.EndSpan(ctx, sc, err)
   430  		}()
   431  	}
   432  	req, err := client.GetExecutionHistoryPreparer(ctx, scope, exportName)
   433  	if err != nil {
   434  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "GetExecutionHistory", nil, "Failure preparing request")
   435  		return
   436  	}
   437  
   438  	resp, err := client.GetExecutionHistorySender(req)
   439  	if err != nil {
   440  		result.Response = autorest.Response{Response: resp}
   441  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "GetExecutionHistory", resp, "Failure sending request")
   442  		return
   443  	}
   444  
   445  	result, err = client.GetExecutionHistoryResponder(resp)
   446  	if err != nil {
   447  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "GetExecutionHistory", resp, "Failure responding to request")
   448  		return
   449  	}
   450  
   451  	return
   452  }
   453  
   454  // GetExecutionHistoryPreparer prepares the GetExecutionHistory request.
   455  func (client ExportsClient) GetExecutionHistoryPreparer(ctx context.Context, scope string, exportName string) (*http.Request, error) {
   456  	pathParameters := map[string]interface{}{
   457  		"exportName": autorest.Encode("path", exportName),
   458  		"scope":      scope,
   459  	}
   460  
   461  	const APIVersion = "2020-06-01"
   462  	queryParameters := map[string]interface{}{
   463  		"api-version": APIVersion,
   464  	}
   465  
   466  	preparer := autorest.CreatePreparer(
   467  		autorest.AsGet(),
   468  		autorest.WithBaseURL(client.BaseURI),
   469  		autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory", pathParameters),
   470  		autorest.WithQueryParameters(queryParameters))
   471  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   472  }
   473  
   474  // GetExecutionHistorySender sends the GetExecutionHistory request. The method will close the
   475  // http.Response Body if it receives an error.
   476  func (client ExportsClient) GetExecutionHistorySender(req *http.Request) (*http.Response, error) {
   477  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   478  }
   479  
   480  // GetExecutionHistoryResponder handles the response to the GetExecutionHistory request. The method always
   481  // closes the http.Response Body.
   482  func (client ExportsClient) GetExecutionHistoryResponder(resp *http.Response) (result ExportExecutionListResult, err error) {
   483  	err = autorest.Respond(
   484  		resp,
   485  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   486  		autorest.ByUnmarshallingJSON(&result),
   487  		autorest.ByClosing())
   488  	result.Response = autorest.Response{Response: resp}
   489  	return
   490  }
   491  
   492  // List the operation to list all exports at the given scope.
   493  // Parameters:
   494  // scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for
   495  // subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup
   496  // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and
   497  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department
   498  // scope,
   499  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}'
   500  // for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for
   501  // Management Group scope,
   502  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for
   503  // billingProfile scope,
   504  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}'
   505  // for invoiceSection scope, and
   506  // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for
   507  // partners.
   508  // expand - may be used to expand the properties within an export. Currently only 'runHistory' is supported and
   509  // will return information for the last execution of each export.
   510  func (client ExportsClient) List(ctx context.Context, scope string, expand string) (result ExportListResult, err error) {
   511  	if tracing.IsEnabled() {
   512  		ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.List")
   513  		defer func() {
   514  			sc := -1
   515  			if result.Response.Response != nil {
   516  				sc = result.Response.Response.StatusCode
   517  			}
   518  			tracing.EndSpan(ctx, sc, err)
   519  		}()
   520  	}
   521  	req, err := client.ListPreparer(ctx, scope, expand)
   522  	if err != nil {
   523  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "List", nil, "Failure preparing request")
   524  		return
   525  	}
   526  
   527  	resp, err := client.ListSender(req)
   528  	if err != nil {
   529  		result.Response = autorest.Response{Response: resp}
   530  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "List", resp, "Failure sending request")
   531  		return
   532  	}
   533  
   534  	result, err = client.ListResponder(resp)
   535  	if err != nil {
   536  		err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "List", resp, "Failure responding to request")
   537  		return
   538  	}
   539  
   540  	return
   541  }
   542  
   543  // ListPreparer prepares the List request.
   544  func (client ExportsClient) ListPreparer(ctx context.Context, scope string, expand string) (*http.Request, error) {
   545  	pathParameters := map[string]interface{}{
   546  		"scope": scope,
   547  	}
   548  
   549  	const APIVersion = "2020-06-01"
   550  	queryParameters := map[string]interface{}{
   551  		"api-version": APIVersion,
   552  	}
   553  	if len(expand) > 0 {
   554  		queryParameters["$expand"] = autorest.Encode("query", expand)
   555  	}
   556  
   557  	preparer := autorest.CreatePreparer(
   558  		autorest.AsGet(),
   559  		autorest.WithBaseURL(client.BaseURI),
   560  		autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports", pathParameters),
   561  		autorest.WithQueryParameters(queryParameters))
   562  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   563  }
   564  
   565  // ListSender sends the List request. The method will close the
   566  // http.Response Body if it receives an error.
   567  func (client ExportsClient) ListSender(req *http.Request) (*http.Response, error) {
   568  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   569  }
   570  
   571  // ListResponder handles the response to the List request. The method always
   572  // closes the http.Response Body.
   573  func (client ExportsClient) ListResponder(resp *http.Response) (result ExportListResult, err error) {
   574  	err = autorest.Respond(
   575  		resp,
   576  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   577  		autorest.ByUnmarshallingJSON(&result),
   578  		autorest.ByClosing())
   579  	result.Response = autorest.Response{Response: resp}
   580  	return
   581  }
   582  

View as plain text