...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/synapse/2019-06-01-preview/artifacts/pipelinerun.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  // PipelineRunClient is the client for the PipelineRun methods of the Artifacts service.
    19  type PipelineRunClient struct {
    20  	BaseClient
    21  }
    22  
    23  // NewPipelineRunClient creates an instance of the PipelineRunClient client.
    24  func NewPipelineRunClient(endpoint string) PipelineRunClient {
    25  	return PipelineRunClient{New(endpoint)}
    26  }
    27  
    28  // CancelPipelineRun cancel a pipeline run by its run ID.
    29  // Parameters:
    30  // runID - the pipeline run identifier.
    31  // isRecursive - if true, cancel all the Child pipelines that are triggered by the current pipeline.
    32  func (client PipelineRunClient) CancelPipelineRun(ctx context.Context, runID string, isRecursive *bool) (result autorest.Response, err error) {
    33  	if tracing.IsEnabled() {
    34  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.CancelPipelineRun")
    35  		defer func() {
    36  			sc := -1
    37  			if result.Response != nil {
    38  				sc = result.Response.StatusCode
    39  			}
    40  			tracing.EndSpan(ctx, sc, err)
    41  		}()
    42  	}
    43  	req, err := client.CancelPipelineRunPreparer(ctx, runID, isRecursive)
    44  	if err != nil {
    45  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "CancelPipelineRun", nil, "Failure preparing request")
    46  		return
    47  	}
    48  
    49  	resp, err := client.CancelPipelineRunSender(req)
    50  	if err != nil {
    51  		result.Response = resp
    52  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "CancelPipelineRun", resp, "Failure sending request")
    53  		return
    54  	}
    55  
    56  	result, err = client.CancelPipelineRunResponder(resp)
    57  	if err != nil {
    58  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "CancelPipelineRun", resp, "Failure responding to request")
    59  		return
    60  	}
    61  
    62  	return
    63  }
    64  
    65  // CancelPipelineRunPreparer prepares the CancelPipelineRun request.
    66  func (client PipelineRunClient) CancelPipelineRunPreparer(ctx context.Context, runID string, isRecursive *bool) (*http.Request, error) {
    67  	urlParameters := map[string]interface{}{
    68  		"endpoint": client.Endpoint,
    69  	}
    70  
    71  	pathParameters := map[string]interface{}{
    72  		"runId": autorest.Encode("path", runID),
    73  	}
    74  
    75  	const APIVersion = "2019-06-01-preview"
    76  	queryParameters := map[string]interface{}{
    77  		"api-version": APIVersion,
    78  	}
    79  	if isRecursive != nil {
    80  		queryParameters["isRecursive"] = autorest.Encode("query", *isRecursive)
    81  	}
    82  
    83  	preparer := autorest.CreatePreparer(
    84  		autorest.AsPost(),
    85  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
    86  		autorest.WithPathParameters("/pipelineruns/{runId}/cancel", pathParameters),
    87  		autorest.WithQueryParameters(queryParameters))
    88  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
    89  }
    90  
    91  // CancelPipelineRunSender sends the CancelPipelineRun request. The method will close the
    92  // http.Response Body if it receives an error.
    93  func (client PipelineRunClient) CancelPipelineRunSender(req *http.Request) (*http.Response, error) {
    94  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
    95  }
    96  
    97  // CancelPipelineRunResponder handles the response to the CancelPipelineRun request. The method always
    98  // closes the http.Response Body.
    99  func (client PipelineRunClient) CancelPipelineRunResponder(resp *http.Response) (result autorest.Response, err error) {
   100  	err = autorest.Respond(
   101  		resp,
   102  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   103  		autorest.ByClosing())
   104  	result.Response = resp
   105  	return
   106  }
   107  
   108  // GetPipelineRun get a pipeline run by its run ID.
   109  // Parameters:
   110  // runID - the pipeline run identifier.
   111  func (client PipelineRunClient) GetPipelineRun(ctx context.Context, runID string) (result PipelineRun, err error) {
   112  	if tracing.IsEnabled() {
   113  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.GetPipelineRun")
   114  		defer func() {
   115  			sc := -1
   116  			if result.Response.Response != nil {
   117  				sc = result.Response.Response.StatusCode
   118  			}
   119  			tracing.EndSpan(ctx, sc, err)
   120  		}()
   121  	}
   122  	req, err := client.GetPipelineRunPreparer(ctx, runID)
   123  	if err != nil {
   124  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "GetPipelineRun", nil, "Failure preparing request")
   125  		return
   126  	}
   127  
   128  	resp, err := client.GetPipelineRunSender(req)
   129  	if err != nil {
   130  		result.Response = autorest.Response{Response: resp}
   131  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "GetPipelineRun", resp, "Failure sending request")
   132  		return
   133  	}
   134  
   135  	result, err = client.GetPipelineRunResponder(resp)
   136  	if err != nil {
   137  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "GetPipelineRun", resp, "Failure responding to request")
   138  		return
   139  	}
   140  
   141  	return
   142  }
   143  
   144  // GetPipelineRunPreparer prepares the GetPipelineRun request.
   145  func (client PipelineRunClient) GetPipelineRunPreparer(ctx context.Context, runID string) (*http.Request, error) {
   146  	urlParameters := map[string]interface{}{
   147  		"endpoint": client.Endpoint,
   148  	}
   149  
   150  	pathParameters := map[string]interface{}{
   151  		"runId": autorest.Encode("path", runID),
   152  	}
   153  
   154  	const APIVersion = "2019-06-01-preview"
   155  	queryParameters := map[string]interface{}{
   156  		"api-version": APIVersion,
   157  	}
   158  
   159  	preparer := autorest.CreatePreparer(
   160  		autorest.AsGet(),
   161  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   162  		autorest.WithPathParameters("/pipelineruns/{runId}", pathParameters),
   163  		autorest.WithQueryParameters(queryParameters))
   164  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   165  }
   166  
   167  // GetPipelineRunSender sends the GetPipelineRun request. The method will close the
   168  // http.Response Body if it receives an error.
   169  func (client PipelineRunClient) GetPipelineRunSender(req *http.Request) (*http.Response, error) {
   170  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   171  }
   172  
   173  // GetPipelineRunResponder handles the response to the GetPipelineRun request. The method always
   174  // closes the http.Response Body.
   175  func (client PipelineRunClient) GetPipelineRunResponder(resp *http.Response) (result PipelineRun, err error) {
   176  	err = autorest.Respond(
   177  		resp,
   178  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   179  		autorest.ByUnmarshallingJSON(&result),
   180  		autorest.ByClosing())
   181  	result.Response = autorest.Response{Response: resp}
   182  	return
   183  }
   184  
   185  // QueryActivityRuns query activity runs based on input filter conditions.
   186  // Parameters:
   187  // pipelineName - the pipeline name.
   188  // runID - the pipeline run identifier.
   189  // filterParameters - parameters to filter the activity runs.
   190  func (client PipelineRunClient) QueryActivityRuns(ctx context.Context, pipelineName string, runID string, filterParameters RunFilterParameters) (result ActivityRunsQueryResponse, err error) {
   191  	if tracing.IsEnabled() {
   192  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.QueryActivityRuns")
   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: pipelineName,
   203  			Constraints: []validation.Constraint{{Target: "pipelineName", Name: validation.MaxLength, Rule: 260, Chain: nil},
   204  				{Target: "pipelineName", Name: validation.MinLength, Rule: 1, Chain: nil},
   205  				{Target: "pipelineName", Name: validation.Pattern, Rule: `^[A-Za-z0-9_][^<>*#.%&:\\+?/]*$`, Chain: nil}}},
   206  		{TargetValue: filterParameters,
   207  			Constraints: []validation.Constraint{{Target: "filterParameters.LastUpdatedAfter", Name: validation.Null, Rule: true, Chain: nil},
   208  				{Target: "filterParameters.LastUpdatedBefore", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   209  		return result, validation.NewError("artifacts.PipelineRunClient", "QueryActivityRuns", err.Error())
   210  	}
   211  
   212  	req, err := client.QueryActivityRunsPreparer(ctx, pipelineName, runID, filterParameters)
   213  	if err != nil {
   214  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryActivityRuns", nil, "Failure preparing request")
   215  		return
   216  	}
   217  
   218  	resp, err := client.QueryActivityRunsSender(req)
   219  	if err != nil {
   220  		result.Response = autorest.Response{Response: resp}
   221  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryActivityRuns", resp, "Failure sending request")
   222  		return
   223  	}
   224  
   225  	result, err = client.QueryActivityRunsResponder(resp)
   226  	if err != nil {
   227  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryActivityRuns", resp, "Failure responding to request")
   228  		return
   229  	}
   230  
   231  	return
   232  }
   233  
   234  // QueryActivityRunsPreparer prepares the QueryActivityRuns request.
   235  func (client PipelineRunClient) QueryActivityRunsPreparer(ctx context.Context, pipelineName string, runID string, filterParameters RunFilterParameters) (*http.Request, error) {
   236  	urlParameters := map[string]interface{}{
   237  		"endpoint": client.Endpoint,
   238  	}
   239  
   240  	pathParameters := map[string]interface{}{
   241  		"pipelineName": autorest.Encode("path", pipelineName),
   242  		"runId":        autorest.Encode("path", runID),
   243  	}
   244  
   245  	const APIVersion = "2019-06-01-preview"
   246  	queryParameters := map[string]interface{}{
   247  		"api-version": APIVersion,
   248  	}
   249  
   250  	preparer := autorest.CreatePreparer(
   251  		autorest.AsContentType("application/json; charset=utf-8"),
   252  		autorest.AsPost(),
   253  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   254  		autorest.WithPathParameters("/pipelines/{pipelineName}/pipelineruns/{runId}/queryActivityruns", pathParameters),
   255  		autorest.WithJSON(filterParameters),
   256  		autorest.WithQueryParameters(queryParameters))
   257  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   258  }
   259  
   260  // QueryActivityRunsSender sends the QueryActivityRuns request. The method will close the
   261  // http.Response Body if it receives an error.
   262  func (client PipelineRunClient) QueryActivityRunsSender(req *http.Request) (*http.Response, error) {
   263  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   264  }
   265  
   266  // QueryActivityRunsResponder handles the response to the QueryActivityRuns request. The method always
   267  // closes the http.Response Body.
   268  func (client PipelineRunClient) QueryActivityRunsResponder(resp *http.Response) (result ActivityRunsQueryResponse, err error) {
   269  	err = autorest.Respond(
   270  		resp,
   271  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   272  		autorest.ByUnmarshallingJSON(&result),
   273  		autorest.ByClosing())
   274  	result.Response = autorest.Response{Response: resp}
   275  	return
   276  }
   277  
   278  // QueryPipelineRunsByWorkspace query pipeline runs in the workspace based on input filter conditions.
   279  // Parameters:
   280  // filterParameters - parameters to filter the pipeline run.
   281  func (client PipelineRunClient) QueryPipelineRunsByWorkspace(ctx context.Context, filterParameters RunFilterParameters) (result PipelineRunsQueryResponse, err error) {
   282  	if tracing.IsEnabled() {
   283  		ctx = tracing.StartSpan(ctx, fqdn+"/PipelineRunClient.QueryPipelineRunsByWorkspace")
   284  		defer func() {
   285  			sc := -1
   286  			if result.Response.Response != nil {
   287  				sc = result.Response.Response.StatusCode
   288  			}
   289  			tracing.EndSpan(ctx, sc, err)
   290  		}()
   291  	}
   292  	if err := validation.Validate([]validation.Validation{
   293  		{TargetValue: filterParameters,
   294  			Constraints: []validation.Constraint{{Target: "filterParameters.LastUpdatedAfter", Name: validation.Null, Rule: true, Chain: nil},
   295  				{Target: "filterParameters.LastUpdatedBefore", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
   296  		return result, validation.NewError("artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", err.Error())
   297  	}
   298  
   299  	req, err := client.QueryPipelineRunsByWorkspacePreparer(ctx, filterParameters)
   300  	if err != nil {
   301  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", nil, "Failure preparing request")
   302  		return
   303  	}
   304  
   305  	resp, err := client.QueryPipelineRunsByWorkspaceSender(req)
   306  	if err != nil {
   307  		result.Response = autorest.Response{Response: resp}
   308  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", resp, "Failure sending request")
   309  		return
   310  	}
   311  
   312  	result, err = client.QueryPipelineRunsByWorkspaceResponder(resp)
   313  	if err != nil {
   314  		err = autorest.NewErrorWithError(err, "artifacts.PipelineRunClient", "QueryPipelineRunsByWorkspace", resp, "Failure responding to request")
   315  		return
   316  	}
   317  
   318  	return
   319  }
   320  
   321  // QueryPipelineRunsByWorkspacePreparer prepares the QueryPipelineRunsByWorkspace request.
   322  func (client PipelineRunClient) QueryPipelineRunsByWorkspacePreparer(ctx context.Context, filterParameters RunFilterParameters) (*http.Request, error) {
   323  	urlParameters := map[string]interface{}{
   324  		"endpoint": client.Endpoint,
   325  	}
   326  
   327  	const APIVersion = "2019-06-01-preview"
   328  	queryParameters := map[string]interface{}{
   329  		"api-version": APIVersion,
   330  	}
   331  
   332  	preparer := autorest.CreatePreparer(
   333  		autorest.AsContentType("application/json; charset=utf-8"),
   334  		autorest.AsPost(),
   335  		autorest.WithCustomBaseURL("{endpoint}", urlParameters),
   336  		autorest.WithPath("/queryPipelineRuns"),
   337  		autorest.WithJSON(filterParameters),
   338  		autorest.WithQueryParameters(queryParameters))
   339  	return preparer.Prepare((&http.Request{}).WithContext(ctx))
   340  }
   341  
   342  // QueryPipelineRunsByWorkspaceSender sends the QueryPipelineRunsByWorkspace request. The method will close the
   343  // http.Response Body if it receives an error.
   344  func (client PipelineRunClient) QueryPipelineRunsByWorkspaceSender(req *http.Request) (*http.Response, error) {
   345  	return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
   346  }
   347  
   348  // QueryPipelineRunsByWorkspaceResponder handles the response to the QueryPipelineRunsByWorkspace request. The method always
   349  // closes the http.Response Body.
   350  func (client PipelineRunClient) QueryPipelineRunsByWorkspaceResponder(resp *http.Response) (result PipelineRunsQueryResponse, err error) {
   351  	err = autorest.Respond(
   352  		resp,
   353  		azure.WithErrorUnlessStatusCode(http.StatusOK),
   354  		autorest.ByUnmarshallingJSON(&result),
   355  		autorest.ByClosing())
   356  	result.Response = autorest.Response{Response: resp}
   357  	return
   358  }
   359  

View as plain text