...

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

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

View as plain text