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