...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/artifacts/pipeline.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/artifacts

     1  package artifacts
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"context"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/azure"
    13  	"github.com/Azure/go-autorest/autorest/validation"
    14  	"github.com/Azure/go-autorest/tracing"
    15  	"net/http"
    16  )
    17  
    18  // PipelineClient is the client for the Pipeline methods of the Artifacts service.
    19  type PipelineClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewPipelineClient creates an instance of the PipelineClient client.
    24  func NewPipelineClient(endpoint string) PipelineClient {
    25  	return PipelineClient{New(endpoint)}
    26  }
    27  
    28  // CreateOrUpdatePipeline creates or updates a pipeline.
    29  // Parameters:
    30  // pipelineName - the pipeline name.
    31  // pipeline - pipeline resource definition.
    32  // ifMatch - eTag of the pipeline entity.  Should only be specified for update, for which it should match
    33  // existing entity or can be * for unconditional update.
    34  func (client PipelineClient) CreateOrUpdatePipeline(ctx context.Context, pipelineName string, pipeline PipelineResource, ifMatch string) (result PipelineCreateOrUpdatePipelineFuture, err error) {
    35  	if tracing.IsEnabled() {
    36  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineClient.CreateOrUpdatePipeline")
    37  		defer func() {
    38  			sc := -1
    39  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
    40  				sc = result.FutureAPI.Response().StatusCode
    41  			}
    42  			tracing.EndSpan(ctx, sc, err)
    43  		}()
    44  	}
    45  	if err := validation.Validate([]validation.Validation{
    46  		{TargetValue: pipelineName,
    47  			Constraints: []validation.Constraint{{Target: "pipelineName", Name: validation.MaxLength, Rule: 260, Chain: nil},
    48  				{Target: "pipelineName", Name: validation.MinLength, Rule: 1, Chain: nil},
    49  				{Target: "pipelineName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}},
    50  		{TargetValue: pipeline,
    51  			Constraints: []validation.Constraint{{Target: "pipeline.Pipeline", Name: validation.Null, Rule: true,
    52  				Chain: []validation.Constraint{{Target: "pipeline.Pipeline.Concurrency", Name: validation.Null, Rule: false,
    53  					Chain: []validation.Constraint{{Target: "pipeline.Pipeline.Concurrency", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}}},
    54  				}}}}}); err != nil {
    55  		return result, validation.NewError("artifacts.PipelineClient", "CreateOrUpdatePipeline", err.Error())
    56  	}
    57  
    58  	req, err := client.CreateOrUpdatePipelinePreparer(ctx, pipelineName, pipeline, ifMatch)
    59  	if err != nil {
    60  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "CreateOrUpdatePipeline", nil, "Failure preparing request")
    61  		return
    62  	}
    63  
    64  	result, err = client.CreateOrUpdatePipelineSender(req)
    65  	if err != nil {
    66  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "CreateOrUpdatePipeline", nil, "Failure sending request")
    67  		return
    68  	}
    69  
    70  	return
    71  }
    72  
    73  // CreateOrUpdatePipelinePreparer prepares the CreateOrUpdatePipeline request.
    74  func (client PipelineClient) CreateOrUpdatePipelinePreparer(ctx context.Context, pipelineName string, pipeline PipelineResource, ifMatch string) (*http.Request, error) {
    75  	urlParameters := map[string]interface{}{
    76  		"endpoint": client.Endpoint,
    77  	}
    78  
    79  	pathParameters := map[string]interface{}{
    80  		"pipelineName": autorest.Encode("path", pipelineName),
    81  	}
    82  
    83  	const APIVersion = "2019-06-01-preview"
    84  	queryParameters := map[string]interface{}{
    85  		"api-version": APIVersion,
    86  	}
    87  
    88  	preparer := autorest.CreatePreparer(
    89  		autorest.AsContentType("application/json; charset=utf-8"),
    90  		autorest.AsPut(),
    91  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
    92  		autorest.WithPathParameters("/pipelines/{pipelineName}", pathParameters),
    93  		autorest.WithJSON(pipeline),
    94  		autorest.WithQueryParameters(queryParameters))
    95  	if len(ifMatch) > 0 {
    96  		preparer = autorest.DecoratePreparer(preparer,
    97  			autorest.WithHeader("If-Match", autorest.String(ifMatch)))
    98  	}
    99  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   100  }
   101  
   102  // CreateOrUpdatePipelineSender sends the CreateOrUpdatePipeline request. The method will close the
   103  // http.Response Body if it receives an error.
   104  func (client PipelineClient) CreateOrUpdatePipelineSender(req *http.Request) (future PipelineCreateOrUpdatePipelineFuture, err error) {
   105  	var resp *http.Response
   106  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   107  	if err != nil {
   108  		return
   109  	}
   110  	var azf azure.Future
   111  	azf, err = azure.NewFutureFromResponse(resp)
   112  	future.FutureAPI = &azf
   113  	future.Result = future.result
   114  	return
   115  }
   116  
   117  // CreateOrUpdatePipelineResponder handles the response to the CreateOrUpdatePipeline request. The method always
   118  // closes the http.Response Body.
   119  func (client PipelineClient) CreateOrUpdatePipelineResponder(resp *http.Response) (result PipelineResource, err error) {
   120  	err = autorest.Respond(
   121  		resp,
   122  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   123  		autorest.ByUnmarshallingJSON(&result),
   124  		autorest.ByClosing())
   125  	result.Response = autorest.Response{Response: resp}
   126  	return
   127  }
   128  
   129  // CreatePipelineRun creates a run of a pipeline.
   130  // Parameters:
   131  // pipelineName - the pipeline name.
   132  // referencePipelineRunID - the pipeline run identifier. If run ID is specified the parameters of the specified
   133  // run will be used to create a new run.
   134  // isRecovery - recovery mode flag. If recovery mode is set to true, the specified referenced pipeline run and
   135  // the new run will be grouped under the same groupId.
   136  // startActivityName - in recovery mode, the rerun will start from this activity. If not specified, all
   137  // activities will run.
   138  // parameters - parameters of the pipeline run. These parameters will be used only if the runId is not
   139  // specified.
   140  func (client PipelineClient) CreatePipelineRun(ctx context.Context, pipelineName string, referencePipelineRunID string, isRecovery *bool, startActivityName string, parameters map[string]interface{}) (result CreateRunResponse, err error) {
   141  	if tracing.IsEnabled() {
   142  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineClient.CreatePipelineRun")
   143  		defer func() {
   144  			sc := -1
   145  			if result.Response.Response != nil {
   146  				sc = result.Response.Response.StatusCode
   147  			}
   148  			tracing.EndSpan(ctx, sc, err)
   149  		}()
   150  	}
   151  	if err := validation.Validate([]validation.Validation{
   152  		{TargetValue: pipelineName,
   153  			Constraints: []validation.Constraint{{Target: "pipelineName", Name: validation.MaxLength, Rule: 260, Chain: nil},
   154  				{Target: "pipelineName", Name: validation.MinLength, Rule: 1, Chain: nil},
   155  				{Target: "pipelineName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}}}); err != nil {
   156  		return result, validation.NewError("artifacts.PipelineClient", "CreatePipelineRun", err.Error())
   157  	}
   158  
   159  	req, err := client.CreatePipelineRunPreparer(ctx, pipelineName, referencePipelineRunID, isRecovery, startActivityName, parameters)
   160  	if err != nil {
   161  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "CreatePipelineRun", nil, "Failure preparing request")
   162  		return
   163  	}
   164  
   165  	resp, err := client.CreatePipelineRunSender(req)
   166  	if err != nil {
   167  		result.Response = autorest.Response{Response: resp}
   168  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "CreatePipelineRun", resp, "Failure sending request")
   169  		return
   170  	}
   171  
   172  	result, err = client.CreatePipelineRunResponder(resp)
   173  	if err != nil {
   174  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "CreatePipelineRun", resp, "Failure responding to request")
   175  		return
   176  	}
   177  
   178  	return
   179  }
   180  
   181  // CreatePipelineRunPreparer prepares the CreatePipelineRun request.
   182  func (client PipelineClient) CreatePipelineRunPreparer(ctx context.Context, pipelineName string, referencePipelineRunID string, isRecovery *bool, startActivityName string, parameters map[string]interface{}) (*http.Request, error) {
   183  	urlParameters := map[string]interface{}{
   184  		"endpoint": client.Endpoint,
   185  	}
   186  
   187  	pathParameters := map[string]interface{}{
   188  		"pipelineName": autorest.Encode("path", pipelineName),
   189  	}
   190  
   191  	const APIVersion = "2019-06-01-preview"
   192  	queryParameters := map[string]interface{}{
   193  		"api-version": APIVersion,
   194  	}
   195  	if len(referencePipelineRunID) > 0 {
   196  		queryParameters["referencePipelineRunId"] = autorest.Encode("query", referencePipelineRunID)
   197  	}
   198  	if isRecovery != nil {
   199  		queryParameters["isRecovery"] = autorest.Encode("query", *isRecovery)
   200  	}
   201  	if len(startActivityName) > 0 {
   202  		queryParameters["startActivityName"] = autorest.Encode("query", startActivityName)
   203  	}
   204  
   205  	preparer := autorest.CreatePreparer(
   206  		autorest.AsContentType("application/json; charset=utf-8"),
   207  		autorest.AsPost(),
   208  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   209  		autorest.WithPathParameters("/pipelines/{pipelineName}/createRun", pathParameters),
   210  		autorest.WithQueryParameters(queryParameters))
   211  	if parameters != nil && len(parameters) > 0 {
   212  		preparer = autorest.DecoratePreparer(preparer,
   213  			autorest.WithJSON(parameters))
   214  	}
   215  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   216  }
   217  
   218  // CreatePipelineRunSender sends the CreatePipelineRun request. The method will close the
   219  // http.Response Body if it receives an error.
   220  func (client PipelineClient) CreatePipelineRunSender(req *http.Request) (*http.Response, error) {
   221  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   222  }
   223  
   224  // CreatePipelineRunResponder handles the response to the CreatePipelineRun request. The method always
   225  // closes the http.Response Body.
   226  func (client PipelineClient) CreatePipelineRunResponder(resp *http.Response) (result CreateRunResponse, err error) {
   227  	err = autorest.Respond(
   228  		resp,
   229  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   230  		autorest.ByUnmarshallingJSON(&result),
   231  		autorest.ByClosing())
   232  	result.Response = autorest.Response{Response: resp}
   233  	return
   234  }
   235  
   236  // DeletePipeline deletes a pipeline.
   237  // Parameters:
   238  // pipelineName - the pipeline name.
   239  func (client PipelineClient) DeletePipeline(ctx context.Context, pipelineName string) (result PipelineDeletePipelineFuture, err error) {
   240  	if tracing.IsEnabled() {
   241  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineClient.DeletePipeline")
   242  		defer func() {
   243  			sc := -1
   244  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   245  				sc = result.FutureAPI.Response().StatusCode
   246  			}
   247  			tracing.EndSpan(ctx, sc, err)
   248  		}()
   249  	}
   250  	if err := validation.Validate([]validation.Validation{
   251  		{TargetValue: pipelineName,
   252  			Constraints: []validation.Constraint{{Target: "pipelineName", Name: validation.MaxLength, Rule: 260, Chain: nil},
   253  				{Target: "pipelineName", Name: validation.MinLength, Rule: 1, Chain: nil},
   254  				{Target: "pipelineName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}}}); err != nil {
   255  		return result, validation.NewError("artifacts.PipelineClient", "DeletePipeline", err.Error())
   256  	}
   257  
   258  	req, err := client.DeletePipelinePreparer(ctx, pipelineName)
   259  	if err != nil {
   260  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "DeletePipeline", nil, "Failure preparing request")
   261  		return
   262  	}
   263  
   264  	result, err = client.DeletePipelineSender(req)
   265  	if err != nil {
   266  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "DeletePipeline", nil, "Failure sending request")
   267  		return
   268  	}
   269  
   270  	return
   271  }
   272  
   273  // DeletePipelinePreparer prepares the DeletePipeline request.
   274  func (client PipelineClient) DeletePipelinePreparer(ctx context.Context, pipelineName string) (*http.Request, error) {
   275  	urlParameters := map[string]interface{}{
   276  		"endpoint": client.Endpoint,
   277  	}
   278  
   279  	pathParameters := map[string]interface{}{
   280  		"pipelineName": autorest.Encode("path", pipelineName),
   281  	}
   282  
   283  	const APIVersion = "2019-06-01-preview"
   284  	queryParameters := map[string]interface{}{
   285  		"api-version": APIVersion,
   286  	}
   287  
   288  	preparer := autorest.CreatePreparer(
   289  		autorest.AsDelete(),
   290  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   291  		autorest.WithPathParameters("/pipelines/{pipelineName}", pathParameters),
   292  		autorest.WithQueryParameters(queryParameters))
   293  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   294  }
   295  
   296  // DeletePipelineSender sends the DeletePipeline request. The method will close the
   297  // http.Response Body if it receives an error.
   298  func (client PipelineClient) DeletePipelineSender(req *http.Request) (future PipelineDeletePipelineFuture, err error) {
   299  	var resp *http.Response
   300  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   301  	if err != nil {
   302  		return
   303  	}
   304  	var azf azure.Future
   305  	azf, err = azure.NewFutureFromResponse(resp)
   306  	future.FutureAPI = &azf
   307  	future.Result = future.result
   308  	return
   309  }
   310  
   311  // DeletePipelineResponder handles the response to the DeletePipeline request. The method always
   312  // closes the http.Response Body.
   313  func (client PipelineClient) DeletePipelineResponder(resp *http.Response) (result autorest.Response, err error) {
   314  	err = autorest.Respond(
   315  		resp,
   316  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
   317  		autorest.ByClosing())
   318  	result.Response = resp
   319  	return
   320  }
   321  
   322  // GetPipeline gets a pipeline.
   323  // Parameters:
   324  // pipelineName - the pipeline name.
   325  // ifNoneMatch - eTag of the pipeline entity. Should only be specified for get. If the ETag matches the
   326  // existing entity tag, or if * was provided, then no content will be returned.
   327  func (client PipelineClient) GetPipeline(ctx context.Context, pipelineName string, ifNoneMatch string) (result PipelineResource, err error) {
   328  	if tracing.IsEnabled() {
   329  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineClient.GetPipeline")
   330  		defer func() {
   331  			sc := -1
   332  			if result.Response.Response != nil {
   333  				sc = result.Response.Response.StatusCode
   334  			}
   335  			tracing.EndSpan(ctx, sc, err)
   336  		}()
   337  	}
   338  	if err := validation.Validate([]validation.Validation{
   339  		{TargetValue: pipelineName,
   340  			Constraints: []validation.Constraint{{Target: "pipelineName", Name: validation.MaxLength, Rule: 260, Chain: nil},
   341  				{Target: "pipelineName", Name: validation.MinLength, Rule: 1, Chain: nil},
   342  				{Target: "pipelineName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}}}); err != nil {
   343  		return result, validation.NewError("artifacts.PipelineClient", "GetPipeline", err.Error())
   344  	}
   345  
   346  	req, err := client.GetPipelinePreparer(ctx, pipelineName, ifNoneMatch)
   347  	if err != nil {
   348  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "GetPipeline", nil, "Failure preparing request")
   349  		return
   350  	}
   351  
   352  	resp, err := client.GetPipelineSender(req)
   353  	if err != nil {
   354  		result.Response = autorest.Response{Response: resp}
   355  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "GetPipeline", resp, "Failure sending request")
   356  		return
   357  	}
   358  
   359  	result, err = client.GetPipelineResponder(resp)
   360  	if err != nil {
   361  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "GetPipeline", resp, "Failure responding to request")
   362  		return
   363  	}
   364  
   365  	return
   366  }
   367  
   368  // GetPipelinePreparer prepares the GetPipeline request.
   369  func (client PipelineClient) GetPipelinePreparer(ctx context.Context, pipelineName string, ifNoneMatch string) (*http.Request, error) {
   370  	urlParameters := map[string]interface{}{
   371  		"endpoint": client.Endpoint,
   372  	}
   373  
   374  	pathParameters := map[string]interface{}{
   375  		"pipelineName": autorest.Encode("path", pipelineName),
   376  	}
   377  
   378  	const APIVersion = "2019-06-01-preview"
   379  	queryParameters := map[string]interface{}{
   380  		"api-version": APIVersion,
   381  	}
   382  
   383  	preparer := autorest.CreatePreparer(
   384  		autorest.AsGet(),
   385  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   386  		autorest.WithPathParameters("/pipelines/{pipelineName}", pathParameters),
   387  		autorest.WithQueryParameters(queryParameters))
   388  	if len(ifNoneMatch) > 0 {
   389  		preparer = autorest.DecoratePreparer(preparer,
   390  			autorest.WithHeader("If-None-Match", autorest.String(ifNoneMatch)))
   391  	}
   392  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   393  }
   394  
   395  // GetPipelineSender sends the GetPipeline request. The method will close the
   396  // http.Response Body if it receives an error.
   397  func (client PipelineClient) GetPipelineSender(req *http.Request) (*http.Response, error) {
   398  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   399  }
   400  
   401  // GetPipelineResponder handles the response to the GetPipeline request. The method always
   402  // closes the http.Response Body.
   403  func (client PipelineClient) GetPipelineResponder(resp *http.Response) (result PipelineResource, err error) {
   404  	err = autorest.Respond(
   405  		resp,
   406  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotModified),
   407  		autorest.ByUnmarshallingJSON(&result),
   408  		autorest.ByClosing())
   409  	result.Response = autorest.Response{Response: resp}
   410  	return
   411  }
   412  
   413  // GetPipelinesByWorkspace lists pipelines.
   414  func (client PipelineClient) GetPipelinesByWorkspace(ctx context.Context) (result PipelineListResponsePage, err error) {
   415  	if tracing.IsEnabled() {
   416  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineClient.GetPipelinesByWorkspace")
   417  		defer func() {
   418  			sc := -1
   419  			if result.plr.Response.Response != nil {
   420  				sc = result.plr.Response.Response.StatusCode
   421  			}
   422  			tracing.EndSpan(ctx, sc, err)
   423  		}()
   424  	}
   425  	result.fn = client.getPipelinesByWorkspaceNextResults
   426  	req, err := client.GetPipelinesByWorkspacePreparer(ctx)
   427  	if err != nil {
   428  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "GetPipelinesByWorkspace", nil, "Failure preparing request")
   429  		return
   430  	}
   431  
   432  	resp, err := client.GetPipelinesByWorkspaceSender(req)
   433  	if err != nil {
   434  		result.plr.Response = autorest.Response{Response: resp}
   435  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "GetPipelinesByWorkspace", resp, "Failure sending request")
   436  		return
   437  	}
   438  
   439  	result.plr, err = client.GetPipelinesByWorkspaceResponder(resp)
   440  	if err != nil {
   441  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "GetPipelinesByWorkspace", resp, "Failure responding to request")
   442  		return
   443  	}
   444  	if result.plr.hasNextLink() && result.plr.IsEmpty() {
   445  		err = result.NextWithContext(ctx)
   446  		return
   447  	}
   448  
   449  	return
   450  }
   451  
   452  // GetPipelinesByWorkspacePreparer prepares the GetPipelinesByWorkspace request.
   453  func (client PipelineClient) GetPipelinesByWorkspacePreparer(ctx context.Context) (*http.Request, error) {
   454  	urlParameters := map[string]interface{}{
   455  		"endpoint": client.Endpoint,
   456  	}
   457  
   458  	const APIVersion = "2019-06-01-preview"
   459  	queryParameters := map[string]interface{}{
   460  		"api-version": APIVersion,
   461  	}
   462  
   463  	preparer := autorest.CreatePreparer(
   464  		autorest.AsGet(),
   465  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   466  		autorest.WithPath("/pipelines"),
   467  		autorest.WithQueryParameters(queryParameters))
   468  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   469  }
   470  
   471  // GetPipelinesByWorkspaceSender sends the GetPipelinesByWorkspace request. The method will close the
   472  // http.Response Body if it receives an error.
   473  func (client PipelineClient) GetPipelinesByWorkspaceSender(req *http.Request) (*http.Response, error) {
   474  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   475  }
   476  
   477  // GetPipelinesByWorkspaceResponder handles the response to the GetPipelinesByWorkspace request. The method always
   478  // closes the http.Response Body.
   479  func (client PipelineClient) GetPipelinesByWorkspaceResponder(resp *http.Response) (result PipelineListResponse, err error) {
   480  	err = autorest.Respond(
   481  		resp,
   482  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   483  		autorest.ByUnmarshallingJSON(&result),
   484  		autorest.ByClosing())
   485  	result.Response = autorest.Response{Response: resp}
   486  	return
   487  }
   488  
   489  // getPipelinesByWorkspaceNextResults retrieves the next set of results, if any.
   490  func (client PipelineClient) getPipelinesByWorkspaceNextResults(ctx context.Context, lastResults PipelineListResponse) (result PipelineListResponse, err error) {
   491  	req, err := lastResults.pipelineListResponsePreparer(ctx)
   492  	if err != nil {
   493  		return result, autorest.NewErrorWithError(err, "artifacts.PipelineClient", "getPipelinesByWorkspaceNextResults", nil, "Failure preparing next results request")
   494  	}
   495  	if req == nil {
   496  		return
   497  	}
   498  	resp, err := client.GetPipelinesByWorkspaceSender(req)
   499  	if err != nil {
   500  		result.Response = autorest.Response{Response: resp}
   501  		return result, autorest.NewErrorWithError(err, "artifacts.PipelineClient", "getPipelinesByWorkspaceNextResults", resp, "Failure sending next results request")
   502  	}
   503  	result, err = client.GetPipelinesByWorkspaceResponder(resp)
   504  	if err != nil {
   505  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "getPipelinesByWorkspaceNextResults", resp, "Failure responding to next results request")
   506  	}
   507  	return
   508  }
   509  
   510  // GetPipelinesByWorkspaceComplete enumerates all values, automatically crossing page boundaries as required.
   511  func (client PipelineClient) GetPipelinesByWorkspaceComplete(ctx context.Context) (result PipelineListResponseIterator, err error) {
   512  	if tracing.IsEnabled() {
   513  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineClient.GetPipelinesByWorkspace")
   514  		defer func() {
   515  			sc := -1
   516  			if result.Response().Response.Response != nil {
   517  				sc = result.page.Response().Response.Response.StatusCode
   518  			}
   519  			tracing.EndSpan(ctx, sc, err)
   520  		}()
   521  	}
   522  	result.page, err = client.GetPipelinesByWorkspace(ctx)
   523  	return
   524  }
   525  
   526  // RenamePipeline renames a pipeline.
   527  // Parameters:
   528  // pipelineName - the pipeline name.
   529  // request - proposed new name.
   530  func (client PipelineClient) RenamePipeline(ctx context.Context, pipelineName string, request RenameRequest) (result PipelineRenamePipelineFuture, err error) {
   531  	if tracing.IsEnabled() {
   532  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineClient.RenamePipeline")
   533  		defer func() {
   534  			sc := -1
   535  			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
   536  				sc = result.FutureAPI.Response().StatusCode
   537  			}
   538  			tracing.EndSpan(ctx, sc, err)
   539  		}()
   540  	}
   541  	if err := validation.Validate([]validation.Validation{
   542  		{TargetValue: pipelineName,
   543  			Constraints: []validation.Constraint{{Target: "pipelineName", Name: validation.MaxLength, Rule: 260, Chain: nil},
   544  				{Target: "pipelineName", Name: validation.MinLength, Rule: 1, Chain: nil},
   545  				{Target: "pipelineName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}},
   546  		{TargetValue: request,
   547  			Constraints: []validation.Constraint{{Target: "request.NewName", Name: validation.Null, Rule: false,
   548  				Chain: []validation.Constraint{{Target: "request.NewName", Name: validation.MaxLength, Rule: 260, Chain: nil},
   549  					{Target: "request.NewName", Name: validation.MinLength, Rule: 1, Chain: nil},
   550  					{Target: "request.NewName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil},
   551  				}}}}}); err != nil {
   552  		return result, validation.NewError("artifacts.PipelineClient", "RenamePipeline", err.Error())
   553  	}
   554  
   555  	req, err := client.RenamePipelinePreparer(ctx, pipelineName, request)
   556  	if err != nil {
   557  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "RenamePipeline", nil, "Failure preparing request")
   558  		return
   559  	}
   560  
   561  	result, err = client.RenamePipelineSender(req)
   562  	if err != nil {
   563  		err = autorest.NewErrorWithError(err, "artifacts.PipelineClient", "RenamePipeline", nil, "Failure sending request")
   564  		return
   565  	}
   566  
   567  	return
   568  }
   569  
   570  // RenamePipelinePreparer prepares the RenamePipeline request.
   571  func (client PipelineClient) RenamePipelinePreparer(ctx context.Context, pipelineName string, request RenameRequest) (*http.Request, error) {
   572  	urlParameters := map[string]interface{}{
   573  		"endpoint": client.Endpoint,
   574  	}
   575  
   576  	pathParameters := map[string]interface{}{
   577  		"pipelineName": autorest.Encode("path", pipelineName),
   578  	}
   579  
   580  	const APIVersion = "2019-06-01-preview"
   581  	queryParameters := map[string]interface{}{
   582  		"api-version": APIVersion,
   583  	}
   584  
   585  	preparer := autorest.CreatePreparer(
   586  		autorest.AsContentType("application/json; charset=utf-8"),
   587  		autorest.AsPost(),
   588  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   589  		autorest.WithPathParameters("/pipelines/{pipelineName}/rename", pathParameters),
   590  		autorest.WithJSON(request),
   591  		autorest.WithQueryParameters(queryParameters))
   592  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   593  }
   594  
   595  // RenamePipelineSender sends the RenamePipeline request. The method will close the
   596  // http.Response Body if it receives an error.
   597  func (client PipelineClient) RenamePipelineSender(req *http.Request) (future PipelineRenamePipelineFuture, err error) {
   598  	var resp *http.Response
   599  	resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   600  	if err != nil {
   601  		return
   602  	}
   603  	var azf azure.Future
   604  	azf, err = azure.NewFutureFromResponse(resp)
   605  	future.FutureAPI = &azf
   606  	future.Result = future.result
   607  	return
   608  }
   609  
   610  // RenamePipelineResponder handles the response to the RenamePipeline request. The method always
   611  // closes the http.Response Body.
   612  func (client PipelineClient) RenamePipelineResponder(resp *http.Response) (result autorest.Response, err error) {
   613  	err = autorest.Respond(
   614  		resp,
   615  		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
   616  		autorest.ByClosing())
   617  	result.Response = resp
   618  	return
   619  }
   620  

View as plain text