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