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// GetBuildSourceUploadURL get the upload location for the user to be able to upload the source.
392// Parameters:
393// resourceGroupName - the name of the resource group to which the container registry belongs.
394// registryName - the name of the container registry.
395func (client RegistriesClient) GetBuildSourceUploadURL(ctx context.Context, resourceGroupName string, registryName string) (result SourceUploadDefinition, err error) {
396	if tracing.IsEnabled() {
397		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.GetBuildSourceUploadURL")
398		defer func() {
399			sc := -1
400			if result.Response.Response != nil {
401				sc = result.Response.Response.StatusCode
402			}
403			tracing.EndSpan(ctx, sc, err)
404		}()
405	}
406	if err := validation.Validate([]validation.Validation{
407		{TargetValue: registryName,
408			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
409				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
410				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
411		return result, validation.NewError("containerregistry.RegistriesClient", "GetBuildSourceUploadURL", err.Error())
412	}
413
414	req, err := client.GetBuildSourceUploadURLPreparer(ctx, resourceGroupName, registryName)
415	if err != nil {
416		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetBuildSourceUploadURL", nil, "Failure preparing request")
417		return
418	}
419
420	resp, err := client.GetBuildSourceUploadURLSender(req)
421	if err != nil {
422		result.Response = autorest.Response{Response: resp}
423		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetBuildSourceUploadURL", resp, "Failure sending request")
424		return
425	}
426
427	result, err = client.GetBuildSourceUploadURLResponder(resp)
428	if err != nil {
429		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetBuildSourceUploadURL", resp, "Failure responding to request")
430		return
431	}
432
433	return
434}
435
436// GetBuildSourceUploadURLPreparer prepares the GetBuildSourceUploadURL request.
437func (client RegistriesClient) GetBuildSourceUploadURLPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
438	pathParameters := map[string]interface{}{
439		"registryName":      autorest.Encode("path", registryName),
440		"resourceGroupName": autorest.Encode("path", resourceGroupName),
441		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
442	}
443
444	const APIVersion = "2018-02-01-preview"
445	queryParameters := map[string]interface{}{
446		"api-version": APIVersion,
447	}
448
449	preparer := autorest.CreatePreparer(
450		autorest.AsPost(),
451		autorest.WithBaseURL(client.BaseURI),
452		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getBuildSourceUploadUrl", pathParameters),
453		autorest.WithQueryParameters(queryParameters))
454	return preparer.Prepare((&http.Request{}).WithContext(ctx))
455}
456
457// GetBuildSourceUploadURLSender sends the GetBuildSourceUploadURL request. The method will close the
458// http.Response Body if it receives an error.
459func (client RegistriesClient) GetBuildSourceUploadURLSender(req *http.Request) (*http.Response, error) {
460	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
461}
462
463// GetBuildSourceUploadURLResponder handles the response to the GetBuildSourceUploadURL request. The method always
464// closes the http.Response Body.
465func (client RegistriesClient) GetBuildSourceUploadURLResponder(resp *http.Response) (result SourceUploadDefinition, err error) {
466	err = autorest.Respond(
467		resp,
468		azure.WithErrorUnlessStatusCode(http.StatusOK),
469		autorest.ByUnmarshallingJSON(&result),
470		autorest.ByClosing())
471	result.Response = autorest.Response{Response: resp}
472	return
473}
474
475// ImportImage copies an image to this container registry from the specified container registry.
476// Parameters:
477// resourceGroupName - the name of the resource group to which the container registry belongs.
478// registryName - the name of the container registry.
479// parameters - the parameters specifying the image to copy and the source container registry.
480func (client RegistriesClient) ImportImage(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters) (result RegistriesImportImageFuture, err error) {
481	if tracing.IsEnabled() {
482		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ImportImage")
483		defer func() {
484			sc := -1
485			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
486				sc = result.FutureAPI.Response().StatusCode
487			}
488			tracing.EndSpan(ctx, sc, err)
489		}()
490	}
491	if err := validation.Validate([]validation.Validation{
492		{TargetValue: resourceGroupName,
493			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
494		{TargetValue: registryName,
495			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
496				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
497				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
498		{TargetValue: parameters,
499			Constraints: []validation.Constraint{{Target: "parameters.Source", Name: validation.Null, Rule: true,
500				Chain: []validation.Constraint{{Target: "parameters.Source.Credentials", Name: validation.Null, Rule: false,
501					Chain: []validation.Constraint{{Target: "parameters.Source.Credentials.Password", Name: validation.Null, Rule: true, Chain: nil}}},
502					{Target: "parameters.Source.SourceImage", Name: validation.Null, Rule: true, Chain: nil},
503				}}}}}); err != nil {
504		return result, validation.NewError("containerregistry.RegistriesClient", "ImportImage", err.Error())
505	}
506
507	req, err := client.ImportImagePreparer(ctx, resourceGroupName, registryName, parameters)
508	if err != nil {
509		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ImportImage", nil, "Failure preparing request")
510		return
511	}
512
513	result, err = client.ImportImageSender(req)
514	if err != nil {
515		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ImportImage", nil, "Failure sending request")
516		return
517	}
518
519	return
520}
521
522// ImportImagePreparer prepares the ImportImage request.
523func (client RegistriesClient) ImportImagePreparer(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters) (*http.Request, error) {
524	pathParameters := map[string]interface{}{
525		"registryName":      autorest.Encode("path", registryName),
526		"resourceGroupName": autorest.Encode("path", resourceGroupName),
527		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
528	}
529
530	const APIVersion = "2017-10-01"
531	queryParameters := map[string]interface{}{
532		"api-version": APIVersion,
533	}
534
535	preparer := autorest.CreatePreparer(
536		autorest.AsContentType("application/json; charset=utf-8"),
537		autorest.AsPost(),
538		autorest.WithBaseURL(client.BaseURI),
539		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", pathParameters),
540		autorest.WithJSON(parameters),
541		autorest.WithQueryParameters(queryParameters))
542	return preparer.Prepare((&http.Request{}).WithContext(ctx))
543}
544
545// ImportImageSender sends the ImportImage request. The method will close the
546// http.Response Body if it receives an error.
547func (client RegistriesClient) ImportImageSender(req *http.Request) (future RegistriesImportImageFuture, err error) {
548	var resp *http.Response
549	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
550	if err != nil {
551		return
552	}
553	var azf azure.Future
554	azf, err = azure.NewFutureFromResponse(resp)
555	future.FutureAPI = &azf
556	future.Result = future.result
557	return
558}
559
560// ImportImageResponder handles the response to the ImportImage request. The method always
561// closes the http.Response Body.
562func (client RegistriesClient) ImportImageResponder(resp *http.Response) (result autorest.Response, err error) {
563	err = autorest.Respond(
564		resp,
565		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
566		autorest.ByClosing())
567	result.Response = resp
568	return
569}
570
571// List lists all the container registries under the specified subscription.
572func (client RegistriesClient) List(ctx context.Context) (result RegistryListResultPage, err error) {
573	if tracing.IsEnabled() {
574		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List")
575		defer func() {
576			sc := -1
577			if result.rlr.Response.Response != nil {
578				sc = result.rlr.Response.Response.StatusCode
579			}
580			tracing.EndSpan(ctx, sc, err)
581		}()
582	}
583	result.fn = client.listNextResults
584	req, err := client.ListPreparer(ctx)
585	if err != nil {
586		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request")
587		return
588	}
589
590	resp, err := client.ListSender(req)
591	if err != nil {
592		result.rlr.Response = autorest.Response{Response: resp}
593		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request")
594		return
595	}
596
597	result.rlr, err = client.ListResponder(resp)
598	if err != nil {
599		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request")
600		return
601	}
602	if result.rlr.hasNextLink() && result.rlr.IsEmpty() {
603		err = result.NextWithContext(ctx)
604		return
605	}
606
607	return
608}
609
610// ListPreparer prepares the List request.
611func (client RegistriesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
612	pathParameters := map[string]interface{}{
613		"subscriptionId": autorest.Encode("path", client.SubscriptionID),
614	}
615
616	const APIVersion = "2017-10-01"
617	queryParameters := map[string]interface{}{
618		"api-version": APIVersion,
619	}
620
621	preparer := autorest.CreatePreparer(
622		autorest.AsGet(),
623		autorest.WithBaseURL(client.BaseURI),
624		autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries", pathParameters),
625		autorest.WithQueryParameters(queryParameters))
626	return preparer.Prepare((&http.Request{}).WithContext(ctx))
627}
628
629// ListSender sends the List request. The method will close the
630// http.Response Body if it receives an error.
631func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) {
632	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
633}
634
635// ListResponder handles the response to the List request. The method always
636// closes the http.Response Body.
637func (client RegistriesClient) ListResponder(resp *http.Response) (result RegistryListResult, err error) {
638	err = autorest.Respond(
639		resp,
640		azure.WithErrorUnlessStatusCode(http.StatusOK),
641		autorest.ByUnmarshallingJSON(&result),
642		autorest.ByClosing())
643	result.Response = autorest.Response{Response: resp}
644	return
645}
646
647// listNextResults retrieves the next set of results, if any.
648func (client RegistriesClient) listNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) {
649	req, err := lastResults.registryListResultPreparer(ctx)
650	if err != nil {
651		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", nil, "Failure preparing next results request")
652	}
653	if req == nil {
654		return
655	}
656	resp, err := client.ListSender(req)
657	if err != nil {
658		result.Response = autorest.Response{Response: resp}
659		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure sending next results request")
660	}
661	result, err = client.ListResponder(resp)
662	if err != nil {
663		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure responding to next results request")
664	}
665	return
666}
667
668// ListComplete enumerates all values, automatically crossing page boundaries as required.
669func (client RegistriesClient) ListComplete(ctx context.Context) (result RegistryListResultIterator, err error) {
670	if tracing.IsEnabled() {
671		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List")
672		defer func() {
673			sc := -1
674			if result.Response().Response.Response != nil {
675				sc = result.page.Response().Response.Response.StatusCode
676			}
677			tracing.EndSpan(ctx, sc, err)
678		}()
679	}
680	result.page, err = client.List(ctx)
681	return
682}
683
684// ListByResourceGroup lists all the container registries under the specified resource group.
685// Parameters:
686// resourceGroupName - the name of the resource group to which the container registry belongs.
687func (client RegistriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result RegistryListResultPage, err error) {
688	if tracing.IsEnabled() {
689		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup")
690		defer func() {
691			sc := -1
692			if result.rlr.Response.Response != nil {
693				sc = result.rlr.Response.Response.StatusCode
694			}
695			tracing.EndSpan(ctx, sc, err)
696		}()
697	}
698	if err := validation.Validate([]validation.Validation{
699		{TargetValue: resourceGroupName,
700			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
701		return result, validation.NewError("containerregistry.RegistriesClient", "ListByResourceGroup", err.Error())
702	}
703
704	result.fn = client.listByResourceGroupNextResults
705	req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
706	if err != nil {
707		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request")
708		return
709	}
710
711	resp, err := client.ListByResourceGroupSender(req)
712	if err != nil {
713		result.rlr.Response = autorest.Response{Response: resp}
714		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request")
715		return
716	}
717
718	result.rlr, err = client.ListByResourceGroupResponder(resp)
719	if err != nil {
720		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request")
721		return
722	}
723	if result.rlr.hasNextLink() && result.rlr.IsEmpty() {
724		err = result.NextWithContext(ctx)
725		return
726	}
727
728	return
729}
730
731// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
732func (client RegistriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) {
733	pathParameters := map[string]interface{}{
734		"resourceGroupName": autorest.Encode("path", resourceGroupName),
735		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
736	}
737
738	const APIVersion = "2017-10-01"
739	queryParameters := map[string]interface{}{
740		"api-version": APIVersion,
741	}
742
743	preparer := autorest.CreatePreparer(
744		autorest.AsGet(),
745		autorest.WithBaseURL(client.BaseURI),
746		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", pathParameters),
747		autorest.WithQueryParameters(queryParameters))
748	return preparer.Prepare((&http.Request{}).WithContext(ctx))
749}
750
751// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
752// http.Response Body if it receives an error.
753func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
754	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
755}
756
757// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
758// closes the http.Response Body.
759func (client RegistriesClient) ListByResourceGroupResponder(resp *http.Response) (result RegistryListResult, err error) {
760	err = autorest.Respond(
761		resp,
762		azure.WithErrorUnlessStatusCode(http.StatusOK),
763		autorest.ByUnmarshallingJSON(&result),
764		autorest.ByClosing())
765	result.Response = autorest.Response{Response: resp}
766	return
767}
768
769// listByResourceGroupNextResults retrieves the next set of results, if any.
770func (client RegistriesClient) listByResourceGroupNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) {
771	req, err := lastResults.registryListResultPreparer(ctx)
772	if err != nil {
773		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
774	}
775	if req == nil {
776		return
777	}
778	resp, err := client.ListByResourceGroupSender(req)
779	if err != nil {
780		result.Response = autorest.Response{Response: resp}
781		return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
782	}
783	result, err = client.ListByResourceGroupResponder(resp)
784	if err != nil {
785		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
786	}
787	return
788}
789
790// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
791func (client RegistriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result RegistryListResultIterator, err error) {
792	if tracing.IsEnabled() {
793		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup")
794		defer func() {
795			sc := -1
796			if result.Response().Response.Response != nil {
797				sc = result.page.Response().Response.Response.StatusCode
798			}
799			tracing.EndSpan(ctx, sc, err)
800		}()
801	}
802	result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
803	return
804}
805
806// ListCredentials lists the login credentials for the specified container registry.
807// Parameters:
808// resourceGroupName - the name of the resource group to which the container registry belongs.
809// registryName - the name of the container registry.
810func (client RegistriesClient) ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) {
811	if tracing.IsEnabled() {
812		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListCredentials")
813		defer func() {
814			sc := -1
815			if result.Response.Response != nil {
816				sc = result.Response.Response.StatusCode
817			}
818			tracing.EndSpan(ctx, sc, err)
819		}()
820	}
821	if err := validation.Validate([]validation.Validation{
822		{TargetValue: resourceGroupName,
823			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
824		{TargetValue: registryName,
825			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
826				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
827				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
828		return result, validation.NewError("containerregistry.RegistriesClient", "ListCredentials", err.Error())
829	}
830
831	req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, registryName)
832	if err != nil {
833		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request")
834		return
835	}
836
837	resp, err := client.ListCredentialsSender(req)
838	if err != nil {
839		result.Response = autorest.Response{Response: resp}
840		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request")
841		return
842	}
843
844	result, err = client.ListCredentialsResponder(resp)
845	if err != nil {
846		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request")
847		return
848	}
849
850	return
851}
852
853// ListCredentialsPreparer prepares the ListCredentials request.
854func (client RegistriesClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
855	pathParameters := map[string]interface{}{
856		"registryName":      autorest.Encode("path", registryName),
857		"resourceGroupName": autorest.Encode("path", resourceGroupName),
858		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
859	}
860
861	const APIVersion = "2017-10-01"
862	queryParameters := map[string]interface{}{
863		"api-version": APIVersion,
864	}
865
866	preparer := autorest.CreatePreparer(
867		autorest.AsPost(),
868		autorest.WithBaseURL(client.BaseURI),
869		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters),
870		autorest.WithQueryParameters(queryParameters))
871	return preparer.Prepare((&http.Request{}).WithContext(ctx))
872}
873
874// ListCredentialsSender sends the ListCredentials request. The method will close the
875// http.Response Body if it receives an error.
876func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) {
877	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
878}
879
880// ListCredentialsResponder handles the response to the ListCredentials request. The method always
881// closes the http.Response Body.
882func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) {
883	err = autorest.Respond(
884		resp,
885		azure.WithErrorUnlessStatusCode(http.StatusOK),
886		autorest.ByUnmarshallingJSON(&result),
887		autorest.ByClosing())
888	result.Response = autorest.Response{Response: resp}
889	return
890}
891
892// ListPolicies lists the policies for the specified container registry.
893// Parameters:
894// resourceGroupName - the name of the resource group to which the container registry belongs.
895// registryName - the name of the container registry.
896func (client RegistriesClient) ListPolicies(ctx context.Context, resourceGroupName string, registryName string) (result RegistryPolicies, err error) {
897	if tracing.IsEnabled() {
898		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListPolicies")
899		defer func() {
900			sc := -1
901			if result.Response.Response != nil {
902				sc = result.Response.Response.StatusCode
903			}
904			tracing.EndSpan(ctx, sc, err)
905		}()
906	}
907	if err := validation.Validate([]validation.Validation{
908		{TargetValue: resourceGroupName,
909			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
910		{TargetValue: registryName,
911			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
912				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
913				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
914		return result, validation.NewError("containerregistry.RegistriesClient", "ListPolicies", err.Error())
915	}
916
917	req, err := client.ListPoliciesPreparer(ctx, resourceGroupName, registryName)
918	if err != nil {
919		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListPolicies", nil, "Failure preparing request")
920		return
921	}
922
923	resp, err := client.ListPoliciesSender(req)
924	if err != nil {
925		result.Response = autorest.Response{Response: resp}
926		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListPolicies", resp, "Failure sending request")
927		return
928	}
929
930	result, err = client.ListPoliciesResponder(resp)
931	if err != nil {
932		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListPolicies", resp, "Failure responding to request")
933		return
934	}
935
936	return
937}
938
939// ListPoliciesPreparer prepares the ListPolicies request.
940func (client RegistriesClient) ListPoliciesPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
941	pathParameters := map[string]interface{}{
942		"registryName":      autorest.Encode("path", registryName),
943		"resourceGroupName": autorest.Encode("path", resourceGroupName),
944		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
945	}
946
947	const APIVersion = "2017-10-01"
948	queryParameters := map[string]interface{}{
949		"api-version": APIVersion,
950	}
951
952	preparer := autorest.CreatePreparer(
953		autorest.AsGet(),
954		autorest.WithBaseURL(client.BaseURI),
955		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listPolicies", pathParameters),
956		autorest.WithQueryParameters(queryParameters))
957	return preparer.Prepare((&http.Request{}).WithContext(ctx))
958}
959
960// ListPoliciesSender sends the ListPolicies request. The method will close the
961// http.Response Body if it receives an error.
962func (client RegistriesClient) ListPoliciesSender(req *http.Request) (*http.Response, error) {
963	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
964}
965
966// ListPoliciesResponder handles the response to the ListPolicies request. The method always
967// closes the http.Response Body.
968func (client RegistriesClient) ListPoliciesResponder(resp *http.Response) (result RegistryPolicies, err error) {
969	err = autorest.Respond(
970		resp,
971		azure.WithErrorUnlessStatusCode(http.StatusOK),
972		autorest.ByUnmarshallingJSON(&result),
973		autorest.ByClosing())
974	result.Response = autorest.Response{Response: resp}
975	return
976}
977
978// ListUsages gets the quota usages for the specified container registry.
979// Parameters:
980// resourceGroupName - the name of the resource group to which the container registry belongs.
981// registryName - the name of the container registry.
982func (client RegistriesClient) ListUsages(ctx context.Context, resourceGroupName string, registryName string) (result RegistryUsageListResult, err error) {
983	if tracing.IsEnabled() {
984		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListUsages")
985		defer func() {
986			sc := -1
987			if result.Response.Response != nil {
988				sc = result.Response.Response.StatusCode
989			}
990			tracing.EndSpan(ctx, sc, err)
991		}()
992	}
993	if err := validation.Validate([]validation.Validation{
994		{TargetValue: resourceGroupName,
995			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
996		{TargetValue: registryName,
997			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
998				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
999				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1000		return result, validation.NewError("containerregistry.RegistriesClient", "ListUsages", err.Error())
1001	}
1002
1003	req, err := client.ListUsagesPreparer(ctx, resourceGroupName, registryName)
1004	if err != nil {
1005		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", nil, "Failure preparing request")
1006		return
1007	}
1008
1009	resp, err := client.ListUsagesSender(req)
1010	if err != nil {
1011		result.Response = autorest.Response{Response: resp}
1012		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure sending request")
1013		return
1014	}
1015
1016	result, err = client.ListUsagesResponder(resp)
1017	if err != nil {
1018		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure responding to request")
1019		return
1020	}
1021
1022	return
1023}
1024
1025// ListUsagesPreparer prepares the ListUsages request.
1026func (client RegistriesClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) {
1027	pathParameters := map[string]interface{}{
1028		"registryName":      autorest.Encode("path", registryName),
1029		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1030		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1031	}
1032
1033	const APIVersion = "2017-10-01"
1034	queryParameters := map[string]interface{}{
1035		"api-version": APIVersion,
1036	}
1037
1038	preparer := autorest.CreatePreparer(
1039		autorest.AsGet(),
1040		autorest.WithBaseURL(client.BaseURI),
1041		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", pathParameters),
1042		autorest.WithQueryParameters(queryParameters))
1043	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1044}
1045
1046// ListUsagesSender sends the ListUsages request. The method will close the
1047// http.Response Body if it receives an error.
1048func (client RegistriesClient) ListUsagesSender(req *http.Request) (*http.Response, error) {
1049	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1050}
1051
1052// ListUsagesResponder handles the response to the ListUsages request. The method always
1053// closes the http.Response Body.
1054func (client RegistriesClient) ListUsagesResponder(resp *http.Response) (result RegistryUsageListResult, err error) {
1055	err = autorest.Respond(
1056		resp,
1057		azure.WithErrorUnlessStatusCode(http.StatusOK),
1058		autorest.ByUnmarshallingJSON(&result),
1059		autorest.ByClosing())
1060	result.Response = autorest.Response{Response: resp}
1061	return
1062}
1063
1064// QueueBuild creates a new build based on the request parameters and add it to the build queue.
1065// Parameters:
1066// resourceGroupName - the name of the resource group to which the container registry belongs.
1067// registryName - the name of the container registry.
1068// buildRequest - the parameters of a build that needs to queued.
1069func (client RegistriesClient) QueueBuild(ctx context.Context, resourceGroupName string, registryName string, buildRequest BasicQueueBuildRequest) (result RegistriesQueueBuildFuture, err error) {
1070	if tracing.IsEnabled() {
1071		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.QueueBuild")
1072		defer func() {
1073			sc := -1
1074			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1075				sc = result.FutureAPI.Response().StatusCode
1076			}
1077			tracing.EndSpan(ctx, sc, err)
1078		}()
1079	}
1080	if err := validation.Validate([]validation.Validation{
1081		{TargetValue: registryName,
1082			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1083				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
1084				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1085		return result, validation.NewError("containerregistry.RegistriesClient", "QueueBuild", err.Error())
1086	}
1087
1088	req, err := client.QueueBuildPreparer(ctx, resourceGroupName, registryName, buildRequest)
1089	if err != nil {
1090		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "QueueBuild", nil, "Failure preparing request")
1091		return
1092	}
1093
1094	result, err = client.QueueBuildSender(req)
1095	if err != nil {
1096		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "QueueBuild", nil, "Failure sending request")
1097		return
1098	}
1099
1100	return
1101}
1102
1103// QueueBuildPreparer prepares the QueueBuild request.
1104func (client RegistriesClient) QueueBuildPreparer(ctx context.Context, resourceGroupName string, registryName string, buildRequest BasicQueueBuildRequest) (*http.Request, error) {
1105	pathParameters := map[string]interface{}{
1106		"registryName":      autorest.Encode("path", registryName),
1107		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1108		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1109	}
1110
1111	const APIVersion = "2018-02-01-preview"
1112	queryParameters := map[string]interface{}{
1113		"api-version": APIVersion,
1114	}
1115
1116	preparer := autorest.CreatePreparer(
1117		autorest.AsContentType("application/json; charset=utf-8"),
1118		autorest.AsPost(),
1119		autorest.WithBaseURL(client.BaseURI),
1120		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/queueBuild", pathParameters),
1121		autorest.WithJSON(buildRequest),
1122		autorest.WithQueryParameters(queryParameters))
1123	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1124}
1125
1126// QueueBuildSender sends the QueueBuild request. The method will close the
1127// http.Response Body if it receives an error.
1128func (client RegistriesClient) QueueBuildSender(req *http.Request) (future RegistriesQueueBuildFuture, err error) {
1129	var resp *http.Response
1130	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1131	if err != nil {
1132		return
1133	}
1134	var azf azure.Future
1135	azf, err = azure.NewFutureFromResponse(resp)
1136	future.FutureAPI = &azf
1137	future.Result = future.result
1138	return
1139}
1140
1141// QueueBuildResponder handles the response to the QueueBuild request. The method always
1142// closes the http.Response Body.
1143func (client RegistriesClient) QueueBuildResponder(resp *http.Response) (result Build, err error) {
1144	err = autorest.Respond(
1145		resp,
1146		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1147		autorest.ByUnmarshallingJSON(&result),
1148		autorest.ByClosing())
1149	result.Response = autorest.Response{Response: resp}
1150	return
1151}
1152
1153// RegenerateCredential regenerates one of the login credentials for the specified container registry.
1154// Parameters:
1155// resourceGroupName - the name of the resource group to which the container registry belongs.
1156// registryName - the name of the container registry.
1157// regenerateCredentialParameters - specifies name of the password which should be regenerated -- password or
1158// password2.
1159func (client RegistriesClient) RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) {
1160	if tracing.IsEnabled() {
1161		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.RegenerateCredential")
1162		defer func() {
1163			sc := -1
1164			if result.Response.Response != nil {
1165				sc = result.Response.Response.StatusCode
1166			}
1167			tracing.EndSpan(ctx, sc, err)
1168		}()
1169	}
1170	if err := validation.Validate([]validation.Validation{
1171		{TargetValue: resourceGroupName,
1172			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1173		{TargetValue: registryName,
1174			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1175				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
1176				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1177		return result, validation.NewError("containerregistry.RegistriesClient", "RegenerateCredential", err.Error())
1178	}
1179
1180	req, err := client.RegenerateCredentialPreparer(ctx, resourceGroupName, registryName, regenerateCredentialParameters)
1181	if err != nil {
1182		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request")
1183		return
1184	}
1185
1186	resp, err := client.RegenerateCredentialSender(req)
1187	if err != nil {
1188		result.Response = autorest.Response{Response: resp}
1189		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request")
1190		return
1191	}
1192
1193	result, err = client.RegenerateCredentialResponder(resp)
1194	if err != nil {
1195		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request")
1196		return
1197	}
1198
1199	return
1200}
1201
1202// RegenerateCredentialPreparer prepares the RegenerateCredential request.
1203func (client RegistriesClient) RegenerateCredentialPreparer(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*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}/regenerateCredential", pathParameters),
1220		autorest.WithJSON(regenerateCredentialParameters),
1221		autorest.WithQueryParameters(queryParameters))
1222	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1223}
1224
1225// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the
1226// http.Response Body if it receives an error.
1227func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) {
1228	return client.Send(req, azure.DoRetryWithRegistration(client.Client))
1229}
1230
1231// RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always
1232// closes the http.Response Body.
1233func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) {
1234	err = autorest.Respond(
1235		resp,
1236		azure.WithErrorUnlessStatusCode(http.StatusOK),
1237		autorest.ByUnmarshallingJSON(&result),
1238		autorest.ByClosing())
1239	result.Response = autorest.Response{Response: resp}
1240	return
1241}
1242
1243// Update updates a container registry with the specified parameters.
1244// Parameters:
1245// resourceGroupName - the name of the resource group to which the container registry belongs.
1246// registryName - the name of the container registry.
1247// registryUpdateParameters - the parameters for updating a container registry.
1248func (client RegistriesClient) Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result RegistriesUpdateFuture, err error) {
1249	if tracing.IsEnabled() {
1250		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Update")
1251		defer func() {
1252			sc := -1
1253			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1254				sc = result.FutureAPI.Response().StatusCode
1255			}
1256			tracing.EndSpan(ctx, sc, err)
1257		}()
1258	}
1259	if err := validation.Validate([]validation.Validation{
1260		{TargetValue: resourceGroupName,
1261			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1262		{TargetValue: registryName,
1263			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1264				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
1265				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1266		return result, validation.NewError("containerregistry.RegistriesClient", "Update", err.Error())
1267	}
1268
1269	req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, registryUpdateParameters)
1270	if err != nil {
1271		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request")
1272		return
1273	}
1274
1275	result, err = client.UpdateSender(req)
1276	if err != nil {
1277		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure sending request")
1278		return
1279	}
1280
1281	return
1282}
1283
1284// UpdatePreparer prepares the Update request.
1285func (client RegistriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*http.Request, error) {
1286	pathParameters := map[string]interface{}{
1287		"registryName":      autorest.Encode("path", registryName),
1288		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1289		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1290	}
1291
1292	const APIVersion = "2017-10-01"
1293	queryParameters := map[string]interface{}{
1294		"api-version": APIVersion,
1295	}
1296
1297	preparer := autorest.CreatePreparer(
1298		autorest.AsContentType("application/json; charset=utf-8"),
1299		autorest.AsPatch(),
1300		autorest.WithBaseURL(client.BaseURI),
1301		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters),
1302		autorest.WithJSON(registryUpdateParameters),
1303		autorest.WithQueryParameters(queryParameters))
1304	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1305}
1306
1307// UpdateSender sends the Update request. The method will close the
1308// http.Response Body if it receives an error.
1309func (client RegistriesClient) UpdateSender(req *http.Request) (future RegistriesUpdateFuture, err error) {
1310	var resp *http.Response
1311	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1312	if err != nil {
1313		return
1314	}
1315	var azf azure.Future
1316	azf, err = azure.NewFutureFromResponse(resp)
1317	future.FutureAPI = &azf
1318	future.Result = future.result
1319	return
1320}
1321
1322// UpdateResponder handles the response to the Update request. The method always
1323// closes the http.Response Body.
1324func (client RegistriesClient) UpdateResponder(resp *http.Response) (result Registry, err error) {
1325	err = autorest.Respond(
1326		resp,
1327		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
1328		autorest.ByUnmarshallingJSON(&result),
1329		autorest.ByClosing())
1330	result.Response = autorest.Response{Response: resp}
1331	return
1332}
1333
1334// UpdatePolicies updates the policies for the specified container registry.
1335// Parameters:
1336// resourceGroupName - the name of the resource group to which the container registry belongs.
1337// registryName - the name of the container registry.
1338// registryPoliciesUpdateParameters - the parameters for updating policies of a container registry.
1339func (client RegistriesClient) UpdatePolicies(ctx context.Context, resourceGroupName string, registryName string, registryPoliciesUpdateParameters RegistryPolicies) (result RegistriesUpdatePoliciesFuture, err error) {
1340	if tracing.IsEnabled() {
1341		ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.UpdatePolicies")
1342		defer func() {
1343			sc := -1
1344			if result.FutureAPI != nil && result.FutureAPI.Response() != nil {
1345				sc = result.FutureAPI.Response().StatusCode
1346			}
1347			tracing.EndSpan(ctx, sc, err)
1348		}()
1349	}
1350	if err := validation.Validate([]validation.Validation{
1351		{TargetValue: resourceGroupName,
1352			Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
1353		{TargetValue: registryName,
1354			Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
1355				{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
1356				{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
1357		return result, validation.NewError("containerregistry.RegistriesClient", "UpdatePolicies", err.Error())
1358	}
1359
1360	req, err := client.UpdatePoliciesPreparer(ctx, resourceGroupName, registryName, registryPoliciesUpdateParameters)
1361	if err != nil {
1362		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "UpdatePolicies", nil, "Failure preparing request")
1363		return
1364	}
1365
1366	result, err = client.UpdatePoliciesSender(req)
1367	if err != nil {
1368		err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "UpdatePolicies", nil, "Failure sending request")
1369		return
1370	}
1371
1372	return
1373}
1374
1375// UpdatePoliciesPreparer prepares the UpdatePolicies request.
1376func (client RegistriesClient) UpdatePoliciesPreparer(ctx context.Context, resourceGroupName string, registryName string, registryPoliciesUpdateParameters RegistryPolicies) (*http.Request, error) {
1377	pathParameters := map[string]interface{}{
1378		"registryName":      autorest.Encode("path", registryName),
1379		"resourceGroupName": autorest.Encode("path", resourceGroupName),
1380		"subscriptionId":    autorest.Encode("path", client.SubscriptionID),
1381	}
1382
1383	const APIVersion = "2017-10-01"
1384	queryParameters := map[string]interface{}{
1385		"api-version": APIVersion,
1386	}
1387
1388	preparer := autorest.CreatePreparer(
1389		autorest.AsContentType("application/json; charset=utf-8"),
1390		autorest.AsPost(),
1391		autorest.WithBaseURL(client.BaseURI),
1392		autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/updatePolicies", pathParameters),
1393		autorest.WithJSON(registryPoliciesUpdateParameters),
1394		autorest.WithQueryParameters(queryParameters))
1395	return preparer.Prepare((&http.Request{}).WithContext(ctx))
1396}
1397
1398// UpdatePoliciesSender sends the UpdatePolicies request. The method will close the
1399// http.Response Body if it receives an error.
1400func (client RegistriesClient) UpdatePoliciesSender(req *http.Request) (future RegistriesUpdatePoliciesFuture, err error) {
1401	var resp *http.Response
1402	resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client))
1403	if err != nil {
1404		return
1405	}
1406	var azf azure.Future
1407	azf, err = azure.NewFutureFromResponse(resp)
1408	future.FutureAPI = &azf
1409	future.Result = future.result
1410	return
1411}
1412
1413// UpdatePoliciesResponder handles the response to the UpdatePolicies request. The method always
1414// closes the http.Response Body.
1415func (client RegistriesClient) UpdatePoliciesResponder(resp *http.Response) (result RegistryPolicies, err error) {
1416	err = autorest.Respond(
1417		resp,
1418		azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
1419		autorest.ByUnmarshallingJSON(&result),
1420		autorest.ByClosing())
1421	result.Response = autorest.Response{Response: resp}
1422	return
1423}
1424