1package containerregistry
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
9import (
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// TaskRunsClient is the client for the TaskRuns methods of the Containerregistry service.
19type TaskRunsClient struct {
20	BaseClient
21}
22
23// NewTaskRunsClient creates an instance of the TaskRunsClient client.
24func NewTaskRunsClient(subscriptionID string) TaskRunsClient {
25	return NewTaskRunsClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewTaskRunsClientWithBaseURI creates an instance of the TaskRunsClient client using a custom endpoint.  Use this
29// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack).
30func NewTaskRunsClientWithBaseURI(baseURI string, subscriptionID string) TaskRunsClient {
31	return TaskRunsClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// Create creates a task run for a container registry with the specified parameters.
35// Parameters:
36// resourceGroupName - the name of the resource group to which the container registry belongs.
37// registryName - the name of the container registry.
38// taskRunName - the name of the task run.
39// taskRun - the parameters of a run that needs to scheduled.
40func (client TaskRunsClient) Create(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun) (result TaskRunsCreateFuture, err error) {
41	if tracing.IsEnabled() {
42		ctx = tracing.StartSpan(ctx, fqdn+"/TaskRunsClient.Create")
43		defer func() {
44			sc := -1
45			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
46				sc = result.FutureAPI.Response().StatusCode
47			}
48			tracing.EndSpan(ctx, sc, err)
49		}()
50	}
51	if err := validation.Validate([]validation.Validation{
52		{TargetValue: resourceGroupName,
53			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
54		{TargetValue: registryName,
55			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
56				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
57				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
58		{TargetValue: taskRunName,
59			Constraints: []validation.Constraint{{Target: "taskRunName", Name: validation.MaxLength, Rule: 50, Chain: nil},
60				{Target: "taskRunName", Name: validation.MinLength, Rule: 5, Chain: nil},
61				{Target: "taskRunName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]*$`, Chain: nil}}}}); err != nil {
62		return result, validation.NewError("containerregistry.TaskRunsClient", "Create", err.Error())
63	}
64
65	req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, taskRunName, taskRun)
66	if err != nil {
67		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Create", nil, "Failure preparing request")
68		return
69	}
70
71	result, err = client.CreateSender(req)
72	if err != nil {
73		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Create", nil, "Failure sending request")
74		return
75	}
76
77	return
78}
79
80// CreatePreparer prepares the Create request.
81func (client TaskRunsClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, taskRun TaskRun) (*http.Request, error) {
82	pathParameters := map[string]interface{}{
83		"registryName":      autorest.Encode("path", registryName),
84		"resourceGroupName": autorest.Encode("path", resourceGroupName),
85		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
86		"taskRunName":       autorest.Encode("path", taskRunName),
87	}
88
89	const APIVersion = "2019-06-01-preview"
90	queryParameters := map[string]interface{}{
91		"api-version": APIVersion,
92	}
93
94	preparer := autorest.CreatePreparer(
95		autorest.AsContentType("application/json; charset=utf-8"),
96		autorest.AsPut(),
97		autorest.WithBaseURL(client.BaseURI),
98		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", pathParameters),
99		autorest.WithJSON(taskRun),
100		autorest.WithQueryParameters(queryParameters))
101	return preparer.Prepare((&http.Request{}).WithContext(ctx))
102}
103
104// CreateSender sends the Create request. The method will close the
105// http.Response Body if it receives an error.
106func (client TaskRunsClient) CreateSender(req *http.Request) (future TaskRunsCreateFuture, err error) {
107	var resp *http.Response
108	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
109	if err != nil {
110		return
111	}
112	var azf azure.Future
113	azf, err = azure.NewFutureFromResponse(resp)
114	future.FutureAPI = &azf
115	future.Result = future.result
116	return
117}
118
119// CreateResponder handles the response to the Create request. The method always
120// closes the http.Response Body.
121func (client TaskRunsClient) CreateResponder(resp *http.Response) (result TaskRun, err error) {
122	err = autorest.Respond(
123		resp,
124		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
125		autorest.ByUnmarshallingJSON(&result),
126		autorest.ByClosing())
127	result.Response = autorest.Response{Response: resp}
128	return
129}
130
131// Delete deletes a specified task run resource.
132// Parameters:
133// resourceGroupName - the name of the resource group to which the container registry belongs.
134// registryName - the name of the container registry.
135// taskRunName - the name of the task run.
136func (client TaskRunsClient) Delete(ctx context.Context, resourceGroupName string, registryName string, taskRunName string) (result TaskRunsDeleteFuture, err error) {
137	if tracing.IsEnabled() {
138		ctx = tracing.StartSpan(ctx, fqdn+"/TaskRunsClient.Delete")
139		defer func() {
140			sc := -1
141			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
142				sc = result.FutureAPI.Response().StatusCode
143			}
144			tracing.EndSpan(ctx, sc, err)
145		}()
146	}
147	if err := validation.Validate([]validation.Validation{
148		{TargetValue: resourceGroupName,
149			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
150		{TargetValue: registryName,
151			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
152				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
153				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
154		{TargetValue: taskRunName,
155			Constraints: []validation.Constraint{{Target: "taskRunName", Name: validation.MaxLength, Rule: 50, Chain: nil},
156				{Target: "taskRunName", Name: validation.MinLength, Rule: 5, Chain: nil},
157				{Target: "taskRunName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]*$`, Chain: nil}}}}); err != nil {
158		return result, validation.NewError("containerregistry.TaskRunsClient", "Delete", err.Error())
159	}
160
161	req, err := client.DeletePreparer(ctx, resourceGroupName, registryName, taskRunName)
162	if err != nil {
163		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Delete", nil, "Failure preparing request")
164		return
165	}
166
167	result, err = client.DeleteSender(req)
168	if err != nil {
169		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Delete", nil, "Failure sending request")
170		return
171	}
172
173	return
174}
175
176// DeletePreparer prepares the Delete request.
177func (client TaskRunsClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string, taskRunName string) (*http.Request, error) {
178	pathParameters := map[string]interface{}{
179		"registryName":      autorest.Encode("path", registryName),
180		"resourceGroupName": autorest.Encode("path", resourceGroupName),
181		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
182		"taskRunName":       autorest.Encode("path", taskRunName),
183	}
184
185	const APIVersion = "2019-06-01-preview"
186	queryParameters := map[string]interface{}{
187		"api-version": APIVersion,
188	}
189
190	preparer := autorest.CreatePreparer(
191		autorest.AsDelete(),
192		autorest.WithBaseURL(client.BaseURI),
193		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", pathParameters),
194		autorest.WithQueryParameters(queryParameters))
195	return preparer.Prepare((&http.Request{}).WithContext(ctx))
196}
197
198// DeleteSender sends the Delete request. The method will close the
199// http.Response Body if it receives an error.
200func (client TaskRunsClient) DeleteSender(req *http.Request) (future TaskRunsDeleteFuture, err error) {
201	var resp *http.Response
202	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
203	if err != nil {
204		return
205	}
206	var azf azure.Future
207	azf, err = azure.NewFutureFromResponse(resp)
208	future.FutureAPI = &azf
209	future.Result = future.result
210	return
211}
212
213// DeleteResponder handles the response to the Delete request. The method always
214// closes the http.Response Body.
215func (client TaskRunsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
216	err = autorest.Respond(
217		resp,
218		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
219		autorest.ByClosing())
220	result.Response = resp
221	return
222}
223
224// Get gets the detailed information for a given task run.
225// Parameters:
226// resourceGroupName - the name of the resource group to which the container registry belongs.
227// registryName - the name of the container registry.
228// taskRunName - the name of the task run.
229func (client TaskRunsClient) Get(ctx context.Context, resourceGroupName string, registryName string, taskRunName string) (result TaskRun, err error) {
230	if tracing.IsEnabled() {
231		ctx = tracing.StartSpan(ctx, fqdn+"/TaskRunsClient.Get")
232		defer func() {
233			sc := -1
234			if result.Response.Response != nil {
235				sc = result.Response.Response.StatusCode
236			}
237			tracing.EndSpan(ctx, sc, err)
238		}()
239	}
240	if err := validation.Validate([]validation.Validation{
241		{TargetValue: resourceGroupName,
242			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
243		{TargetValue: registryName,
244			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
245				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
246				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
247		{TargetValue: taskRunName,
248			Constraints: []validation.Constraint{{Target: "taskRunName", Name: validation.MaxLength, Rule: 50, Chain: nil},
249				{Target: "taskRunName", Name: validation.MinLength, Rule: 5, Chain: nil},
250				{Target: "taskRunName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]*$`, Chain: nil}}}}); err != nil {
251		return result, validation.NewError("containerregistry.TaskRunsClient", "Get", err.Error())
252	}
253
254	req, err := client.GetPreparer(ctx, resourceGroupName, registryName, taskRunName)
255	if err != nil {
256		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Get", nil, "Failure preparing request")
257		return
258	}
259
260	resp, err := client.GetSender(req)
261	if err != nil {
262		result.Response = autorest.Response{Response: resp}
263		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Get", resp, "Failure sending request")
264		return
265	}
266
267	result, err = client.GetResponder(resp)
268	if err != nil {
269		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Get", resp, "Failure responding to request")
270		return
271	}
272
273	return
274}
275
276// GetPreparer prepares the Get request.
277func (client TaskRunsClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string, taskRunName string) (*http.Request, error) {
278	pathParameters := map[string]interface{}{
279		"registryName":      autorest.Encode("path", registryName),
280		"resourceGroupName": autorest.Encode("path", resourceGroupName),
281		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
282		"taskRunName":       autorest.Encode("path", taskRunName),
283	}
284
285	const APIVersion = "2019-06-01-preview"
286	queryParameters := map[string]interface{}{
287		"api-version": APIVersion,
288	}
289
290	preparer := autorest.CreatePreparer(
291		autorest.AsGet(),
292		autorest.WithBaseURL(client.BaseURI),
293		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", pathParameters),
294		autorest.WithQueryParameters(queryParameters))
295	return preparer.Prepare((&http.Request{}).WithContext(ctx))
296}
297
298// GetSender sends the Get request. The method will close the
299// http.Response Body if it receives an error.
300func (client TaskRunsClient) GetSender(req *http.Request) (*http.Response, error) {
301	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
302}
303
304// GetResponder handles the response to the Get request. The method always
305// closes the http.Response Body.
306func (client TaskRunsClient) GetResponder(resp *http.Response) (result TaskRun, err error) {
307	err = autorest.Respond(
308		resp,
309		azure.WithErrorUnlessStatusCode(http.StatusOK),
310		autorest.ByUnmarshallingJSON(&result),
311		autorest.ByClosing())
312	result.Response = autorest.Response{Response: resp}
313	return
314}
315
316// GetDetails gets the detailed information for a given task run that includes all secrets.
317// Parameters:
318// resourceGroupName - the name of the resource group to which the container registry belongs.
319// registryName - the name of the container registry.
320// taskRunName - the name of the task run.
321func (client TaskRunsClient) GetDetails(ctx context.Context, resourceGroupName string, registryName string, taskRunName string) (result TaskRun, err error) {
322	if tracing.IsEnabled() {
323		ctx = tracing.StartSpan(ctx, fqdn+"/TaskRunsClient.GetDetails")
324		defer func() {
325			sc := -1
326			if result.Response.Response != nil {
327				sc = result.Response.Response.StatusCode
328			}
329			tracing.EndSpan(ctx, sc, err)
330		}()
331	}
332	if err := validation.Validate([]validation.Validation{
333		{TargetValue: resourceGroupName,
334			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
335		{TargetValue: registryName,
336			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
337				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
338				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
339		{TargetValue: taskRunName,
340			Constraints: []validation.Constraint{{Target: "taskRunName", Name: validation.MaxLength, Rule: 50, Chain: nil},
341				{Target: "taskRunName", Name: validation.MinLength, Rule: 5, Chain: nil},
342				{Target: "taskRunName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]*$`, Chain: nil}}}}); err != nil {
343		return result, validation.NewError("containerregistry.TaskRunsClient", "GetDetails", err.Error())
344	}
345
346	req, err := client.GetDetailsPreparer(ctx, resourceGroupName, registryName, taskRunName)
347	if err != nil {
348		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "GetDetails", nil, "Failure preparing request")
349		return
350	}
351
352	resp, err := client.GetDetailsSender(req)
353	if err != nil {
354		result.Response = autorest.Response{Response: resp}
355		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "GetDetails", resp, "Failure sending request")
356		return
357	}
358
359	result, err = client.GetDetailsResponder(resp)
360	if err != nil {
361		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "GetDetails", resp, "Failure responding to request")
362		return
363	}
364
365	return
366}
367
368// GetDetailsPreparer prepares the GetDetails request.
369func (client TaskRunsClient) GetDetailsPreparer(ctx context.Context, resourceGroupName string, registryName string, taskRunName string) (*http.Request, error) {
370	pathParameters := map[string]interface{}{
371		"registryName":      autorest.Encode("path", registryName),
372		"resourceGroupName": autorest.Encode("path", resourceGroupName),
373		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
374		"taskRunName":       autorest.Encode("path", taskRunName),
375	}
376
377	const APIVersion = "2019-06-01-preview"
378	queryParameters := map[string]interface{}{
379		"api-version": APIVersion,
380	}
381
382	preparer := autorest.CreatePreparer(
383		autorest.AsPost(),
384		autorest.WithBaseURL(client.BaseURI),
385		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}/listDetails", pathParameters),
386		autorest.WithQueryParameters(queryParameters))
387	return preparer.Prepare((&http.Request{}).WithContext(ctx))
388}
389
390// GetDetailsSender sends the GetDetails request. The method will close the
391// http.Response Body if it receives an error.
392func (client TaskRunsClient) GetDetailsSender(req *http.Request) (*http.Response, error) {
393	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
394}
395
396// GetDetailsResponder handles the response to the GetDetails request. The method always
397// closes the http.Response Body.
398func (client TaskRunsClient) GetDetailsResponder(resp *http.Response) (result TaskRun, err error) {
399	err = autorest.Respond(
400		resp,
401		azure.WithErrorUnlessStatusCode(http.StatusOK),
402		autorest.ByUnmarshallingJSON(&result),
403		autorest.ByClosing())
404	result.Response = autorest.Response{Response: resp}
405	return
406}
407
408// List lists all the task runs for a specified container registry.
409// Parameters:
410// resourceGroupName - the name of the resource group to which the container registry belongs.
411// registryName - the name of the container registry.
412func (client TaskRunsClient) List(ctx context.Context, resourceGroupName string, registryName string) (result TaskRunListResultPage, err error) {
413	if tracing.IsEnabled() {
414		ctx = tracing.StartSpan(ctx, fqdn+"/TaskRunsClient.List")
415		defer func() {
416			sc := -1
417			if result.trlr.Response.Response != nil {
418				sc = result.trlr.Response.Response.StatusCode
419			}
420			tracing.EndSpan(ctx, sc, err)
421		}()
422	}
423	if err := validation.Validate([]validation.Validation{
424		{TargetValue: resourceGroupName,
425			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
426		{TargetValue: registryName,
427			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
428				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
429				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
430		return result, validation.NewError("containerregistry.TaskRunsClient", "List", err.Error())
431	}
432
433	result.fn = client.listNextResults
434	req, err := client.ListPreparer(ctx, resourceGroupName, registryName)
435	if err != nil {
436		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "List", nil, "Failure preparing request")
437		return
438	}
439
440	resp, err := client.ListSender(req)
441	if err != nil {
442		result.trlr.Response = autorest.Response{Response: resp}
443		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "List", resp, "Failure sending request")
444		return
445	}
446
447	result.trlr, err = client.ListResponder(resp)
448	if err != nil {
449		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "List", resp, "Failure responding to request")
450		return
451	}
452	if result.trlr.hasNextLink() && result.trlr.IsEmpty() {
453		err = result.NextWithContext(ctx)
454		return
455	}
456
457	return
458}
459
460// ListPreparer prepares the List request.
461func (client TaskRunsClient) ListPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
462	pathParameters := map[string]interface{}{
463		"registryName":      autorest.Encode("path", registryName),
464		"resourceGroupName": autorest.Encode("path", resourceGroupName),
465		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
466	}
467
468	const APIVersion = "2019-06-01-preview"
469	queryParameters := map[string]interface{}{
470		"api-version": APIVersion,
471	}
472
473	preparer := autorest.CreatePreparer(
474		autorest.AsGet(),
475		autorest.WithBaseURL(client.BaseURI),
476		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns", pathParameters),
477		autorest.WithQueryParameters(queryParameters))
478	return preparer.Prepare((&http.Request{}).WithContext(ctx))
479}
480
481// ListSender sends the List request. The method will close the
482// http.Response Body if it receives an error.
483func (client TaskRunsClient) ListSender(req *http.Request) (*http.Response, error) {
484	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
485}
486
487// ListResponder handles the response to the List request. The method always
488// closes the http.Response Body.
489func (client TaskRunsClient) ListResponder(resp *http.Response) (result TaskRunListResult, err error) {
490	err = autorest.Respond(
491		resp,
492		azure.WithErrorUnlessStatusCode(http.StatusOK),
493		autorest.ByUnmarshallingJSON(&result),
494		autorest.ByClosing())
495	result.Response = autorest.Response{Response: resp}
496	return
497}
498
499// listNextResults retrieves the next set of results, if any.
500func (client TaskRunsClient) listNextResults(ctx context.Context, lastResults TaskRunListResult) (result TaskRunListResult, err error) {
501	req, err := lastResults.taskRunListResultPreparer(ctx)
502	if err != nil {
503		return result, autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "listNextResults", nil, "Failure preparing next results request")
504	}
505	if req == nil {
506		return
507	}
508	resp, err := client.ListSender(req)
509	if err != nil {
510		result.Response = autorest.Response{Response: resp}
511		return result, autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "listNextResults", resp, "Failure sending next results request")
512	}
513	result, err = client.ListResponder(resp)
514	if err != nil {
515		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "listNextResults", resp, "Failure responding to next results request")
516	}
517	return
518}
519
520// ListComplete enumerates all values, automatically crossing page boundaries as required.
521func (client TaskRunsClient) ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result TaskRunListResultIterator, err error) {
522	if tracing.IsEnabled() {
523		ctx = tracing.StartSpan(ctx, fqdn+"/TaskRunsClient.List")
524		defer func() {
525			sc := -1
526			if result.Response().Response.Response != nil {
527				sc = result.page.Response().Response.Response.StatusCode
528			}
529			tracing.EndSpan(ctx, sc, err)
530		}()
531	}
532	result.page, err = client.List(ctx, resourceGroupName, registryName)
533	return
534}
535
536// Update updates a task run with the specified parameters.
537// Parameters:
538// resourceGroupName - the name of the resource group to which the container registry belongs.
539// registryName - the name of the container registry.
540// taskRunName - the name of the task run.
541// updateParameters - the parameters for updating a task run.
542func (client TaskRunsClient) Update(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters) (result TaskRunsUpdateFuture, err error) {
543	if tracing.IsEnabled() {
544		ctx = tracing.StartSpan(ctx, fqdn+"/TaskRunsClient.Update")
545		defer func() {
546			sc := -1
547			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
548				sc = result.FutureAPI.Response().StatusCode
549			}
550			tracing.EndSpan(ctx, sc, err)
551		}()
552	}
553	if err := validation.Validate([]validation.Validation{
554		{TargetValue: resourceGroupName,
555			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
556		{TargetValue: registryName,
557			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
558				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
559				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
560		{TargetValue: taskRunName,
561			Constraints: []validation.Constraint{{Target: "taskRunName", Name: validation.MaxLength, Rule: 50, Chain: nil},
562				{Target: "taskRunName", Name: validation.MinLength, Rule: 5, Chain: nil},
563				{Target: "taskRunName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]*$`, Chain: nil}}}}); err != nil {
564		return result, validation.NewError("containerregistry.TaskRunsClient", "Update", err.Error())
565	}
566
567	req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, taskRunName, updateParameters)
568	if err != nil {
569		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Update", nil, "Failure preparing request")
570		return
571	}
572
573	result, err = client.UpdateSender(req)
574	if err != nil {
575		err = autorest.NewErrorWithError(err, "containerregistry.TaskRunsClient", "Update", nil, "Failure sending request")
576		return
577	}
578
579	return
580}
581
582// UpdatePreparer prepares the Update request.
583func (client TaskRunsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, taskRunName string, updateParameters TaskRunUpdateParameters) (*http.Request, error) {
584	pathParameters := map[string]interface{}{
585		"registryName":      autorest.Encode("path", registryName),
586		"resourceGroupName": autorest.Encode("path", resourceGroupName),
587		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
588		"taskRunName":       autorest.Encode("path", taskRunName),
589	}
590
591	const APIVersion = "2019-06-01-preview"
592	queryParameters := map[string]interface{}{
593		"api-version": APIVersion,
594	}
595
596	preparer := autorest.CreatePreparer(
597		autorest.AsContentType("application/json; charset=utf-8"),
598		autorest.AsPatch(),
599		autorest.WithBaseURL(client.BaseURI),
600		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/taskRuns/{taskRunName}", pathParameters),
601		autorest.WithJSON(updateParameters),
602		autorest.WithQueryParameters(queryParameters))
603	return preparer.Prepare((&http.Request{}).WithContext(ctx))
604}
605
606// UpdateSender sends the Update request. The method will close the
607// http.Response Body if it receives an error.
608func (client TaskRunsClient) UpdateSender(req *http.Request) (future TaskRunsUpdateFuture, err error) {
609	var resp *http.Response
610	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
611	if err != nil {
612		return
613	}
614	var azf azure.Future
615	azf, err = azure.NewFutureFromResponse(resp)
616	future.FutureAPI = &azf
617	future.Result = future.result
618	return
619}
620
621// UpdateResponder handles the response to the Update request. The method always
622// closes the http.Response Body.
623func (client TaskRunsClient) UpdateResponder(resp *http.Response) (result TaskRun, err error) {
624	err = autorest.Respond(
625		resp,
626		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
627		autorest.ByUnmarshallingJSON(&result),
628		autorest.ByClosing())
629	result.Response = autorest.Response{Response: resp}
630	return
631}
632