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// RegistriesClient is the client for the Registries methods of the Containerregistry service.
19type RegistriesClient struct {
20	BaseClient
21}
22
23// NewRegistriesClient creates an instance of the RegistriesClient client.
24func NewRegistriesClient(subscriptionID string) RegistriesClient {
25	return NewRegistriesClientWithBaseURI(DefaultBaseURI, subscriptionID)
26}
27
28// NewRegistriesClientWithBaseURI creates an instance of the RegistriesClient 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 NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) RegistriesClient {
31	return RegistriesClient{NewWithBaseURI(baseURI, subscriptionID)}
32}
33
34// CheckNameAvailability checks whether the container registry name is available for use. The name must contain only
35// alphanumeric characters, be globally unique, and between 5 and 50 characters in length.
36// Parameters:
37// registryNameCheckRequest - the object containing information for the availability request.
38func (client RegistriesClient) CheckNameAvailability(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) {
39	if tracing.IsEnabled() {
40		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.CheckNameAvailability")
41		defer func() {
42			sc := -1
43			if result.Response.Response != nil {
44				sc = result.Response.Response.StatusCode
45			}
46			tracing.EndSpan(ctx, sc, err)
47		}()
48	}
49	if err := validation.Validate([]validation.Validation{
50		{TargetValue: registryNameCheckRequest,
51			Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true,
52				Chain: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil},
53					{Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil},
54					{Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil},
55				}},
56				{Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
57		return result, validation.NewError("containerregistry.RegistriesClient", "CheckNameAvailability", err.Error())
58	}
59
60	req, err := client.CheckNameAvailabilityPreparer(ctx, registryNameCheckRequest)
61	if err != nil {
62		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request")
63		return
64	}
65
66	resp, err := client.CheckNameAvailabilitySender(req)
67	if err != nil {
68		result.Response = autorest.Response{Response: resp}
69		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request")
70		return
71	}
72
73	result, err = client.CheckNameAvailabilityResponder(resp)
74	if err != nil {
75		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure responding to request")
76		return
77	}
78
79	return
80}
81
82// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request.
83func (client RegistriesClient) CheckNameAvailabilityPreparer(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (*http.Request, error) {
84	pathParameters := map[string]interface{}{
85		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
86	}
87
88	const APIVersion = "2017-10-01"
89	queryParameters := map[string]interface{}{
90		"api-version": APIVersion,
91	}
92
93	preparer := autorest.CreatePreparer(
94		autorest.AsContentType("application/json; charset=utf-8"),
95		autorest.AsPost(),
96		autorest.WithBaseURL(client.BaseURI),
97		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability", pathParameters),
98		autorest.WithJSON(registryNameCheckRequest),
99		autorest.WithQueryParameters(queryParameters))
100	return preparer.Prepare((&http.Request{}).WithContext(ctx))
101}
102
103// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the
104// http.Response Body if it receives an error.
105func (client RegistriesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) {
106	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
107}
108
109// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always
110// closes the http.Response Body.
111func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Response) (result RegistryNameStatus, err error) {
112	err = autorest.Respond(
113		resp,
114		azure.WithErrorUnlessStatusCode(http.StatusOK),
115		autorest.ByUnmarshallingJSON(&result),
116		autorest.ByClosing())
117	result.Response = autorest.Response{Response: resp}
118	return
119}
120
121// Create creates a container registry with the specified parameters.
122// Parameters:
123// resourceGroupName - the name of the resource group to which the container registry belongs.
124// registryName - the name of the container registry.
125// registry - the parameters for creating a container registry.
126func (client RegistriesClient) Create(ctx context.Context, resourceGroupName string, registryName string, registry Registry) (result RegistriesCreateFuture, err error) {
127	if tracing.IsEnabled() {
128		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Create")
129		defer func() {
130			sc := -1
131			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
132				sc = result.FutureAPI.Response().StatusCode
133			}
134			tracing.EndSpan(ctx, sc, err)
135		}()
136	}
137	if err := validation.Validate([]validation.Validation{
138		{TargetValue: resourceGroupName,
139			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
140		{TargetValue: registryName,
141			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
142				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
143				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
144		{TargetValue: registry,
145			Constraints: []validation.Constraint{{Target: "registry.Sku", Name: validation.Null, Rule: true, Chain: nil},
146				{Target: "registry.RegistryProperties", Name: validation.Null, Rule: false,
147					Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount", Name: validation.Null, Rule: false,
148						Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount.ID", Name: validation.Null, Rule: true, Chain: nil}}},
149					}}}}}); err != nil {
150		return result, validation.NewError("containerregistry.RegistriesClient", "Create", err.Error())
151	}
152
153	req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, registry)
154	if err != nil {
155		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure preparing request")
156		return
157	}
158
159	result, err = client.CreateSender(req)
160	if err != nil {
161		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure sending request")
162		return
163	}
164
165	return
166}
167
168// CreatePreparer prepares the Create request.
169func (client RegistriesClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, registry Registry) (*http.Request, error) {
170	pathParameters := map[string]interface{}{
171		"registryName":      autorest.Encode("path", registryName),
172		"resourceGroupName": autorest.Encode("path", resourceGroupName),
173		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
174	}
175
176	const APIVersion = "2017-10-01"
177	queryParameters := map[string]interface{}{
178		"api-version": APIVersion,
179	}
180
181	preparer := autorest.CreatePreparer(
182		autorest.AsContentType("application/json; charset=utf-8"),
183		autorest.AsPut(),
184		autorest.WithBaseURL(client.BaseURI),
185		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters),
186		autorest.WithJSON(registry),
187		autorest.WithQueryParameters(queryParameters))
188	return preparer.Prepare((&http.Request{}).WithContext(ctx))
189}
190
191// CreateSender sends the Create request. The method will close the
192// http.Response Body if it receives an error.
193func (client RegistriesClient) CreateSender(req *http.Request) (future RegistriesCreateFuture, err error) {
194	var resp *http.Response
195	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
196	if err != nil {
197		return
198	}
199	var azf azure.Future
200	azf, err = azure.NewFutureFromResponse(resp)
201	future.FutureAPI = &azf
202	future.Result = future.result
203	return
204}
205
206// CreateResponder handles the response to the Create request. The method always
207// closes the http.Response Body.
208func (client RegistriesClient) CreateResponder(resp *http.Response) (result Registry, err error) {
209	err = autorest.Respond(
210		resp,
211		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
212		autorest.ByUnmarshallingJSON(&result),
213		autorest.ByClosing())
214	result.Response = autorest.Response{Response: resp}
215	return
216}
217
218// Delete deletes a container registry.
219// Parameters:
220// resourceGroupName - the name of the resource group to which the container registry belongs.
221// registryName - the name of the container registry.
222func (client RegistriesClient) Delete(ctx context.Context, resourceGroupName string, registryName string) (result RegistriesDeleteFuture, err error) {
223	if tracing.IsEnabled() {
224		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Delete")
225		defer func() {
226			sc := -1
227			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
228				sc = result.FutureAPI.Response().StatusCode
229			}
230			tracing.EndSpan(ctx, sc, err)
231		}()
232	}
233	if err := validation.Validate([]validation.Validation{
234		{TargetValue: resourceGroupName,
235			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
236		{TargetValue: registryName,
237			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
238				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
239				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
240		return result, validation.NewError("containerregistry.RegistriesClient", "Delete", err.Error())
241	}
242
243	req, err := client.DeletePreparer(ctx, resourceGroupName, registryName)
244	if err != nil {
245		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request")
246		return
247	}
248
249	result, err = client.DeleteSender(req)
250	if err != nil {
251		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure sending request")
252		return
253	}
254
255	return
256}
257
258// DeletePreparer prepares the Delete request.
259func (client RegistriesClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
260	pathParameters := map[string]interface{}{
261		"registryName":      autorest.Encode("path", registryName),
262		"resourceGroupName": autorest.Encode("path", resourceGroupName),
263		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
264	}
265
266	const APIVersion = "2017-10-01"
267	queryParameters := map[string]interface{}{
268		"api-version": APIVersion,
269	}
270
271	preparer := autorest.CreatePreparer(
272		autorest.AsDelete(),
273		autorest.WithBaseURL(client.BaseURI),
274		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters),
275		autorest.WithQueryParameters(queryParameters))
276	return preparer.Prepare((&http.Request{}).WithContext(ctx))
277}
278
279// DeleteSender sends the Delete request. The method will close the
280// http.Response Body if it receives an error.
281func (client RegistriesClient) DeleteSender(req *http.Request) (future RegistriesDeleteFuture, err error) {
282	var resp *http.Response
283	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
284	if err != nil {
285		return
286	}
287	var azf azure.Future
288	azf, err = azure.NewFutureFromResponse(resp)
289	future.FutureAPI = &azf
290	future.Result = future.result
291	return
292}
293
294// DeleteResponder handles the response to the Delete request. The method always
295// closes the http.Response Body.
296func (client RegistriesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
297	err = autorest.Respond(
298		resp,
299		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
300		autorest.ByClosing())
301	result.Response = resp
302	return
303}
304
305// Get gets the properties of the specified container registry.
306// Parameters:
307// resourceGroupName - the name of the resource group to which the container registry belongs.
308// registryName - the name of the container registry.
309func (client RegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string) (result Registry, err error) {
310	if tracing.IsEnabled() {
311		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Get")
312		defer func() {
313			sc := -1
314			if result.Response.Response != nil {
315				sc = result.Response.Response.StatusCode
316			}
317			tracing.EndSpan(ctx, sc, err)
318		}()
319	}
320	if err := validation.Validate([]validation.Validation{
321		{TargetValue: resourceGroupName,
322			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
323		{TargetValue: registryName,
324			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
325				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
326				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
327		return result, validation.NewError("containerregistry.RegistriesClient", "Get", err.Error())
328	}
329
330	req, err := client.GetPreparer(ctx, resourceGroupName, registryName)
331	if err != nil {
332		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil, "Failure preparing request")
333		return
334	}
335
336	resp, err := client.GetSender(req)
337	if err != nil {
338		result.Response = autorest.Response{Response: resp}
339		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request")
340		return
341	}
342
343	result, err = client.GetResponder(resp)
344	if err != nil {
345		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request")
346		return
347	}
348
349	return
350}
351
352// GetPreparer prepares the Get request.
353func (client RegistriesClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
354	pathParameters := map[string]interface{}{
355		"registryName":      autorest.Encode("path", registryName),
356		"resourceGroupName": autorest.Encode("path", resourceGroupName),
357		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
358	}
359
360	const APIVersion = "2017-10-01"
361	queryParameters := map[string]interface{}{
362		"api-version": APIVersion,
363	}
364
365	preparer := autorest.CreatePreparer(
366		autorest.AsGet(),
367		autorest.WithBaseURL(client.BaseURI),
368		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters),
369		autorest.WithQueryParameters(queryParameters))
370	return preparer.Prepare((&http.Request{}).WithContext(ctx))
371}
372
373// GetSender sends the Get request. The method will close the
374// http.Response Body if it receives an error.
375func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) {
376	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
377}
378
379// GetResponder handles the response to the Get request. The method always
380// closes the http.Response Body.
381func (client RegistriesClient) GetResponder(resp *http.Response) (result Registry, err error) {
382	err = autorest.Respond(
383		resp,
384		azure.WithErrorUnlessStatusCode(http.StatusOK),
385		autorest.ByUnmarshallingJSON(&result),
386		autorest.ByClosing())
387	result.Response = autorest.Response{Response: resp}
388	return
389}
390
391// ImportImage copies an image to this container registry from the specified container registry.
392// Parameters:
393// resourceGroupName - the name of the resource group to which the container registry belongs.
394// registryName - the name of the container registry.
395// parameters - the parameters specifying the image to copy and the source container registry.
396func (client RegistriesClient) ImportImage(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters) (result RegistriesImportImageFuture, err error) {
397	if tracing.IsEnabled() {
398		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ImportImage")
399		defer func() {
400			sc := -1
401			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
402				sc = result.FutureAPI.Response().StatusCode
403			}
404			tracing.EndSpan(ctx, sc, err)
405		}()
406	}
407	if err := validation.Validate([]validation.Validation{
408		{TargetValue: resourceGroupName,
409			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
410		{TargetValue: registryName,
411			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
412				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
413				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
414		{TargetValue: parameters,
415			Constraints: []validation.Constraint{{Target: "parameters.Source", Name: validation.Null, Rule: true,
416				Chain: []validation.Constraint{{Target: "parameters.Source.Credentials", Name: validation.Null, Rule: false,
417					Chain: []validation.Constraint{{Target: "parameters.Source.Credentials.Password", Name: validation.Null, Rule: true, Chain: nil}}},
418					{Target: "parameters.Source.SourceImage", Name: validation.Null, Rule: true, Chain: nil},
419				}}}}}); err != nil {
420		return result, validation.NewError("containerregistry.RegistriesClient", "ImportImage", err.Error())
421	}
422
423	req, err := client.ImportImagePreparer(ctx, resourceGroupName, registryName, parameters)
424	if err != nil {
425		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ImportImage", nil, "Failure preparing request")
426		return
427	}
428
429	result, err = client.ImportImageSender(req)
430	if err != nil {
431		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ImportImage", nil, "Failure sending request")
432		return
433	}
434
435	return
436}
437
438// ImportImagePreparer prepares the ImportImage request.
439func (client RegistriesClient) ImportImagePreparer(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters) (*http.Request, error) {
440	pathParameters := map[string]interface{}{
441		"registryName":      autorest.Encode("path", registryName),
442		"resourceGroupName": autorest.Encode("path", resourceGroupName),
443		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
444	}
445
446	const APIVersion = "2017-10-01"
447	queryParameters := map[string]interface{}{
448		"api-version": APIVersion,
449	}
450
451	preparer := autorest.CreatePreparer(
452		autorest.AsContentType("application/json; charset=utf-8"),
453		autorest.AsPost(),
454		autorest.WithBaseURL(client.BaseURI),
455		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", pathParameters),
456		autorest.WithJSON(parameters),
457		autorest.WithQueryParameters(queryParameters))
458	return preparer.Prepare((&http.Request{}).WithContext(ctx))
459}
460
461// ImportImageSender sends the ImportImage request. The method will close the
462// http.Response Body if it receives an error.
463func (client RegistriesClient) ImportImageSender(req *http.Request) (future RegistriesImportImageFuture, err error) {
464	var resp *http.Response
465	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
466	if err != nil {
467		return
468	}
469	var azf azure.Future
470	azf, err = azure.NewFutureFromResponse(resp)
471	future.FutureAPI = &azf
472	future.Result = future.result
473	return
474}
475
476// ImportImageResponder handles the response to the ImportImage request. The method always
477// closes the http.Response Body.
478func (client RegistriesClient) ImportImageResponder(resp *http.Response) (result autorest.Response, err error) {
479	err = autorest.Respond(
480		resp,
481		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
482		autorest.ByClosing())
483	result.Response = resp
484	return
485}
486
487// List lists all the container registries under the specified subscription.
488func (client RegistriesClient) List(ctx context.Context) (result RegistryListResultPage, err error) {
489	if tracing.IsEnabled() {
490		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List")
491		defer func() {
492			sc := -1
493			if result.rlr.Response.Response != nil {
494				sc = result.rlr.Response.Response.StatusCode
495			}
496			tracing.EndSpan(ctx, sc, err)
497		}()
498	}
499	result.fn = client.listNextResults
500	req, err := client.ListPreparer(ctx)
501	if err != nil {
502		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request")
503		return
504	}
505
506	resp, err := client.ListSender(req)
507	if err != nil {
508		result.rlr.Response = autorest.Response{Response: resp}
509		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request")
510		return
511	}
512
513	result.rlr, err = client.ListResponder(resp)
514	if err != nil {
515		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request")
516		return
517	}
518	if result.rlr.hasNextLink() && result.rlr.IsEmpty() {
519		err = result.NextWithContext(ctx)
520		return
521	}
522
523	return
524}
525
526// ListPreparer prepares the List request.
527func (client RegistriesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
528	pathParameters := map[string]interface{}{
529		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
530	}
531
532	const APIVersion = "2017-10-01"
533	queryParameters := map[string]interface{}{
534		"api-version": APIVersion,
535	}
536
537	preparer := autorest.CreatePreparer(
538		autorest.AsGet(),
539		autorest.WithBaseURL(client.BaseURI),
540		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries", pathParameters),
541		autorest.WithQueryParameters(queryParameters))
542	return preparer.Prepare((&http.Request{}).WithContext(ctx))
543}
544
545// ListSender sends the List request. The method will close the
546// http.Response Body if it receives an error.
547func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) {
548	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
549}
550
551// ListResponder handles the response to the List request. The method always
552// closes the http.Response Body.
553func (client RegistriesClient) ListResponder(resp *http.Response) (result RegistryListResult, err error) {
554	err = autorest.Respond(
555		resp,
556		azure.WithErrorUnlessStatusCode(http.StatusOK),
557		autorest.ByUnmarshallingJSON(&result),
558		autorest.ByClosing())
559	result.Response = autorest.Response{Response: resp}
560	return
561}
562
563// listNextResults retrieves the next set of results, if any.
564func (client RegistriesClient) listNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) {
565	req, err := lastResults.registryListResultPreparer(ctx)
566	if err != nil {
567		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", nil, "Failure preparing next results request")
568	}
569	if req == nil {
570		return
571	}
572	resp, err := client.ListSender(req)
573	if err != nil {
574		result.Response = autorest.Response{Response: resp}
575		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure sending next results request")
576	}
577	result, err = client.ListResponder(resp)
578	if err != nil {
579		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure responding to next results request")
580	}
581	return
582}
583
584// ListComplete enumerates all values, automatically crossing page boundaries as required.
585func (client RegistriesClient) ListComplete(ctx context.Context) (result RegistryListResultIterator, err error) {
586	if tracing.IsEnabled() {
587		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List")
588		defer func() {
589			sc := -1
590			if result.Response().Response.Response != nil {
591				sc = result.page.Response().Response.Response.StatusCode
592			}
593			tracing.EndSpan(ctx, sc, err)
594		}()
595	}
596	result.page, err = client.List(ctx)
597	return
598}
599
600// ListByResourceGroup lists all the container registries under the specified resource group.
601// Parameters:
602// resourceGroupName - the name of the resource group to which the container registry belongs.
603func (client RegistriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result RegistryListResultPage, err error) {
604	if tracing.IsEnabled() {
605		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup")
606		defer func() {
607			sc := -1
608			if result.rlr.Response.Response != nil {
609				sc = result.rlr.Response.Response.StatusCode
610			}
611			tracing.EndSpan(ctx, sc, err)
612		}()
613	}
614	if err := validation.Validate([]validation.Validation{
615		{TargetValue: resourceGroupName,
616			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
617		return result, validation.NewError("containerregistry.RegistriesClient", "ListByResourceGroup", err.Error())
618	}
619
620	result.fn = client.listByResourceGroupNextResults
621	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
622	if err != nil {
623		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request")
624		return
625	}
626
627	resp, err := client.ListByResourceGroupSender(req)
628	if err != nil {
629		result.rlr.Response = autorest.Response{Response: resp}
630		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request")
631		return
632	}
633
634	result.rlr, err = client.ListByResourceGroupResponder(resp)
635	if err != nil {
636		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request")
637		return
638	}
639	if result.rlr.hasNextLink() && result.rlr.IsEmpty() {
640		err = result.NextWithContext(ctx)
641		return
642	}
643
644	return
645}
646
647// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
648func (client RegistriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
649	pathParameters := map[string]interface{}{
650		"resourceGroupName": autorest.Encode("path", resourceGroupName),
651		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
652	}
653
654	const APIVersion = "2017-10-01"
655	queryParameters := map[string]interface{}{
656		"api-version": APIVersion,
657	}
658
659	preparer := autorest.CreatePreparer(
660		autorest.AsGet(),
661		autorest.WithBaseURL(client.BaseURI),
662		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", pathParameters),
663		autorest.WithQueryParameters(queryParameters))
664	return preparer.Prepare((&http.Request{}).WithContext(ctx))
665}
666
667// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
668// http.Response Body if it receives an error.
669func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
670	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
671}
672
673// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
674// closes the http.Response Body.
675func (client RegistriesClient) ListByResourceGroupResponder(resp *http.Response) (result RegistryListResult, err error) {
676	err = autorest.Respond(
677		resp,
678		azure.WithErrorUnlessStatusCode(http.StatusOK),
679		autorest.ByUnmarshallingJSON(&result),
680		autorest.ByClosing())
681	result.Response = autorest.Response{Response: resp}
682	return
683}
684
685// listByResourceGroupNextResults retrieves the next set of results, if any.
686func (client RegistriesClient) listByResourceGroupNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) {
687	req, err := lastResults.registryListResultPreparer(ctx)
688	if err != nil {
689		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
690	}
691	if req == nil {
692		return
693	}
694	resp, err := client.ListByResourceGroupSender(req)
695	if err != nil {
696		result.Response = autorest.Response{Response: resp}
697		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
698	}
699	result, err = client.ListByResourceGroupResponder(resp)
700	if err != nil {
701		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
702	}
703	return
704}
705
706// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
707func (client RegistriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result RegistryListResultIterator, err error) {
708	if tracing.IsEnabled() {
709		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup")
710		defer func() {
711			sc := -1
712			if result.Response().Response.Response != nil {
713				sc = result.page.Response().Response.Response.StatusCode
714			}
715			tracing.EndSpan(ctx, sc, err)
716		}()
717	}
718	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
719	return
720}
721
722// ListCredentials lists the login credentials for the specified container registry.
723// Parameters:
724// resourceGroupName - the name of the resource group to which the container registry belongs.
725// registryName - the name of the container registry.
726func (client RegistriesClient) ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) {
727	if tracing.IsEnabled() {
728		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListCredentials")
729		defer func() {
730			sc := -1
731			if result.Response.Response != nil {
732				sc = result.Response.Response.StatusCode
733			}
734			tracing.EndSpan(ctx, sc, err)
735		}()
736	}
737	if err := validation.Validate([]validation.Validation{
738		{TargetValue: resourceGroupName,
739			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
740		{TargetValue: registryName,
741			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
742				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
743				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
744		return result, validation.NewError("containerregistry.RegistriesClient", "ListCredentials", err.Error())
745	}
746
747	req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, registryName)
748	if err != nil {
749		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request")
750		return
751	}
752
753	resp, err := client.ListCredentialsSender(req)
754	if err != nil {
755		result.Response = autorest.Response{Response: resp}
756		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request")
757		return
758	}
759
760	result, err = client.ListCredentialsResponder(resp)
761	if err != nil {
762		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request")
763		return
764	}
765
766	return
767}
768
769// ListCredentialsPreparer prepares the ListCredentials request.
770func (client RegistriesClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
771	pathParameters := map[string]interface{}{
772		"registryName":      autorest.Encode("path", registryName),
773		"resourceGroupName": autorest.Encode("path", resourceGroupName),
774		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
775	}
776
777	const APIVersion = "2017-10-01"
778	queryParameters := map[string]interface{}{
779		"api-version": APIVersion,
780	}
781
782	preparer := autorest.CreatePreparer(
783		autorest.AsPost(),
784		autorest.WithBaseURL(client.BaseURI),
785		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters),
786		autorest.WithQueryParameters(queryParameters))
787	return preparer.Prepare((&http.Request{}).WithContext(ctx))
788}
789
790// ListCredentialsSender sends the ListCredentials request. The method will close the
791// http.Response Body if it receives an error.
792func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) {
793	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
794}
795
796// ListCredentialsResponder handles the response to the ListCredentials request. The method always
797// closes the http.Response Body.
798func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) {
799	err = autorest.Respond(
800		resp,
801		azure.WithErrorUnlessStatusCode(http.StatusOK),
802		autorest.ByUnmarshallingJSON(&result),
803		autorest.ByClosing())
804	result.Response = autorest.Response{Response: resp}
805	return
806}
807
808// ListPolicies lists the policies for the specified container registry.
809// Parameters:
810// resourceGroupName - the name of the resource group to which the container registry belongs.
811// registryName - the name of the container registry.
812func (client RegistriesClient) ListPolicies(ctx context.Context, resourceGroupName string, registryName string) (result RegistryPolicies, err error) {
813	if tracing.IsEnabled() {
814		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListPolicies")
815		defer func() {
816			sc := -1
817			if result.Response.Response != nil {
818				sc = result.Response.Response.StatusCode
819			}
820			tracing.EndSpan(ctx, sc, err)
821		}()
822	}
823	if err := validation.Validate([]validation.Validation{
824		{TargetValue: resourceGroupName,
825			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
826		{TargetValue: registryName,
827			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
828				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
829				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
830		return result, validation.NewError("containerregistry.RegistriesClient", "ListPolicies", err.Error())
831	}
832
833	req, err := client.ListPoliciesPreparer(ctx, resourceGroupName, registryName)
834	if err != nil {
835		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListPolicies", nil, "Failure preparing request")
836		return
837	}
838
839	resp, err := client.ListPoliciesSender(req)
840	if err != nil {
841		result.Response = autorest.Response{Response: resp}
842		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListPolicies", resp, "Failure sending request")
843		return
844	}
845
846	result, err = client.ListPoliciesResponder(resp)
847	if err != nil {
848		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListPolicies", resp, "Failure responding to request")
849		return
850	}
851
852	return
853}
854
855// ListPoliciesPreparer prepares the ListPolicies request.
856func (client RegistriesClient) ListPoliciesPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
857	pathParameters := map[string]interface{}{
858		"registryName":      autorest.Encode("path", registryName),
859		"resourceGroupName": autorest.Encode("path", resourceGroupName),
860		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
861	}
862
863	const APIVersion = "2017-10-01"
864	queryParameters := map[string]interface{}{
865		"api-version": APIVersion,
866	}
867
868	preparer := autorest.CreatePreparer(
869		autorest.AsGet(),
870		autorest.WithBaseURL(client.BaseURI),
871		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies", pathParameters),
872		autorest.WithQueryParameters(queryParameters))
873	return preparer.Prepare((&http.Request{}).WithContext(ctx))
874}
875
876// ListPoliciesSender sends the ListPolicies request. The method will close the
877// http.Response Body if it receives an error.
878func (client RegistriesClient) ListPoliciesSender(req *http.Request) (*http.Response, error) {
879	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
880}
881
882// ListPoliciesResponder handles the response to the ListPolicies request. The method always
883// closes the http.Response Body.
884func (client RegistriesClient) ListPoliciesResponder(resp *http.Response) (result RegistryPolicies, err error) {
885	err = autorest.Respond(
886		resp,
887		azure.WithErrorUnlessStatusCode(http.StatusOK),
888		autorest.ByUnmarshallingJSON(&result),
889		autorest.ByClosing())
890	result.Response = autorest.Response{Response: resp}
891	return
892}
893
894// ListUsages gets the quota usages for the specified container registry.
895// Parameters:
896// resourceGroupName - the name of the resource group to which the container registry belongs.
897// registryName - the name of the container registry.
898func (client RegistriesClient) ListUsages(ctx context.Context, resourceGroupName string, registryName string) (result RegistryUsageListResult, err error) {
899	if tracing.IsEnabled() {
900		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListUsages")
901		defer func() {
902			sc := -1
903			if result.Response.Response != nil {
904				sc = result.Response.Response.StatusCode
905			}
906			tracing.EndSpan(ctx, sc, err)
907		}()
908	}
909	if err := validation.Validate([]validation.Validation{
910		{TargetValue: resourceGroupName,
911			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
912		{TargetValue: registryName,
913			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
914				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
915				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
916		return result, validation.NewError("containerregistry.RegistriesClient", "ListUsages", err.Error())
917	}
918
919	req, err := client.ListUsagesPreparer(ctx, resourceGroupName, registryName)
920	if err != nil {
921		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", nil, "Failure preparing request")
922		return
923	}
924
925	resp, err := client.ListUsagesSender(req)
926	if err != nil {
927		result.Response = autorest.Response{Response: resp}
928		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure sending request")
929		return
930	}
931
932	result, err = client.ListUsagesResponder(resp)
933	if err != nil {
934		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure responding to request")
935		return
936	}
937
938	return
939}
940
941// ListUsagesPreparer prepares the ListUsages request.
942func (client RegistriesClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
943	pathParameters := map[string]interface{}{
944		"registryName":      autorest.Encode("path", registryName),
945		"resourceGroupName": autorest.Encode("path", resourceGroupName),
946		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
947	}
948
949	const APIVersion = "2017-10-01"
950	queryParameters := map[string]interface{}{
951		"api-version": APIVersion,
952	}
953
954	preparer := autorest.CreatePreparer(
955		autorest.AsGet(),
956		autorest.WithBaseURL(client.BaseURI),
957		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", pathParameters),
958		autorest.WithQueryParameters(queryParameters))
959	return preparer.Prepare((&http.Request{}).WithContext(ctx))
960}
961
962// ListUsagesSender sends the ListUsages request. The method will close the
963// http.Response Body if it receives an error.
964func (client RegistriesClient) ListUsagesSender(req *http.Request) (*http.Response, error) {
965	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
966}
967
968// ListUsagesResponder handles the response to the ListUsages request. The method always
969// closes the http.Response Body.
970func (client RegistriesClient) ListUsagesResponder(resp *http.Response) (result RegistryUsageListResult, err error) {
971	err = autorest.Respond(
972		resp,
973		azure.WithErrorUnlessStatusCode(http.StatusOK),
974		autorest.ByUnmarshallingJSON(&result),
975		autorest.ByClosing())
976	result.Response = autorest.Response{Response: resp}
977	return
978}
979
980// RegenerateCredential regenerates one of the login credentials for the specified container registry.
981// Parameters:
982// resourceGroupName - the name of the resource group to which the container registry belongs.
983// registryName - the name of the container registry.
984// regenerateCredentialParameters - specifies name of the password which should be regenerated -- password or
985// password2.
986func (client RegistriesClient) RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) {
987	if tracing.IsEnabled() {
988		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.RegenerateCredential")
989		defer func() {
990			sc := -1
991			if result.Response.Response != nil {
992				sc = result.Response.Response.StatusCode
993			}
994			tracing.EndSpan(ctx, sc, err)
995		}()
996	}
997	if err := validation.Validate([]validation.Validation{
998		{TargetValue: resourceGroupName,
999			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1000		{TargetValue: registryName,
1001			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1002				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
1003				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1004		return result, validation.NewError("containerregistry.RegistriesClient", "RegenerateCredential", err.Error())
1005	}
1006
1007	req, err := client.RegenerateCredentialPreparer(ctx, resourceGroupName, registryName, regenerateCredentialParameters)
1008	if err != nil {
1009		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request")
1010		return
1011	}
1012
1013	resp, err := client.RegenerateCredentialSender(req)
1014	if err != nil {
1015		result.Response = autorest.Response{Response: resp}
1016		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request")
1017		return
1018	}
1019
1020	result, err = client.RegenerateCredentialResponder(resp)
1021	if err != nil {
1022		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request")
1023		return
1024	}
1025
1026	return
1027}
1028
1029// RegenerateCredentialPreparer prepares the RegenerateCredential request.
1030func (client RegistriesClient) RegenerateCredentialPreparer(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*http.Request, error) {
1031	pathParameters := map[string]interface{}{
1032		"registryName":      autorest.Encode("path", registryName),
1033		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1034		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1035	}
1036
1037	const APIVersion = "2017-10-01"
1038	queryParameters := map[string]interface{}{
1039		"api-version": APIVersion,
1040	}
1041
1042	preparer := autorest.CreatePreparer(
1043		autorest.AsContentType("application/json; charset=utf-8"),
1044		autorest.AsPost(),
1045		autorest.WithBaseURL(client.BaseURI),
1046		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", pathParameters),
1047		autorest.WithJSON(regenerateCredentialParameters),
1048		autorest.WithQueryParameters(queryParameters))
1049	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1050}
1051
1052// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the
1053// http.Response Body if it receives an error.
1054func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) {
1055	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1056}
1057
1058// RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always
1059// closes the http.Response Body.
1060func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) {
1061	err = autorest.Respond(
1062		resp,
1063		azure.WithErrorUnlessStatusCode(http.StatusOK),
1064		autorest.ByUnmarshallingJSON(&result),
1065		autorest.ByClosing())
1066	result.Response = autorest.Response{Response: resp}
1067	return
1068}
1069
1070// Update updates a container registry with the specified parameters.
1071// Parameters:
1072// resourceGroupName - the name of the resource group to which the container registry belongs.
1073// registryName - the name of the container registry.
1074// registryUpdateParameters - the parameters for updating a container registry.
1075func (client RegistriesClient) Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result RegistriesUpdateFuture, err error) {
1076	if tracing.IsEnabled() {
1077		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Update")
1078		defer func() {
1079			sc := -1
1080			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1081				sc = result.FutureAPI.Response().StatusCode
1082			}
1083			tracing.EndSpan(ctx, sc, err)
1084		}()
1085	}
1086	if err := validation.Validate([]validation.Validation{
1087		{TargetValue: resourceGroupName,
1088			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1089		{TargetValue: registryName,
1090			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1091				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
1092				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1093		return result, validation.NewError("containerregistry.RegistriesClient", "Update", err.Error())
1094	}
1095
1096	req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, registryUpdateParameters)
1097	if err != nil {
1098		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request")
1099		return
1100	}
1101
1102	result, err = client.UpdateSender(req)
1103	if err != nil {
1104		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure sending request")
1105		return
1106	}
1107
1108	return
1109}
1110
1111// UpdatePreparer prepares the Update request.
1112func (client RegistriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*http.Request, error) {
1113	pathParameters := map[string]interface{}{
1114		"registryName":      autorest.Encode("path", registryName),
1115		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1116		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1117	}
1118
1119	const APIVersion = "2017-10-01"
1120	queryParameters := map[string]interface{}{
1121		"api-version": APIVersion,
1122	}
1123
1124	preparer := autorest.CreatePreparer(
1125		autorest.AsContentType("application/json; charset=utf-8"),
1126		autorest.AsPatch(),
1127		autorest.WithBaseURL(client.BaseURI),
1128		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters),
1129		autorest.WithJSON(registryUpdateParameters),
1130		autorest.WithQueryParameters(queryParameters))
1131	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1132}
1133
1134// UpdateSender sends the Update request. The method will close the
1135// http.Response Body if it receives an error.
1136func (client RegistriesClient) UpdateSender(req *http.Request) (future RegistriesUpdateFuture, err error) {
1137	var resp *http.Response
1138	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1139	if err != nil {
1140		return
1141	}
1142	var azf azure.Future
1143	azf, err = azure.NewFutureFromResponse(resp)
1144	future.FutureAPI = &azf
1145	future.Result = future.result
1146	return
1147}
1148
1149// UpdateResponder handles the response to the Update request. The method always
1150// closes the http.Response Body.
1151func (client RegistriesClient) UpdateResponder(resp *http.Response) (result Registry, err error) {
1152	err = autorest.Respond(
1153		resp,
1154		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
1155		autorest.ByUnmarshallingJSON(&result),
1156		autorest.ByClosing())
1157	result.Response = autorest.Response{Response: resp}
1158	return
1159}
1160
1161// UpdatePolicies updates the policies for the specified container registry.
1162// Parameters:
1163// resourceGroupName - the name of the resource group to which the container registry belongs.
1164// registryName - the name of the container registry.
1165// registryPoliciesUpdateParameters - the parameters for updating policies of a container registry.
1166func (client RegistriesClient) UpdatePolicies(ctx context.Context, resourceGroupName string, registryName string, registryPoliciesUpdateParameters RegistryPolicies) (result RegistriesUpdatePoliciesFuture, err error) {
1167	if tracing.IsEnabled() {
1168		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.UpdatePolicies")
1169		defer func() {
1170			sc := -1
1171			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1172				sc = result.FutureAPI.Response().StatusCode
1173			}
1174			tracing.EndSpan(ctx, sc, err)
1175		}()
1176	}
1177	if err := validation.Validate([]validation.Validation{
1178		{TargetValue: resourceGroupName,
1179			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1180		{TargetValue: registryName,
1181			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1182				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
1183				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1184		return result, validation.NewError("containerregistry.RegistriesClient", "UpdatePolicies", err.Error())
1185	}
1186
1187	req, err := client.UpdatePoliciesPreparer(ctx, resourceGroupName, registryName, registryPoliciesUpdateParameters)
1188	if err != nil {
1189		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "UpdatePolicies", nil, "Failure preparing request")
1190		return
1191	}
1192
1193	result, err = client.UpdatePoliciesSender(req)
1194	if err != nil {
1195		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "UpdatePolicies", nil, "Failure sending request")
1196		return
1197	}
1198
1199	return
1200}
1201
1202// UpdatePoliciesPreparer prepares the UpdatePolicies request.
1203func (client RegistriesClient) UpdatePoliciesPreparer(ctx context.Context, resourceGroupName string, registryName string, registryPoliciesUpdateParameters RegistryPolicies) (*http.Request, error) {
1204	pathParameters := map[string]interface{}{
1205		"registryName":      autorest.Encode("path", registryName),
1206		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1207		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1208	}
1209
1210	const APIVersion = "2017-10-01"
1211	queryParameters := map[string]interface{}{
1212		"api-version": APIVersion,
1213	}
1214
1215	preparer := autorest.CreatePreparer(
1216		autorest.AsContentType("application/json; charset=utf-8"),
1217		autorest.AsPost(),
1218		autorest.WithBaseURL(client.BaseURI),
1219		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies", pathParameters),
1220		autorest.WithJSON(registryPoliciesUpdateParameters),
1221		autorest.WithQueryParameters(queryParameters))
1222	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1223}
1224
1225// UpdatePoliciesSender sends the UpdatePolicies request. The method will close the
1226// http.Response Body if it receives an error.
1227func (client RegistriesClient) UpdatePoliciesSender(req *http.Request) (future RegistriesUpdatePoliciesFuture, err error) {
1228	var resp *http.Response
1229	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1230	if err != nil {
1231		return
1232	}
1233	var azf azure.Future
1234	azf, err = azure.NewFutureFromResponse(resp)
1235	future.FutureAPI = &azf
1236	future.Result = future.result
1237	return
1238}
1239
1240// UpdatePoliciesResponder handles the response to the UpdatePolicies request. The method always
1241// closes the http.Response Body.
1242func (client RegistriesClient) UpdatePoliciesResponder(resp *http.Response) (result RegistryPolicies, err error) {
1243	err = autorest.Respond(
1244		resp,
1245		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1246		autorest.ByUnmarshallingJSON(&result),
1247		autorest.ByClosing())
1248	result.Response = autorest.Response{Response: resp}
1249	return
1250}
1251