...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/datalake/analytics/2015-11-01-preview/job/job.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/datalake/analytics/2015-11-01-preview/job

     1  package job
     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  	"github.com/gofrs/uuid"
    16  	"net/http"
    17  )
    18  
    19  // Client is the creates an Azure Data Lake Analytics job client.
    20  type Client struct {
    21  	BaseClient
    22  }
    23  
    24  // NewClient creates an instance of the Client client.
    25  func NewClient() Client {
    26  	return Client{New()}
    27  }
    28  
    29  // Build builds (compiles) the specified job in the specified Data Lake Analytics account for job correctness and
    30  // validation.
    31  // Parameters:
    32  // accountName - the Azure Data Lake Analytics account to execute job operations on.
    33  // parameters - the parameters to build a job.
    34  func (client Client) Build(ctx context.Context, accountName string, parameters Information) (result Information, err error) {
    35  	if tracing.IsEnabled() {
    36  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Build")
    37  		defer func() {
    38  			sc := -1
    39  			if result.Response.Response != nil {
    40  				sc = result.Response.Response.StatusCode
    41  			}
    42  			tracing.EndSpan(ctx, sc, err)
    43  		}()
    44  	}
    45  	if err := validation.Validate([]validation.Validation{
    46  		{TargetValue: parameters,
    47  			Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
    48  		return result, validation.NewError("job.Client", "Build", err.Error())
    49  	}
    50  
    51  	req, err := client.BuildPreparer(ctx, accountName, parameters)
    52  	if err != nil {
    53  		err = autorest.NewErrorWithError(err, "job.Client", "Build", nil, "Failure preparing request")
    54  		return
    55  	}
    56  
    57  	resp, err := client.BuildSender(req)
    58  	if err != nil {
    59  		result.Response = autorest.Response{Response: resp}
    60  		err = autorest.NewErrorWithError(err, "job.Client", "Build", resp, "Failure sending request")
    61  		return
    62  	}
    63  
    64  	result, err = client.BuildResponder(resp)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "job.Client", "Build", resp, "Failure responding to request")
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // BuildPreparer prepares the Build request.
    74  func (client Client) BuildPreparer(ctx context.Context, accountName string, parameters Information) (*http.Request, error) {
    75  	urlParameters := map[string]interface{}{
    76  		"accountName":      accountName,
    77  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
    78  	}
    79  
    80  	const APIVersion = "2015-11-01-preview"
    81  	queryParameters := map[string]interface{}{
    82  		"api-version": APIVersion,
    83  	}
    84  
    85  	parameters.ErrorMessage = nil
    86  	parameters.SubmitTime = nil
    87  	parameters.StartTime = nil
    88  	parameters.EndTime = nil
    89  	parameters.State = ""
    90  	parameters.Result = ""
    91  	parameters.StateAuditRecords = nil
    92  	parameters.HierarchyQueueNode = nil
    93  	preparer := autorest.CreatePreparer(
    94  		autorest.AsContentType("application/json; charset=utf-8"),
    95  		autorest.AsPost(),
    96  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
    97  		autorest.WithPath("/BuildJob"),
    98  		autorest.WithJSON(parameters),
    99  		autorest.WithQueryParameters(queryParameters))
   100  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   101  }
   102  
   103  // BuildSender sends the Build request. The method will close the
   104  // http.Response Body if it receives an error.
   105  func (client Client) BuildSender(req *http.Request) (*http.Response, error) {
   106  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   107  }
   108  
   109  // BuildResponder handles the response to the Build request. The method always
   110  // closes the http.Response Body.
   111  func (client Client) BuildResponder(resp *http.Response) (result Information, err error) {
   112  	err = autorest.Respond(
   113  		resp,
   114  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   115  		autorest.ByUnmarshallingJSON(&result),
   116  		autorest.ByClosing())
   117  	result.Response = autorest.Response{Response: resp}
   118  	return
   119  }
   120  
   121  // Cancel cancels the running job specified by the job ID.
   122  // Parameters:
   123  // accountName - the Azure Data Lake Analytics account to execute job operations on.
   124  // jobIdentity - jobInfo ID to cancel.
   125  func (client Client) Cancel(ctx context.Context, accountName string, jobIdentity uuid.UUID) (result autorest.Response, err error) {
   126  	if tracing.IsEnabled() {
   127  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Cancel")
   128  		defer func() {
   129  			sc := -1
   130  			if result.Response != nil {
   131  				sc = result.Response.StatusCode
   132  			}
   133  			tracing.EndSpan(ctx, sc, err)
   134  		}()
   135  	}
   136  	req, err := client.CancelPreparer(ctx, accountName, jobIdentity)
   137  	if err != nil {
   138  		err = autorest.NewErrorWithError(err, "job.Client", "Cancel", nil, "Failure preparing request")
   139  		return
   140  	}
   141  
   142  	resp, err := client.CancelSender(req)
   143  	if err != nil {
   144  		result.Response = resp
   145  		err = autorest.NewErrorWithError(err, "job.Client", "Cancel", resp, "Failure sending request")
   146  		return
   147  	}
   148  
   149  	result, err = client.CancelResponder(resp)
   150  	if err != nil {
   151  		err = autorest.NewErrorWithError(err, "job.Client", "Cancel", resp, "Failure responding to request")
   152  		return
   153  	}
   154  
   155  	return
   156  }
   157  
   158  // CancelPreparer prepares the Cancel request.
   159  func (client Client) CancelPreparer(ctx context.Context, accountName string, jobIdentity uuid.UUID) (*http.Request, error) {
   160  	urlParameters := map[string]interface{}{
   161  		"accountName":      accountName,
   162  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
   163  	}
   164  
   165  	pathParameters := map[string]interface{}{
   166  		"jobIdentity": autorest.Encode("path", jobIdentity),
   167  	}
   168  
   169  	const APIVersion = "2015-11-01-preview"
   170  	queryParameters := map[string]interface{}{
   171  		"api-version": APIVersion,
   172  	}
   173  
   174  	preparer := autorest.CreatePreparer(
   175  		autorest.AsPost(),
   176  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
   177  		autorest.WithPathParameters("/Jobs/{jobIdentity}/CancelJob", pathParameters),
   178  		autorest.WithQueryParameters(queryParameters))
   179  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   180  }
   181  
   182  // CancelSender sends the Cancel request. The method will close the
   183  // http.Response Body if it receives an error.
   184  func (client Client) CancelSender(req *http.Request) (*http.Response, error) {
   185  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   186  }
   187  
   188  // CancelResponder handles the response to the Cancel request. The method always
   189  // closes the http.Response Body.
   190  func (client Client) CancelResponder(resp *http.Response) (result autorest.Response, err error) {
   191  	err = autorest.Respond(
   192  		resp,
   193  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   194  		autorest.ByClosing())
   195  	result.Response = resp
   196  	return
   197  }
   198  
   199  // Create submits a job to the specified Data Lake Analytics account.
   200  // Parameters:
   201  // accountName - the Azure Data Lake Analytics account to execute job operations on.
   202  // jobIdentity - the job ID (a GUID) for the job being submitted.
   203  // parameters - the parameters to submit a job.
   204  func (client Client) Create(ctx context.Context, accountName string, jobIdentity uuid.UUID, parameters Information) (result Information, err error) {
   205  	if tracing.IsEnabled() {
   206  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Create")
   207  		defer func() {
   208  			sc := -1
   209  			if result.Response.Response != nil {
   210  				sc = result.Response.Response.StatusCode
   211  			}
   212  			tracing.EndSpan(ctx, sc, err)
   213  		}()
   214  	}
   215  	if err := validation.Validate([]validation.Validation{
   216  		{TargetValue: parameters,
   217  			Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   218  		return result, validation.NewError("job.Client", "Create", err.Error())
   219  	}
   220  
   221  	req, err := client.CreatePreparer(ctx, accountName, jobIdentity, parameters)
   222  	if err != nil {
   223  		err = autorest.NewErrorWithError(err, "job.Client", "Create", nil, "Failure preparing request")
   224  		return
   225  	}
   226  
   227  	resp, err := client.CreateSender(req)
   228  	if err != nil {
   229  		result.Response = autorest.Response{Response: resp}
   230  		err = autorest.NewErrorWithError(err, "job.Client", "Create", resp, "Failure sending request")
   231  		return
   232  	}
   233  
   234  	result, err = client.CreateResponder(resp)
   235  	if err != nil {
   236  		err = autorest.NewErrorWithError(err, "job.Client", "Create", resp, "Failure responding to request")
   237  		return
   238  	}
   239  
   240  	return
   241  }
   242  
   243  // CreatePreparer prepares the Create request.
   244  func (client Client) CreatePreparer(ctx context.Context, accountName string, jobIdentity uuid.UUID, parameters Information) (*http.Request, error) {
   245  	urlParameters := map[string]interface{}{
   246  		"accountName":      accountName,
   247  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
   248  	}
   249  
   250  	pathParameters := map[string]interface{}{
   251  		"jobIdentity": autorest.Encode("path", jobIdentity),
   252  	}
   253  
   254  	const APIVersion = "2015-11-01-preview"
   255  	queryParameters := map[string]interface{}{
   256  		"api-version": APIVersion,
   257  	}
   258  
   259  	parameters.ErrorMessage = nil
   260  	parameters.SubmitTime = nil
   261  	parameters.StartTime = nil
   262  	parameters.EndTime = nil
   263  	parameters.State = ""
   264  	parameters.Result = ""
   265  	parameters.StateAuditRecords = nil
   266  	parameters.HierarchyQueueNode = nil
   267  	preparer := autorest.CreatePreparer(
   268  		autorest.AsContentType("application/json; charset=utf-8"),
   269  		autorest.AsPut(),
   270  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
   271  		autorest.WithPathParameters("/Jobs/{jobIdentity}", pathParameters),
   272  		autorest.WithJSON(parameters),
   273  		autorest.WithQueryParameters(queryParameters))
   274  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   275  }
   276  
   277  // CreateSender sends the Create request. The method will close the
   278  // http.Response Body if it receives an error.
   279  func (client Client) CreateSender(req *http.Request) (*http.Response, error) {
   280  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   281  }
   282  
   283  // CreateResponder handles the response to the Create request. The method always
   284  // closes the http.Response Body.
   285  func (client Client) CreateResponder(resp *http.Response) (result Information, err error) {
   286  	err = autorest.Respond(
   287  		resp,
   288  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   289  		autorest.ByUnmarshallingJSON(&result),
   290  		autorest.ByClosing())
   291  	result.Response = autorest.Response{Response: resp}
   292  	return
   293  }
   294  
   295  // Get gets the job information for the specified job ID.
   296  // Parameters:
   297  // accountName - the Azure Data Lake Analytics account to execute job operations on.
   298  // jobIdentity - jobInfo ID.
   299  func (client Client) Get(ctx context.Context, accountName string, jobIdentity uuid.UUID) (result Information, err error) {
   300  	if tracing.IsEnabled() {
   301  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.Get")
   302  		defer func() {
   303  			sc := -1
   304  			if result.Response.Response != nil {
   305  				sc = result.Response.Response.StatusCode
   306  			}
   307  			tracing.EndSpan(ctx, sc, err)
   308  		}()
   309  	}
   310  	req, err := client.GetPreparer(ctx, accountName, jobIdentity)
   311  	if err != nil {
   312  		err = autorest.NewErrorWithError(err, "job.Client", "Get", nil, "Failure preparing request")
   313  		return
   314  	}
   315  
   316  	resp, err := client.GetSender(req)
   317  	if err != nil {
   318  		result.Response = autorest.Response{Response: resp}
   319  		err = autorest.NewErrorWithError(err, "job.Client", "Get", resp, "Failure sending request")
   320  		return
   321  	}
   322  
   323  	result, err = client.GetResponder(resp)
   324  	if err != nil {
   325  		err = autorest.NewErrorWithError(err, "job.Client", "Get", resp, "Failure responding to request")
   326  		return
   327  	}
   328  
   329  	return
   330  }
   331  
   332  // GetPreparer prepares the Get request.
   333  func (client Client) GetPreparer(ctx context.Context, accountName string, jobIdentity uuid.UUID) (*http.Request, error) {
   334  	urlParameters := map[string]interface{}{
   335  		"accountName":      accountName,
   336  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
   337  	}
   338  
   339  	pathParameters := map[string]interface{}{
   340  		"jobIdentity": autorest.Encode("path", jobIdentity),
   341  	}
   342  
   343  	const APIVersion = "2015-11-01-preview"
   344  	queryParameters := map[string]interface{}{
   345  		"api-version": APIVersion,
   346  	}
   347  
   348  	preparer := autorest.CreatePreparer(
   349  		autorest.AsGet(),
   350  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
   351  		autorest.WithPathParameters("/Jobs/{jobIdentity}", pathParameters),
   352  		autorest.WithQueryParameters(queryParameters))
   353  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   354  }
   355  
   356  // GetSender sends the Get request. The method will close the
   357  // http.Response Body if it receives an error.
   358  func (client Client) GetSender(req *http.Request) (*http.Response, error) {
   359  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   360  }
   361  
   362  // GetResponder handles the response to the Get request. The method always
   363  // closes the http.Response Body.
   364  func (client Client) GetResponder(resp *http.Response) (result Information, err error) {
   365  	err = autorest.Respond(
   366  		resp,
   367  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   368  		autorest.ByUnmarshallingJSON(&result),
   369  		autorest.ByClosing())
   370  	result.Response = autorest.Response{Response: resp}
   371  	return
   372  }
   373  
   374  // GetDebugDataPath gets the U-SQL job debug data information specified by the job ID.
   375  // Parameters:
   376  // accountName - the Azure Data Lake Analytics account to execute job operations on.
   377  // jobIdentity - jobInfo ID.
   378  func (client Client) GetDebugDataPath(ctx context.Context, accountName string, jobIdentity uuid.UUID) (result DataPath, err error) {
   379  	if tracing.IsEnabled() {
   380  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetDebugDataPath")
   381  		defer func() {
   382  			sc := -1
   383  			if result.Response.Response != nil {
   384  				sc = result.Response.Response.StatusCode
   385  			}
   386  			tracing.EndSpan(ctx, sc, err)
   387  		}()
   388  	}
   389  	req, err := client.GetDebugDataPathPreparer(ctx, accountName, jobIdentity)
   390  	if err != nil {
   391  		err = autorest.NewErrorWithError(err, "job.Client", "GetDebugDataPath", nil, "Failure preparing request")
   392  		return
   393  	}
   394  
   395  	resp, err := client.GetDebugDataPathSender(req)
   396  	if err != nil {
   397  		result.Response = autorest.Response{Response: resp}
   398  		err = autorest.NewErrorWithError(err, "job.Client", "GetDebugDataPath", resp, "Failure sending request")
   399  		return
   400  	}
   401  
   402  	result, err = client.GetDebugDataPathResponder(resp)
   403  	if err != nil {
   404  		err = autorest.NewErrorWithError(err, "job.Client", "GetDebugDataPath", resp, "Failure responding to request")
   405  		return
   406  	}
   407  
   408  	return
   409  }
   410  
   411  // GetDebugDataPathPreparer prepares the GetDebugDataPath request.
   412  func (client Client) GetDebugDataPathPreparer(ctx context.Context, accountName string, jobIdentity uuid.UUID) (*http.Request, error) {
   413  	urlParameters := map[string]interface{}{
   414  		"accountName":      accountName,
   415  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
   416  	}
   417  
   418  	pathParameters := map[string]interface{}{
   419  		"jobIdentity": autorest.Encode("path", jobIdentity),
   420  	}
   421  
   422  	const APIVersion = "2015-11-01-preview"
   423  	queryParameters := map[string]interface{}{
   424  		"api-version": APIVersion,
   425  	}
   426  
   427  	preparer := autorest.CreatePreparer(
   428  		autorest.AsPost(),
   429  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
   430  		autorest.WithPathParameters("/Jobs/{jobIdentity}/GetDebugDataPath", pathParameters),
   431  		autorest.WithQueryParameters(queryParameters))
   432  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   433  }
   434  
   435  // GetDebugDataPathSender sends the GetDebugDataPath request. The method will close the
   436  // http.Response Body if it receives an error.
   437  func (client Client) GetDebugDataPathSender(req *http.Request) (*http.Response, error) {
   438  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   439  }
   440  
   441  // GetDebugDataPathResponder handles the response to the GetDebugDataPath request. The method always
   442  // closes the http.Response Body.
   443  func (client Client) GetDebugDataPathResponder(resp *http.Response) (result DataPath, err error) {
   444  	err = autorest.Respond(
   445  		resp,
   446  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   447  		autorest.ByUnmarshallingJSON(&result),
   448  		autorest.ByClosing())
   449  	result.Response = autorest.Response{Response: resp}
   450  	return
   451  }
   452  
   453  // GetStatistics gets statistics of the specified job.
   454  // Parameters:
   455  // accountName - the Azure Data Lake Analytics account to execute job operations on.
   456  // jobIdentity - jobInfo ID.
   457  func (client Client) GetStatistics(ctx context.Context, accountName string, jobIdentity uuid.UUID) (result Statistics, err error) {
   458  	if tracing.IsEnabled() {
   459  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.GetStatistics")
   460  		defer func() {
   461  			sc := -1
   462  			if result.Response.Response != nil {
   463  				sc = result.Response.Response.StatusCode
   464  			}
   465  			tracing.EndSpan(ctx, sc, err)
   466  		}()
   467  	}
   468  	req, err := client.GetStatisticsPreparer(ctx, accountName, jobIdentity)
   469  	if err != nil {
   470  		err = autorest.NewErrorWithError(err, "job.Client", "GetStatistics", nil, "Failure preparing request")
   471  		return
   472  	}
   473  
   474  	resp, err := client.GetStatisticsSender(req)
   475  	if err != nil {
   476  		result.Response = autorest.Response{Response: resp}
   477  		err = autorest.NewErrorWithError(err, "job.Client", "GetStatistics", resp, "Failure sending request")
   478  		return
   479  	}
   480  
   481  	result, err = client.GetStatisticsResponder(resp)
   482  	if err != nil {
   483  		err = autorest.NewErrorWithError(err, "job.Client", "GetStatistics", resp, "Failure responding to request")
   484  		return
   485  	}
   486  
   487  	return
   488  }
   489  
   490  // GetStatisticsPreparer prepares the GetStatistics request.
   491  func (client Client) GetStatisticsPreparer(ctx context.Context, accountName string, jobIdentity uuid.UUID) (*http.Request, error) {
   492  	urlParameters := map[string]interface{}{
   493  		"accountName":      accountName,
   494  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
   495  	}
   496  
   497  	pathParameters := map[string]interface{}{
   498  		"jobIdentity": autorest.Encode("path", jobIdentity),
   499  	}
   500  
   501  	const APIVersion = "2015-11-01-preview"
   502  	queryParameters := map[string]interface{}{
   503  		"api-version": APIVersion,
   504  	}
   505  
   506  	preparer := autorest.CreatePreparer(
   507  		autorest.AsPost(),
   508  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
   509  		autorest.WithPathParameters("/Jobs/{jobIdentity}/GetStatistics", pathParameters),
   510  		autorest.WithQueryParameters(queryParameters))
   511  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   512  }
   513  
   514  // GetStatisticsSender sends the GetStatistics request. The method will close the
   515  // http.Response Body if it receives an error.
   516  func (client Client) GetStatisticsSender(req *http.Request) (*http.Response, error) {
   517  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   518  }
   519  
   520  // GetStatisticsResponder handles the response to the GetStatistics request. The method always
   521  // closes the http.Response Body.
   522  func (client Client) GetStatisticsResponder(resp *http.Response) (result Statistics, err error) {
   523  	err = autorest.Respond(
   524  		resp,
   525  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   526  		autorest.ByUnmarshallingJSON(&result),
   527  		autorest.ByClosing())
   528  	result.Response = autorest.Response{Response: resp}
   529  	return
   530  }
   531  
   532  // List lists the jobs, if any, associated with the specified Data Lake Analytics account. The response includes a link
   533  // to the next page of results, if any.
   534  // Parameters:
   535  // accountName - the Azure Data Lake Analytics account to execute job operations on.
   536  // filter - oData filter. Optional.
   537  // top - the number of items to return. Optional.
   538  // skip - the number of items to skip over before returning elements. Optional.
   539  // expand - oData expansion. Expand related resources in line with the retrieved resources, e.g.
   540  // Categories/$expand=Products would expand Product data in line with each Category entry. Optional.
   541  // selectParameter - oData Select statement. Limits the properties on each entry to just those requested, e.g.
   542  // Categories?$select=CategoryName,Description. Optional.
   543  // orderby - orderBy clause. One or more comma-separated expressions with an optional "asc" (the default) or
   544  // "desc" depending on the order you'd like the values sorted, e.g. Categories?$orderby=CategoryName desc.
   545  // Optional.
   546  // count - the Boolean value of true or false to request a count of the matching resources included with the
   547  // resources in the response, e.g. Categories?$count=true. Optional.
   548  // search - a free form search. A free-text search expression to match for whether a particular entry should be
   549  // included in the feed, e.g. Categories?$search=blue OR green. Optional.
   550  // formatParameter - the return format. Return the response in particular format without access to request
   551  // headers for standard content-type negotiation (e.g Orders?$format=json). Optional.
   552  func (client Client) List(ctx context.Context, accountName string, filter string, top *int32, skip *int32, expand string, selectParameter string, orderby string, count *bool, search string, formatParameter string) (result InfoListResultPage, err error) {
   553  	if tracing.IsEnabled() {
   554  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
   555  		defer func() {
   556  			sc := -1
   557  			if result.ilr.Response.Response != nil {
   558  				sc = result.ilr.Response.Response.StatusCode
   559  			}
   560  			tracing.EndSpan(ctx, sc, err)
   561  		}()
   562  	}
   563  	result.fn = client.listNextResults
   564  	req, err := client.ListPreparer(ctx, accountName, filter, top, skip, expand, selectParameter, orderby, count, search, formatParameter)
   565  	if err != nil {
   566  		err = autorest.NewErrorWithError(err, "job.Client", "List", nil, "Failure preparing request")
   567  		return
   568  	}
   569  
   570  	resp, err := client.ListSender(req)
   571  	if err != nil {
   572  		result.ilr.Response = autorest.Response{Response: resp}
   573  		err = autorest.NewErrorWithError(err, "job.Client", "List", resp, "Failure sending request")
   574  		return
   575  	}
   576  
   577  	result.ilr, err = client.ListResponder(resp)
   578  	if err != nil {
   579  		err = autorest.NewErrorWithError(err, "job.Client", "List", resp, "Failure responding to request")
   580  		return
   581  	}
   582  	if result.ilr.hasNextLink() && result.ilr.IsEmpty() {
   583  		err = result.NextWithContext(ctx)
   584  		return
   585  	}
   586  
   587  	return
   588  }
   589  
   590  // ListPreparer prepares the List request.
   591  func (client Client) ListPreparer(ctx context.Context, accountName string, filter string, top *int32, skip *int32, expand string, selectParameter string, orderby string, count *bool, search string, formatParameter string) (*http.Request, error) {
   592  	urlParameters := map[string]interface{}{
   593  		"accountName":      accountName,
   594  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
   595  	}
   596  
   597  	const APIVersion = "2015-11-01-preview"
   598  	queryParameters := map[string]interface{}{
   599  		"api-version": APIVersion,
   600  	}
   601  	if len(filter) > 0 {
   602  		queryParameters["$filter"] = autorest.Encode("query", filter)
   603  	}
   604  	if top != nil {
   605  		queryParameters["$top"] = autorest.Encode("query", *top)
   606  	}
   607  	if skip != nil {
   608  		queryParameters["$skip"] = autorest.Encode("query", *skip)
   609  	}
   610  	if len(expand) > 0 {
   611  		queryParameters["$expand"] = autorest.Encode("query", expand)
   612  	}
   613  	if len(selectParameter) > 0 {
   614  		queryParameters["$select"] = autorest.Encode("query", selectParameter)
   615  	}
   616  	if len(orderby) > 0 {
   617  		queryParameters["$orderby"] = autorest.Encode("query", orderby)
   618  	}
   619  	if count != nil {
   620  		queryParameters["$count"] = autorest.Encode("query", *count)
   621  	}
   622  	if len(search) > 0 {
   623  		queryParameters["$search"] = autorest.Encode("query", search)
   624  	}
   625  	if len(formatParameter) > 0 {
   626  		queryParameters["$format"] = autorest.Encode("query", formatParameter)
   627  	}
   628  
   629  	preparer := autorest.CreatePreparer(
   630  		autorest.AsGet(),
   631  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
   632  		autorest.WithPath("/Jobs"),
   633  		autorest.WithQueryParameters(queryParameters))
   634  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   635  }
   636  
   637  // ListSender sends the List request. The method will close the
   638  // http.Response Body if it receives an error.
   639  func (client Client) ListSender(req *http.Request) (*http.Response, error) {
   640  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   641  }
   642  
   643  // ListResponder handles the response to the List request. The method always
   644  // closes the http.Response Body.
   645  func (client Client) ListResponder(resp *http.Response) (result InfoListResult, err error) {
   646  	err = autorest.Respond(
   647  		resp,
   648  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   649  		autorest.ByUnmarshallingJSON(&result),
   650  		autorest.ByClosing())
   651  	result.Response = autorest.Response{Response: resp}
   652  	return
   653  }
   654  
   655  // listNextResults retrieves the next set of results, if any.
   656  func (client Client) listNextResults(ctx context.Context, lastResults InfoListResult) (result InfoListResult, err error) {
   657  	req, err := lastResults.infoListResultPreparer(ctx)
   658  	if err != nil {
   659  		return result, autorest.NewErrorWithError(err, "job.Client", "listNextResults", nil, "Failure preparing next results request")
   660  	}
   661  	if req == nil {
   662  		return
   663  	}
   664  	resp, err := client.ListSender(req)
   665  	if err != nil {
   666  		result.Response = autorest.Response{Response: resp}
   667  		return result, autorest.NewErrorWithError(err, "job.Client", "listNextResults", resp, "Failure sending next results request")
   668  	}
   669  	result, err = client.ListResponder(resp)
   670  	if err != nil {
   671  		err = autorest.NewErrorWithError(err, "job.Client", "listNextResults", resp, "Failure responding to next results request")
   672  	}
   673  	return
   674  }
   675  
   676  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   677  func (client Client) ListComplete(ctx context.Context, accountName string, filter string, top *int32, skip *int32, expand string, selectParameter string, orderby string, count *bool, search string, formatParameter string) (result InfoListResultIterator, err error) {
   678  	if tracing.IsEnabled() {
   679  		ctx = tracing.StartSpan(ctx, fqdn+"/Client.List")
   680  		defer func() {
   681  			sc := -1
   682  			if result.Response().Response.Response != nil {
   683  				sc = result.page.Response().Response.Response.StatusCode
   684  			}
   685  			tracing.EndSpan(ctx, sc, err)
   686  		}()
   687  	}
   688  	result.page, err = client.List(ctx, accountName, filter, top, skip, expand, selectParameter, orderby, count, search, formatParameter)
   689  	return
   690  }
   691  

View as plain text