1package containerregistry 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// RegistriesClient is the client for the Registries methods of the Containerregistry service. 30type RegistriesClient struct { 31 BaseClient 32} 33 34// NewRegistriesClient creates an instance of the RegistriesClient client. 35func NewRegistriesClient(subscriptionID string) RegistriesClient { 36 return NewRegistriesClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewRegistriesClientWithBaseURI creates an instance of the RegistriesClient client. 40func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) RegistriesClient { 41 return RegistriesClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// CheckNameAvailability checks whether the container registry name is available for use. The name must contain only 45// alphanumeric characters, be globally unique, and between 5 and 50 characters in length. 46// Parameters: 47// registryNameCheckRequest - the object containing information for the availability request. 48func (client RegistriesClient) CheckNameAvailability(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) { 49 if tracing.IsEnabled() { 50 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.CheckNameAvailability") 51 defer func() { 52 sc := -1 53 if result.Response.Response != nil { 54 sc = result.Response.Response.StatusCode 55 } 56 tracing.EndSpan(ctx, sc, err) 57 }() 58 } 59 if err := validation.Validate([]validation.Validation{ 60 {TargetValue: registryNameCheckRequest, 61 Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, 62 Chain: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil}, 63 {Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil}, 64 {Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}, 65 }}, 66 {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 67 return result, validation.NewError("containerregistry.RegistriesClient", "CheckNameAvailability", err.Error()) 68 } 69 70 req, err := client.CheckNameAvailabilityPreparer(ctx, registryNameCheckRequest) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") 73 return 74 } 75 76 resp, err := client.CheckNameAvailabilitySender(req) 77 if err != nil { 78 result.Response = autorest.Response{Response: resp} 79 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") 80 return 81 } 82 83 result, err = client.CheckNameAvailabilityResponder(resp) 84 if err != nil { 85 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure responding to request") 86 } 87 88 return 89} 90 91// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. 92func (client RegistriesClient) CheckNameAvailabilityPreparer(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (*http.Request, error) { 93 pathParameters := map[string]interface{}{ 94 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 95 } 96 97 const APIVersion = "2017-03-01" 98 queryParameters := map[string]interface{}{ 99 "api-version": APIVersion, 100 } 101 102 preparer := autorest.CreatePreparer( 103 autorest.AsContentType("application/json; charset=utf-8"), 104 autorest.AsPost(), 105 autorest.WithBaseURL(client.BaseURI), 106 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability", pathParameters), 107 autorest.WithJSON(registryNameCheckRequest), 108 autorest.WithQueryParameters(queryParameters)) 109 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 110} 111 112// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 113// http.Response Body if it receives an error. 114func (client RegistriesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 115 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 116 return autorest.SendWithSender(client, req, sd...) 117} 118 119// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 120// closes the http.Response Body. 121func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Response) (result RegistryNameStatus, err error) { 122 err = autorest.Respond( 123 resp, 124 client.ByInspecting(), 125 azure.WithErrorUnlessStatusCode(http.StatusOK), 126 autorest.ByUnmarshallingJSON(&result), 127 autorest.ByClosing()) 128 result.Response = autorest.Response{Response: resp} 129 return 130} 131 132// Create creates a container registry with the specified parameters. 133// Parameters: 134// resourceGroupName - the name of the resource group to which the container registry belongs. 135// registryName - the name of the container registry. 136// registryCreateParameters - the parameters for creating a container registry. 137func (client RegistriesClient) Create(ctx context.Context, resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters) (result RegistriesCreateFuture, err error) { 138 if tracing.IsEnabled() { 139 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Create") 140 defer func() { 141 sc := -1 142 if result.Response() != nil { 143 sc = result.Response().StatusCode 144 } 145 tracing.EndSpan(ctx, sc, err) 146 }() 147 } 148 if err := validation.Validate([]validation.Validation{ 149 {TargetValue: resourceGroupName, 150 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 151 {TargetValue: registryName, 152 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 153 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 154 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 155 {TargetValue: registryCreateParameters, 156 Constraints: []validation.Constraint{{Target: "registryCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, 157 {Target: "registryCreateParameters.Sku", Name: validation.Null, Rule: true, 158 Chain: []validation.Constraint{{Target: "registryCreateParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, 159 {Target: "registryCreateParameters.RegistryPropertiesCreateParameters", Name: validation.Null, Rule: false, 160 Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount", Name: validation.Null, Rule: true, 161 Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, 162 {Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, 163 }}, 164 }}}}}); err != nil { 165 return result, validation.NewError("containerregistry.RegistriesClient", "Create", err.Error()) 166 } 167 168 req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, registryCreateParameters) 169 if err != nil { 170 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure preparing request") 171 return 172 } 173 174 result, err = client.CreateSender(req) 175 if err != nil { 176 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", result.Response(), "Failure sending request") 177 return 178 } 179 180 return 181} 182 183// CreatePreparer prepares the Create request. 184func (client RegistriesClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters) (*http.Request, error) { 185 pathParameters := map[string]interface{}{ 186 "registryName": autorest.Encode("path", registryName), 187 "resourceGroupName": autorest.Encode("path", resourceGroupName), 188 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 189 } 190 191 const APIVersion = "2017-03-01" 192 queryParameters := map[string]interface{}{ 193 "api-version": APIVersion, 194 } 195 196 preparer := autorest.CreatePreparer( 197 autorest.AsContentType("application/json; charset=utf-8"), 198 autorest.AsPut(), 199 autorest.WithBaseURL(client.BaseURI), 200 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 201 autorest.WithJSON(registryCreateParameters), 202 autorest.WithQueryParameters(queryParameters)) 203 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 204} 205 206// CreateSender sends the Create request. The method will close the 207// http.Response Body if it receives an error. 208func (client RegistriesClient) CreateSender(req *http.Request) (future RegistriesCreateFuture, err error) { 209 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 210 var resp *http.Response 211 resp, err = autorest.SendWithSender(client, req, sd...) 212 if err != nil { 213 return 214 } 215 future.Future, err = azure.NewFutureFromResponse(resp) 216 return 217} 218 219// CreateResponder handles the response to the Create request. The method always 220// closes the http.Response Body. 221func (client RegistriesClient) CreateResponder(resp *http.Response) (result Registry, err error) { 222 err = autorest.Respond( 223 resp, 224 client.ByInspecting(), 225 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 226 autorest.ByUnmarshallingJSON(&result), 227 autorest.ByClosing()) 228 result.Response = autorest.Response{Response: resp} 229 return 230} 231 232// Delete deletes a container registry. 233// Parameters: 234// resourceGroupName - the name of the resource group to which the container registry belongs. 235// registryName - the name of the container registry. 236func (client RegistriesClient) Delete(ctx context.Context, resourceGroupName string, registryName string) (result autorest.Response, err error) { 237 if tracing.IsEnabled() { 238 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Delete") 239 defer func() { 240 sc := -1 241 if result.Response != nil { 242 sc = result.Response.StatusCode 243 } 244 tracing.EndSpan(ctx, sc, err) 245 }() 246 } 247 if err := validation.Validate([]validation.Validation{ 248 {TargetValue: resourceGroupName, 249 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 250 {TargetValue: registryName, 251 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 252 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 253 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 254 return result, validation.NewError("containerregistry.RegistriesClient", "Delete", err.Error()) 255 } 256 257 req, err := client.DeletePreparer(ctx, resourceGroupName, registryName) 258 if err != nil { 259 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") 260 return 261 } 262 263 resp, err := client.DeleteSender(req) 264 if err != nil { 265 result.Response = resp 266 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") 267 return 268 } 269 270 result, err = client.DeleteResponder(resp) 271 if err != nil { 272 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure responding to request") 273 } 274 275 return 276} 277 278// DeletePreparer prepares the Delete request. 279func (client RegistriesClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 280 pathParameters := map[string]interface{}{ 281 "registryName": autorest.Encode("path", registryName), 282 "resourceGroupName": autorest.Encode("path", resourceGroupName), 283 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 284 } 285 286 const APIVersion = "2017-03-01" 287 queryParameters := map[string]interface{}{ 288 "api-version": APIVersion, 289 } 290 291 preparer := autorest.CreatePreparer( 292 autorest.AsDelete(), 293 autorest.WithBaseURL(client.BaseURI), 294 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 295 autorest.WithQueryParameters(queryParameters)) 296 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 297} 298 299// DeleteSender sends the Delete request. The method will close the 300// http.Response Body if it receives an error. 301func (client RegistriesClient) DeleteSender(req *http.Request) (*http.Response, error) { 302 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 303 return autorest.SendWithSender(client, req, sd...) 304} 305 306// DeleteResponder handles the response to the Delete request. The method always 307// closes the http.Response Body. 308func (client RegistriesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 309 err = autorest.Respond( 310 resp, 311 client.ByInspecting(), 312 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 313 autorest.ByClosing()) 314 result.Response = resp 315 return 316} 317 318// Get gets the properties of the specified container registry. 319// Parameters: 320// resourceGroupName - the name of the resource group to which the container registry belongs. 321// registryName - the name of the container registry. 322func (client RegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string) (result Registry, err error) { 323 if tracing.IsEnabled() { 324 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Get") 325 defer func() { 326 sc := -1 327 if result.Response.Response != nil { 328 sc = result.Response.Response.StatusCode 329 } 330 tracing.EndSpan(ctx, sc, err) 331 }() 332 } 333 if err := validation.Validate([]validation.Validation{ 334 {TargetValue: resourceGroupName, 335 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 336 {TargetValue: registryName, 337 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 338 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 339 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 340 return result, validation.NewError("containerregistry.RegistriesClient", "Get", err.Error()) 341 } 342 343 req, err := client.GetPreparer(ctx, resourceGroupName, registryName) 344 if err != nil { 345 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil, "Failure preparing request") 346 return 347 } 348 349 resp, err := client.GetSender(req) 350 if err != nil { 351 result.Response = autorest.Response{Response: resp} 352 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request") 353 return 354 } 355 356 result, err = client.GetResponder(resp) 357 if err != nil { 358 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request") 359 } 360 361 return 362} 363 364// GetPreparer prepares the Get request. 365func (client RegistriesClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 366 pathParameters := map[string]interface{}{ 367 "registryName": autorest.Encode("path", registryName), 368 "resourceGroupName": autorest.Encode("path", resourceGroupName), 369 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 370 } 371 372 const APIVersion = "2017-03-01" 373 queryParameters := map[string]interface{}{ 374 "api-version": APIVersion, 375 } 376 377 preparer := autorest.CreatePreparer( 378 autorest.AsGet(), 379 autorest.WithBaseURL(client.BaseURI), 380 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 381 autorest.WithQueryParameters(queryParameters)) 382 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 383} 384 385// GetSender sends the Get request. The method will close the 386// http.Response Body if it receives an error. 387func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) { 388 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 389 return autorest.SendWithSender(client, req, sd...) 390} 391 392// GetResponder handles the response to the Get request. The method always 393// closes the http.Response Body. 394func (client RegistriesClient) GetResponder(resp *http.Response) (result Registry, err error) { 395 err = autorest.Respond( 396 resp, 397 client.ByInspecting(), 398 azure.WithErrorUnlessStatusCode(http.StatusOK), 399 autorest.ByUnmarshallingJSON(&result), 400 autorest.ByClosing()) 401 result.Response = autorest.Response{Response: resp} 402 return 403} 404 405// List lists all the container registries under the specified subscription. 406func (client RegistriesClient) List(ctx context.Context) (result RegistryListResultPage, err error) { 407 if tracing.IsEnabled() { 408 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List") 409 defer func() { 410 sc := -1 411 if result.rlr.Response.Response != nil { 412 sc = result.rlr.Response.Response.StatusCode 413 } 414 tracing.EndSpan(ctx, sc, err) 415 }() 416 } 417 result.fn = client.listNextResults 418 req, err := client.ListPreparer(ctx) 419 if err != nil { 420 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") 421 return 422 } 423 424 resp, err := client.ListSender(req) 425 if err != nil { 426 result.rlr.Response = autorest.Response{Response: resp} 427 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") 428 return 429 } 430 431 result.rlr, err = client.ListResponder(resp) 432 if err != nil { 433 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request") 434 } 435 436 return 437} 438 439// ListPreparer prepares the List request. 440func (client RegistriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { 441 pathParameters := map[string]interface{}{ 442 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 443 } 444 445 const APIVersion = "2017-03-01" 446 queryParameters := map[string]interface{}{ 447 "api-version": APIVersion, 448 } 449 450 preparer := autorest.CreatePreparer( 451 autorest.AsGet(), 452 autorest.WithBaseURL(client.BaseURI), 453 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries", pathParameters), 454 autorest.WithQueryParameters(queryParameters)) 455 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 456} 457 458// ListSender sends the List request. The method will close the 459// http.Response Body if it receives an error. 460func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) { 461 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 462 return autorest.SendWithSender(client, req, sd...) 463} 464 465// ListResponder handles the response to the List request. The method always 466// closes the http.Response Body. 467func (client RegistriesClient) ListResponder(resp *http.Response) (result RegistryListResult, err error) { 468 err = autorest.Respond( 469 resp, 470 client.ByInspecting(), 471 azure.WithErrorUnlessStatusCode(http.StatusOK), 472 autorest.ByUnmarshallingJSON(&result), 473 autorest.ByClosing()) 474 result.Response = autorest.Response{Response: resp} 475 return 476} 477 478// listNextResults retrieves the next set of results, if any. 479func (client RegistriesClient) listNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { 480 req, err := lastResults.registryListResultPreparer(ctx) 481 if err != nil { 482 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", nil, "Failure preparing next results request") 483 } 484 if req == nil { 485 return 486 } 487 resp, err := client.ListSender(req) 488 if err != nil { 489 result.Response = autorest.Response{Response: resp} 490 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure sending next results request") 491 } 492 result, err = client.ListResponder(resp) 493 if err != nil { 494 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure responding to next results request") 495 } 496 return 497} 498 499// ListComplete enumerates all values, automatically crossing page boundaries as required. 500func (client RegistriesClient) ListComplete(ctx context.Context) (result RegistryListResultIterator, err error) { 501 if tracing.IsEnabled() { 502 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List") 503 defer func() { 504 sc := -1 505 if result.Response().Response.Response != nil { 506 sc = result.page.Response().Response.Response.StatusCode 507 } 508 tracing.EndSpan(ctx, sc, err) 509 }() 510 } 511 result.page, err = client.List(ctx) 512 return 513} 514 515// ListByResourceGroup lists all the container registries under the specified resource group. 516// Parameters: 517// resourceGroupName - the name of the resource group to which the container registry belongs. 518func (client RegistriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result RegistryListResultPage, err error) { 519 if tracing.IsEnabled() { 520 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup") 521 defer func() { 522 sc := -1 523 if result.rlr.Response.Response != nil { 524 sc = result.rlr.Response.Response.StatusCode 525 } 526 tracing.EndSpan(ctx, sc, err) 527 }() 528 } 529 if err := validation.Validate([]validation.Validation{ 530 {TargetValue: resourceGroupName, 531 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 532 return result, validation.NewError("containerregistry.RegistriesClient", "ListByResourceGroup", err.Error()) 533 } 534 535 result.fn = client.listByResourceGroupNextResults 536 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 537 if err != nil { 538 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") 539 return 540 } 541 542 resp, err := client.ListByResourceGroupSender(req) 543 if err != nil { 544 result.rlr.Response = autorest.Response{Response: resp} 545 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") 546 return 547 } 548 549 result.rlr, err = client.ListByResourceGroupResponder(resp) 550 if err != nil { 551 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request") 552 } 553 554 return 555} 556 557// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 558func (client RegistriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 559 pathParameters := map[string]interface{}{ 560 "resourceGroupName": autorest.Encode("path", resourceGroupName), 561 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 562 } 563 564 const APIVersion = "2017-03-01" 565 queryParameters := map[string]interface{}{ 566 "api-version": APIVersion, 567 } 568 569 preparer := autorest.CreatePreparer( 570 autorest.AsGet(), 571 autorest.WithBaseURL(client.BaseURI), 572 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", pathParameters), 573 autorest.WithQueryParameters(queryParameters)) 574 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 575} 576 577// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 578// http.Response Body if it receives an error. 579func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 580 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 581 return autorest.SendWithSender(client, req, sd...) 582} 583 584// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 585// closes the http.Response Body. 586func (client RegistriesClient) ListByResourceGroupResponder(resp *http.Response) (result RegistryListResult, err error) { 587 err = autorest.Respond( 588 resp, 589 client.ByInspecting(), 590 azure.WithErrorUnlessStatusCode(http.StatusOK), 591 autorest.ByUnmarshallingJSON(&result), 592 autorest.ByClosing()) 593 result.Response = autorest.Response{Response: resp} 594 return 595} 596 597// listByResourceGroupNextResults retrieves the next set of results, if any. 598func (client RegistriesClient) listByResourceGroupNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { 599 req, err := lastResults.registryListResultPreparer(ctx) 600 if err != nil { 601 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 602 } 603 if req == nil { 604 return 605 } 606 resp, err := client.ListByResourceGroupSender(req) 607 if err != nil { 608 result.Response = autorest.Response{Response: resp} 609 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 610 } 611 result, err = client.ListByResourceGroupResponder(resp) 612 if err != nil { 613 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 614 } 615 return 616} 617 618// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 619func (client RegistriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result RegistryListResultIterator, err error) { 620 if tracing.IsEnabled() { 621 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup") 622 defer func() { 623 sc := -1 624 if result.Response().Response.Response != nil { 625 sc = result.page.Response().Response.Response.StatusCode 626 } 627 tracing.EndSpan(ctx, sc, err) 628 }() 629 } 630 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 631 return 632} 633 634// ListCredentials lists the login credentials for the specified container registry. 635// Parameters: 636// resourceGroupName - the name of the resource group to which the container registry belongs. 637// registryName - the name of the container registry. 638func (client RegistriesClient) ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) { 639 if tracing.IsEnabled() { 640 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListCredentials") 641 defer func() { 642 sc := -1 643 if result.Response.Response != nil { 644 sc = result.Response.Response.StatusCode 645 } 646 tracing.EndSpan(ctx, sc, err) 647 }() 648 } 649 if err := validation.Validate([]validation.Validation{ 650 {TargetValue: resourceGroupName, 651 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 652 {TargetValue: registryName, 653 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 654 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 655 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 656 return result, validation.NewError("containerregistry.RegistriesClient", "ListCredentials", err.Error()) 657 } 658 659 req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, registryName) 660 if err != nil { 661 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request") 662 return 663 } 664 665 resp, err := client.ListCredentialsSender(req) 666 if err != nil { 667 result.Response = autorest.Response{Response: resp} 668 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request") 669 return 670 } 671 672 result, err = client.ListCredentialsResponder(resp) 673 if err != nil { 674 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request") 675 } 676 677 return 678} 679 680// ListCredentialsPreparer prepares the ListCredentials request. 681func (client RegistriesClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 682 pathParameters := map[string]interface{}{ 683 "registryName": autorest.Encode("path", registryName), 684 "resourceGroupName": autorest.Encode("path", resourceGroupName), 685 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 686 } 687 688 const APIVersion = "2017-03-01" 689 queryParameters := map[string]interface{}{ 690 "api-version": APIVersion, 691 } 692 693 preparer := autorest.CreatePreparer( 694 autorest.AsPost(), 695 autorest.WithBaseURL(client.BaseURI), 696 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters), 697 autorest.WithQueryParameters(queryParameters)) 698 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 699} 700 701// ListCredentialsSender sends the ListCredentials request. The method will close the 702// http.Response Body if it receives an error. 703func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { 704 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 705 return autorest.SendWithSender(client, req, sd...) 706} 707 708// ListCredentialsResponder handles the response to the ListCredentials request. The method always 709// closes the http.Response Body. 710func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { 711 err = autorest.Respond( 712 resp, 713 client.ByInspecting(), 714 azure.WithErrorUnlessStatusCode(http.StatusOK), 715 autorest.ByUnmarshallingJSON(&result), 716 autorest.ByClosing()) 717 result.Response = autorest.Response{Response: resp} 718 return 719} 720 721// RegenerateCredential regenerates one of the login credentials for the specified container registry. 722// Parameters: 723// resourceGroupName - the name of the resource group to which the container registry belongs. 724// registryName - the name of the container registry. 725// regenerateCredentialParameters - specifies name of the password which should be regenerated -- password or 726// password2. 727func (client RegistriesClient) RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) { 728 if tracing.IsEnabled() { 729 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.RegenerateCredential") 730 defer func() { 731 sc := -1 732 if result.Response.Response != nil { 733 sc = result.Response.Response.StatusCode 734 } 735 tracing.EndSpan(ctx, sc, err) 736 }() 737 } 738 if err := validation.Validate([]validation.Validation{ 739 {TargetValue: resourceGroupName, 740 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 741 {TargetValue: registryName, 742 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 743 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 744 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 745 return result, validation.NewError("containerregistry.RegistriesClient", "RegenerateCredential", err.Error()) 746 } 747 748 req, err := client.RegenerateCredentialPreparer(ctx, resourceGroupName, registryName, regenerateCredentialParameters) 749 if err != nil { 750 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request") 751 return 752 } 753 754 resp, err := client.RegenerateCredentialSender(req) 755 if err != nil { 756 result.Response = autorest.Response{Response: resp} 757 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request") 758 return 759 } 760 761 result, err = client.RegenerateCredentialResponder(resp) 762 if err != nil { 763 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request") 764 } 765 766 return 767} 768 769// RegenerateCredentialPreparer prepares the RegenerateCredential request. 770func (client RegistriesClient) RegenerateCredentialPreparer(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*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-03-01" 778 queryParameters := map[string]interface{}{ 779 "api-version": APIVersion, 780 } 781 782 preparer := autorest.CreatePreparer( 783 autorest.AsContentType("application/json; charset=utf-8"), 784 autorest.AsPost(), 785 autorest.WithBaseURL(client.BaseURI), 786 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", pathParameters), 787 autorest.WithJSON(regenerateCredentialParameters), 788 autorest.WithQueryParameters(queryParameters)) 789 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 790} 791 792// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the 793// http.Response Body if it receives an error. 794func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) { 795 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 796 return autorest.SendWithSender(client, req, sd...) 797} 798 799// RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always 800// closes the http.Response Body. 801func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { 802 err = autorest.Respond( 803 resp, 804 client.ByInspecting(), 805 azure.WithErrorUnlessStatusCode(http.StatusOK), 806 autorest.ByUnmarshallingJSON(&result), 807 autorest.ByClosing()) 808 result.Response = autorest.Response{Response: resp} 809 return 810} 811 812// Update updates a container registry with the specified parameters. 813// Parameters: 814// resourceGroupName - the name of the resource group to which the container registry belongs. 815// registryName - the name of the container registry. 816// registryUpdateParameters - the parameters for updating a container registry. 817func (client RegistriesClient) Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result Registry, err error) { 818 if tracing.IsEnabled() { 819 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Update") 820 defer func() { 821 sc := -1 822 if result.Response.Response != nil { 823 sc = result.Response.Response.StatusCode 824 } 825 tracing.EndSpan(ctx, sc, err) 826 }() 827 } 828 if err := validation.Validate([]validation.Validation{ 829 {TargetValue: resourceGroupName, 830 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 831 {TargetValue: registryName, 832 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 833 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 834 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 835 return result, validation.NewError("containerregistry.RegistriesClient", "Update", err.Error()) 836 } 837 838 req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, registryUpdateParameters) 839 if err != nil { 840 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") 841 return 842 } 843 844 resp, err := client.UpdateSender(req) 845 if err != nil { 846 result.Response = autorest.Response{Response: resp} 847 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") 848 return 849 } 850 851 result, err = client.UpdateResponder(resp) 852 if err != nil { 853 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure responding to request") 854 } 855 856 return 857} 858 859// UpdatePreparer prepares the Update request. 860func (client RegistriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*http.Request, error) { 861 pathParameters := map[string]interface{}{ 862 "registryName": autorest.Encode("path", registryName), 863 "resourceGroupName": autorest.Encode("path", resourceGroupName), 864 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 865 } 866 867 const APIVersion = "2017-03-01" 868 queryParameters := map[string]interface{}{ 869 "api-version": APIVersion, 870 } 871 872 preparer := autorest.CreatePreparer( 873 autorest.AsContentType("application/json; charset=utf-8"), 874 autorest.AsPatch(), 875 autorest.WithBaseURL(client.BaseURI), 876 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 877 autorest.WithJSON(registryUpdateParameters), 878 autorest.WithQueryParameters(queryParameters)) 879 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 880} 881 882// UpdateSender sends the Update request. The method will close the 883// http.Response Body if it receives an error. 884func (client RegistriesClient) UpdateSender(req *http.Request) (*http.Response, error) { 885 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 886 return autorest.SendWithSender(client, req, sd...) 887} 888 889// UpdateResponder handles the response to the Update request. The method always 890// closes the http.Response Body. 891func (client RegistriesClient) UpdateResponder(resp *http.Response) (result Registry, err error) { 892 err = autorest.Respond( 893 resp, 894 client.ByInspecting(), 895 azure.WithErrorUnlessStatusCode(http.StatusOK), 896 autorest.ByUnmarshallingJSON(&result), 897 autorest.ByClosing()) 898 result.Response = autorest.Response{Response: resp} 899 return 900} 901