...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/datalake/analytics/2016-03-20-preview/job/job.go

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

View as plain text