...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/datalake/analytics/2017-09-01-preview/job/recurrence.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/datalake/analytics/2017-09-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/date"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"github.com/gofrs/uuid"
    16  	"net/http"
    17  )
    18  
    19  // RecurrenceClient is the creates an Azure Data Lake Analytics job client.
    20  type RecurrenceClient struct {
    21  	BaseClient
    22  }
    23  
    24  // NewRecurrenceClient creates an instance of the RecurrenceClient client.
    25  func NewRecurrenceClient() RecurrenceClient {
    26  	return RecurrenceClient{New()}
    27  }
    28  
    29  // Get gets the recurrence information for the specified recurrence ID.
    30  // Parameters:
    31  // accountName - the Azure Data Lake Analytics account to execute job operations on.
    32  // recurrenceIdentity - recurrence ID.
    33  // startDateTime - the start date for when to get the recurrence and aggregate its data. The startDateTime and
    34  // endDateTime can be no more than 30 days apart.
    35  // endDateTime - the end date for when to get recurrence and aggregate its data. The startDateTime and
    36  // endDateTime can be no more than 30 days apart.
    37  func (client RecurrenceClient) Get(ctx context.Context, accountName string, recurrenceIdentity uuid.UUID, startDateTime *date.Time, endDateTime *date.Time) (result RecurrenceInformation, err error) {
    38  	if tracing.IsEnabled() {
    39  		ctx = tracing.StartSpan(ctx, fqdn+"/RecurrenceClient.Get")
    40  		defer func() {
    41  			sc := -1
    42  			if result.Response.Response != nil {
    43  				sc = result.Response.Response.StatusCode
    44  			}
    45  			tracing.EndSpan(ctx, sc, err)
    46  		}()
    47  	}
    48  	req, err := client.GetPreparer(ctx, accountName, recurrenceIdentity, startDateTime, endDateTime)
    49  	if err != nil {
    50  		err = autorest.NewErrorWithError(err, "job.RecurrenceClient", "Get", nil, "Failure preparing request")
    51  		return
    52  	}
    53  
    54  	resp, err := client.GetSender(req)
    55  	if err != nil {
    56  		result.Response = autorest.Response{Response: resp}
    57  		err = autorest.NewErrorWithError(err, "job.RecurrenceClient", "Get", resp, "Failure sending request")
    58  		return
    59  	}
    60  
    61  	result, err = client.GetResponder(resp)
    62  	if err != nil {
    63  		err = autorest.NewErrorWithError(err, "job.RecurrenceClient", "Get", resp, "Failure responding to request")
    64  		return
    65  	}
    66  
    67  	return
    68  }
    69  
    70  // GetPreparer prepares the Get request.
    71  func (client RecurrenceClient) GetPreparer(ctx context.Context, accountName string, recurrenceIdentity uuid.UUID, startDateTime *date.Time, endDateTime *date.Time) (*http.Request, error) {
    72  	urlParameters := map[string]interface{}{
    73  		"accountName":      accountName,
    74  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
    75  	}
    76  
    77  	pathParameters := map[string]interface{}{
    78  		"recurrenceIdentity": autorest.Encode("path", recurrenceIdentity),
    79  	}
    80  
    81  	const APIVersion = "2017-09-01-preview"
    82  	queryParameters := map[string]interface{}{
    83  		"api-version": APIVersion,
    84  	}
    85  	if startDateTime != nil {
    86  		queryParameters["startDateTime"] = autorest.Encode("query", *startDateTime)
    87  	}
    88  	if endDateTime != nil {
    89  		queryParameters["endDateTime"] = autorest.Encode("query", *endDateTime)
    90  	}
    91  
    92  	preparer := autorest.CreatePreparer(
    93  		autorest.AsGet(),
    94  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
    95  		autorest.WithPathParameters("/recurrences/{recurrenceIdentity}", pathParameters),
    96  		autorest.WithQueryParameters(queryParameters))
    97  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    98  }
    99  
   100  // GetSender sends the Get request. The method will close the
   101  // http.Response Body if it receives an error.
   102  func (client RecurrenceClient) GetSender(req *http.Request) (*http.Response, error) {
   103  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   104  }
   105  
   106  // GetResponder handles the response to the Get request. The method always
   107  // closes the http.Response Body.
   108  func (client RecurrenceClient) GetResponder(resp *http.Response) (result RecurrenceInformation, err error) {
   109  	err = autorest.Respond(
   110  		resp,
   111  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   112  		autorest.ByUnmarshallingJSON(&result),
   113  		autorest.ByClosing())
   114  	result.Response = autorest.Response{Response: resp}
   115  	return
   116  }
   117  
   118  // List lists all recurrences.
   119  // Parameters:
   120  // accountName - the Azure Data Lake Analytics account to execute job operations on.
   121  // startDateTime - the start date for when to get the list of recurrences. The startDateTime and endDateTime
   122  // can be no more than 30 days apart.
   123  // endDateTime - the end date for when to get the list of recurrences. The startDateTime and endDateTime can be
   124  // no more than 30 days apart.
   125  func (client RecurrenceClient) List(ctx context.Context, accountName string, startDateTime *date.Time, endDateTime *date.Time) (result RecurrenceInformationListResultPage, err error) {
   126  	if tracing.IsEnabled() {
   127  		ctx = tracing.StartSpan(ctx, fqdn+"/RecurrenceClient.List")
   128  		defer func() {
   129  			sc := -1
   130  			if result.rilr.Response.Response != nil {
   131  				sc = result.rilr.Response.Response.StatusCode
   132  			}
   133  			tracing.EndSpan(ctx, sc, err)
   134  		}()
   135  	}
   136  	result.fn = client.listNextResults
   137  	req, err := client.ListPreparer(ctx, accountName, startDateTime, endDateTime)
   138  	if err != nil {
   139  		err = autorest.NewErrorWithError(err, "job.RecurrenceClient", "List", nil, "Failure preparing request")
   140  		return
   141  	}
   142  
   143  	resp, err := client.ListSender(req)
   144  	if err != nil {
   145  		result.rilr.Response = autorest.Response{Response: resp}
   146  		err = autorest.NewErrorWithError(err, "job.RecurrenceClient", "List", resp, "Failure sending request")
   147  		return
   148  	}
   149  
   150  	result.rilr, err = client.ListResponder(resp)
   151  	if err != nil {
   152  		err = autorest.NewErrorWithError(err, "job.RecurrenceClient", "List", resp, "Failure responding to request")
   153  		return
   154  	}
   155  	if result.rilr.hasNextLink() && result.rilr.IsEmpty() {
   156  		err = result.NextWithContext(ctx)
   157  		return
   158  	}
   159  
   160  	return
   161  }
   162  
   163  // ListPreparer prepares the List request.
   164  func (client RecurrenceClient) ListPreparer(ctx context.Context, accountName string, startDateTime *date.Time, endDateTime *date.Time) (*http.Request, error) {
   165  	urlParameters := map[string]interface{}{
   166  		"accountName":      accountName,
   167  		"adlaJobDnsSuffix": client.AdlaJobDNSSuffix,
   168  	}
   169  
   170  	const APIVersion = "2017-09-01-preview"
   171  	queryParameters := map[string]interface{}{
   172  		"api-version": APIVersion,
   173  	}
   174  	if startDateTime != nil {
   175  		queryParameters["startDateTime"] = autorest.Encode("query", *startDateTime)
   176  	}
   177  	if endDateTime != nil {
   178  		queryParameters["endDateTime"] = autorest.Encode("query", *endDateTime)
   179  	}
   180  
   181  	preparer := autorest.CreatePreparer(
   182  		autorest.AsGet(),
   183  		autorest.WithCustomBaseURL("https://{accountName}.{adlaJobDnsSuffix}", urlParameters),
   184  		autorest.WithPath("/recurrences"),
   185  		autorest.WithQueryParameters(queryParameters))
   186  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   187  }
   188  
   189  // ListSender sends the List request. The method will close the
   190  // http.Response Body if it receives an error.
   191  func (client RecurrenceClient) ListSender(req *http.Request) (*http.Response, error) {
   192  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   193  }
   194  
   195  // ListResponder handles the response to the List request. The method always
   196  // closes the http.Response Body.
   197  func (client RecurrenceClient) ListResponder(resp *http.Response) (result RecurrenceInformationListResult, err error) {
   198  	err = autorest.Respond(
   199  		resp,
   200  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   201  		autorest.ByUnmarshallingJSON(&result),
   202  		autorest.ByClosing())
   203  	result.Response = autorest.Response{Response: resp}
   204  	return
   205  }
   206  
   207  // listNextResults retrieves the next set of results, if any.
   208  func (client RecurrenceClient) listNextResults(ctx context.Context, lastResults RecurrenceInformationListResult) (result RecurrenceInformationListResult, err error) {
   209  	req, err := lastResults.recurrenceInformationListResultPreparer(ctx)
   210  	if err != nil {
   211  		return result, autorest.NewErrorWithError(err, "job.RecurrenceClient", "listNextResults", nil, "Failure preparing next results request")
   212  	}
   213  	if req == nil {
   214  		return
   215  	}
   216  	resp, err := client.ListSender(req)
   217  	if err != nil {
   218  		result.Response = autorest.Response{Response: resp}
   219  		return result, autorest.NewErrorWithError(err, "job.RecurrenceClient", "listNextResults", resp, "Failure sending next results request")
   220  	}
   221  	result, err = client.ListResponder(resp)
   222  	if err != nil {
   223  		err = autorest.NewErrorWithError(err, "job.RecurrenceClient", "listNextResults", resp, "Failure responding to next results request")
   224  	}
   225  	return
   226  }
   227  
   228  // ListComplete enumerates all values, automatically crossing page boundaries as required.
   229  func (client RecurrenceClient) ListComplete(ctx context.Context, accountName string, startDateTime *date.Time, endDateTime *date.Time) (result RecurrenceInformationListResultIterator, err error) {
   230  	if tracing.IsEnabled() {
   231  		ctx = tracing.StartSpan(ctx, fqdn+"/RecurrenceClient.List")
   232  		defer func() {
   233  			sc := -1
   234  			if result.Response().Response.Response != nil {
   235  				sc = result.page.Response().Response.Response.StatusCode
   236  			}
   237  			tracing.EndSpan(ctx, sc, err)
   238  		}()
   239  	}
   240  	result.page, err = client.List(ctx, accountName, startDateTime, endDateTime)
   241  	return
   242  }
   243  

View as plain text