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 = "2019-05-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 = "2019-05-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 = "2019-05-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 = "2019-05-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// GetBuildSourceUploadURL get the upload location for the user to be able to upload the source. 402// Parameters: 403// resourceGroupName - the name of the resource group to which the container registry belongs. 404// registryName - the name of the container registry. 405func (client RegistriesClient) GetBuildSourceUploadURL(ctx context.Context, resourceGroupName string, registryName string) (result SourceUploadDefinition, err error) { 406 if tracing.IsEnabled() { 407 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.GetBuildSourceUploadURL") 408 defer func() { 409 sc := -1 410 if result.Response.Response != nil { 411 sc = result.Response.Response.StatusCode 412 } 413 tracing.EndSpan(ctx, sc, err) 414 }() 415 } 416 if err := validation.Validate([]validation.Validation{ 417 {TargetValue: resourceGroupName, 418 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 419 {TargetValue: registryName, 420 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 421 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 422 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 423 return result, validation.NewError("containerregistry.RegistriesClient", "GetBuildSourceUploadURL", err.Error()) 424 } 425 426 req, err := client.GetBuildSourceUploadURLPreparer(ctx, resourceGroupName, registryName) 427 if err != nil { 428 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetBuildSourceUploadURL", nil, "Failure preparing request") 429 return 430 } 431 432 resp, err := client.GetBuildSourceUploadURLSender(req) 433 if err != nil { 434 result.Response = autorest.Response{Response: resp} 435 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetBuildSourceUploadURL", resp, "Failure sending request") 436 return 437 } 438 439 result, err = client.GetBuildSourceUploadURLResponder(resp) 440 if err != nil { 441 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetBuildSourceUploadURL", resp, "Failure responding to request") 442 } 443 444 return 445} 446 447// GetBuildSourceUploadURLPreparer prepares the GetBuildSourceUploadURL request. 448func (client RegistriesClient) GetBuildSourceUploadURLPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 449 pathParameters := map[string]interface{}{ 450 "registryName": autorest.Encode("path", registryName), 451 "resourceGroupName": autorest.Encode("path", resourceGroupName), 452 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 453 } 454 455 const APIVersion = "2019-04-01" 456 queryParameters := map[string]interface{}{ 457 "api-version": APIVersion, 458 } 459 460 preparer := autorest.CreatePreparer( 461 autorest.AsPost(), 462 autorest.WithBaseURL(client.BaseURI), 463 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listBuildSourceUploadUrl", pathParameters), 464 autorest.WithQueryParameters(queryParameters)) 465 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 466} 467 468// GetBuildSourceUploadURLSender sends the GetBuildSourceUploadURL request. The method will close the 469// http.Response Body if it receives an error. 470func (client RegistriesClient) GetBuildSourceUploadURLSender(req *http.Request) (*http.Response, error) { 471 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 472 return autorest.SendWithSender(client, req, sd...) 473} 474 475// GetBuildSourceUploadURLResponder handles the response to the GetBuildSourceUploadURL request. The method always 476// closes the http.Response Body. 477func (client RegistriesClient) GetBuildSourceUploadURLResponder(resp *http.Response) (result SourceUploadDefinition, err error) { 478 err = autorest.Respond( 479 resp, 480 client.ByInspecting(), 481 azure.WithErrorUnlessStatusCode(http.StatusOK), 482 autorest.ByUnmarshallingJSON(&result), 483 autorest.ByClosing()) 484 result.Response = autorest.Response{Response: resp} 485 return 486} 487 488// ImportImage copies an image to this container registry from the specified container registry. 489// Parameters: 490// resourceGroupName - the name of the resource group to which the container registry belongs. 491// registryName - the name of the container registry. 492// parameters - the parameters specifying the image to copy and the source container registry. 493func (client RegistriesClient) ImportImage(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters) (result RegistriesImportImageFuture, err error) { 494 if tracing.IsEnabled() { 495 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ImportImage") 496 defer func() { 497 sc := -1 498 if result.Response() != nil { 499 sc = result.Response().StatusCode 500 } 501 tracing.EndSpan(ctx, sc, err) 502 }() 503 } 504 if err := validation.Validate([]validation.Validation{ 505 {TargetValue: resourceGroupName, 506 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, 507 {TargetValue: registryName, 508 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 509 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 510 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 511 {TargetValue: parameters, 512 Constraints: []validation.Constraint{{Target: "parameters.Source", Name: validation.Null, Rule: true, 513 Chain: []validation.Constraint{{Target: "parameters.Source.Credentials", Name: validation.Null, Rule: false, 514 Chain: []validation.Constraint{{Target: "parameters.Source.Credentials.Password", Name: validation.Null, Rule: true, Chain: nil}}}, 515 {Target: "parameters.Source.SourceImage", Name: validation.Null, Rule: true, Chain: nil}, 516 }}}}}); err != nil { 517 return result, validation.NewError("containerregistry.RegistriesClient", "ImportImage", err.Error()) 518 } 519 520 req, err := client.ImportImagePreparer(ctx, resourceGroupName, registryName, parameters) 521 if err != nil { 522 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ImportImage", nil, "Failure preparing request") 523 return 524 } 525 526 result, err = client.ImportImageSender(req) 527 if err != nil { 528 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ImportImage", result.Response(), "Failure sending request") 529 return 530 } 531 532 return 533} 534 535// ImportImagePreparer prepares the ImportImage request. 536func (client RegistriesClient) ImportImagePreparer(ctx context.Context, resourceGroupName string, registryName string, parameters ImportImageParameters) (*http.Request, error) { 537 pathParameters := map[string]interface{}{ 538 "registryName": autorest.Encode("path", registryName), 539 "resourceGroupName": autorest.Encode("path", resourceGroupName), 540 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 541 } 542 543 const APIVersion = "2019-05-01" 544 queryParameters := map[string]interface{}{ 545 "api-version": APIVersion, 546 } 547 548 preparer := autorest.CreatePreparer( 549 autorest.AsContentType("application/json; charset=utf-8"), 550 autorest.AsPost(), 551 autorest.WithBaseURL(client.BaseURI), 552 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/importImage", pathParameters), 553 autorest.WithJSON(parameters), 554 autorest.WithQueryParameters(queryParameters)) 555 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 556} 557 558// ImportImageSender sends the ImportImage request. The method will close the 559// http.Response Body if it receives an error. 560func (client RegistriesClient) ImportImageSender(req *http.Request) (future RegistriesImportImageFuture, err error) { 561 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 562 var resp *http.Response 563 resp, err = autorest.SendWithSender(client, req, sd...) 564 if err != nil { 565 return 566 } 567 future.Future, err = azure.NewFutureFromResponse(resp) 568 return 569} 570 571// ImportImageResponder handles the response to the ImportImage request. The method always 572// closes the http.Response Body. 573func (client RegistriesClient) ImportImageResponder(resp *http.Response) (result autorest.Response, err error) { 574 err = autorest.Respond( 575 resp, 576 client.ByInspecting(), 577 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 578 autorest.ByClosing()) 579 result.Response = resp 580 return 581} 582 583// List lists all the container registries under the specified subscription. 584func (client RegistriesClient) List(ctx context.Context) (result RegistryListResultPage, err error) { 585 if tracing.IsEnabled() { 586 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List") 587 defer func() { 588 sc := -1 589 if result.rlr.Response.Response != nil { 590 sc = result.rlr.Response.Response.StatusCode 591 } 592 tracing.EndSpan(ctx, sc, err) 593 }() 594 } 595 result.fn = client.listNextResults 596 req, err := client.ListPreparer(ctx) 597 if err != nil { 598 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") 599 return 600 } 601 602 resp, err := client.ListSender(req) 603 if err != nil { 604 result.rlr.Response = autorest.Response{Response: resp} 605 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") 606 return 607 } 608 609 result.rlr, err = client.ListResponder(resp) 610 if err != nil { 611 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request") 612 } 613 614 return 615} 616 617// ListPreparer prepares the List request. 618func (client RegistriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { 619 pathParameters := map[string]interface{}{ 620 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 621 } 622 623 const APIVersion = "2019-05-01" 624 queryParameters := map[string]interface{}{ 625 "api-version": APIVersion, 626 } 627 628 preparer := autorest.CreatePreparer( 629 autorest.AsGet(), 630 autorest.WithBaseURL(client.BaseURI), 631 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries", pathParameters), 632 autorest.WithQueryParameters(queryParameters)) 633 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 634} 635 636// ListSender sends the List request. The method will close the 637// http.Response Body if it receives an error. 638func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) { 639 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 640 return autorest.SendWithSender(client, req, sd...) 641} 642 643// ListResponder handles the response to the List request. The method always 644// closes the http.Response Body. 645func (client RegistriesClient) ListResponder(resp *http.Response) (result RegistryListResult, err error) { 646 err = autorest.Respond( 647 resp, 648 client.ByInspecting(), 649 azure.WithErrorUnlessStatusCode(http.StatusOK), 650 autorest.ByUnmarshallingJSON(&result), 651 autorest.ByClosing()) 652 result.Response = autorest.Response{Response: resp} 653 return 654} 655 656// listNextResults retrieves the next set of results, if any. 657func (client RegistriesClient) listNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { 658 req, err := lastResults.registryListResultPreparer(ctx) 659 if err != nil { 660 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", nil, "Failure preparing next results request") 661 } 662 if req == nil { 663 return 664 } 665 resp, err := client.ListSender(req) 666 if err != nil { 667 result.Response = autorest.Response{Response: resp} 668 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure sending next results request") 669 } 670 result, err = client.ListResponder(resp) 671 if err != nil { 672 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure responding to next results request") 673 } 674 return 675} 676 677// ListComplete enumerates all values, automatically crossing page boundaries as required. 678func (client RegistriesClient) ListComplete(ctx context.Context) (result RegistryListResultIterator, err error) { 679 if tracing.IsEnabled() { 680 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List") 681 defer func() { 682 sc := -1 683 if result.Response().Response.Response != nil { 684 sc = result.page.Response().Response.Response.StatusCode 685 } 686 tracing.EndSpan(ctx, sc, err) 687 }() 688 } 689 result.page, err = client.List(ctx) 690 return 691} 692 693// ListByResourceGroup lists all the container registries under the specified resource group. 694// Parameters: 695// resourceGroupName - the name of the resource group to which the container registry belongs. 696func (client RegistriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result RegistryListResultPage, err error) { 697 if tracing.IsEnabled() { 698 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup") 699 defer func() { 700 sc := -1 701 if result.rlr.Response.Response != nil { 702 sc = result.rlr.Response.Response.StatusCode 703 } 704 tracing.EndSpan(ctx, sc, err) 705 }() 706 } 707 if err := validation.Validate([]validation.Validation{ 708 {TargetValue: resourceGroupName, 709 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil { 710 return result, validation.NewError("containerregistry.RegistriesClient", "ListByResourceGroup", err.Error()) 711 } 712 713 result.fn = client.listByResourceGroupNextResults 714 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 715 if err != nil { 716 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") 717 return 718 } 719 720 resp, err := client.ListByResourceGroupSender(req) 721 if err != nil { 722 result.rlr.Response = autorest.Response{Response: resp} 723 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") 724 return 725 } 726 727 result.rlr, err = client.ListByResourceGroupResponder(resp) 728 if err != nil { 729 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request") 730 } 731 732 return 733} 734 735// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 736func (client RegistriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 737 pathParameters := map[string]interface{}{ 738 "resourceGroupName": autorest.Encode("path", resourceGroupName), 739 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 740 } 741 742 const APIVersion = "2019-05-01" 743 queryParameters := map[string]interface{}{ 744 "api-version": APIVersion, 745 } 746 747 preparer := autorest.CreatePreparer( 748 autorest.AsGet(), 749 autorest.WithBaseURL(client.BaseURI), 750 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", pathParameters), 751 autorest.WithQueryParameters(queryParameters)) 752 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 753} 754 755// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 756// http.Response Body if it receives an error. 757func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 758 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 759 return autorest.SendWithSender(client, req, sd...) 760} 761 762// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 763// closes the http.Response Body. 764func (client RegistriesClient) ListByResourceGroupResponder(resp *http.Response) (result RegistryListResult, err error) { 765 err = autorest.Respond( 766 resp, 767 client.ByInspecting(), 768 azure.WithErrorUnlessStatusCode(http.StatusOK), 769 autorest.ByUnmarshallingJSON(&result), 770 autorest.ByClosing()) 771 result.Response = autorest.Response{Response: resp} 772 return 773} 774 775// listByResourceGroupNextResults retrieves the next set of results, if any. 776func (client RegistriesClient) listByResourceGroupNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { 777 req, err := lastResults.registryListResultPreparer(ctx) 778 if err != nil { 779 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 780 } 781 if req == nil { 782 return 783 } 784 resp, err := client.ListByResourceGroupSender(req) 785 if err != nil { 786 result.Response = autorest.Response{Response: resp} 787 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 788 } 789 result, err = client.ListByResourceGroupResponder(resp) 790 if err != nil { 791 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 792 } 793 return 794} 795 796// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 797func (client RegistriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result RegistryListResultIterator, err error) { 798 if tracing.IsEnabled() { 799 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup") 800 defer func() { 801 sc := -1 802 if result.Response().Response.Response != nil { 803 sc = result.page.Response().Response.Response.StatusCode 804 } 805 tracing.EndSpan(ctx, sc, err) 806 }() 807 } 808 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 809 return 810} 811 812// ListCredentials lists the login credentials 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) ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) { 817 if tracing.IsEnabled() { 818 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListCredentials") 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", "ListCredentials", err.Error()) 835 } 836 837 req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, registryName) 838 if err != nil { 839 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request") 840 return 841 } 842 843 resp, err := client.ListCredentialsSender(req) 844 if err != nil { 845 result.Response = autorest.Response{Response: resp} 846 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request") 847 return 848 } 849 850 result, err = client.ListCredentialsResponder(resp) 851 if err != nil { 852 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request") 853 } 854 855 return 856} 857 858// ListCredentialsPreparer prepares the ListCredentials request. 859func (client RegistriesClient) ListCredentialsPreparer(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 = "2019-05-01" 867 queryParameters := map[string]interface{}{ 868 "api-version": APIVersion, 869 } 870 871 preparer := autorest.CreatePreparer( 872 autorest.AsPost(), 873 autorest.WithBaseURL(client.BaseURI), 874 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters), 875 autorest.WithQueryParameters(queryParameters)) 876 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 877} 878 879// ListCredentialsSender sends the ListCredentials request. The method will close the 880// http.Response Body if it receives an error. 881func (client RegistriesClient) ListCredentialsSender(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// ListCredentialsResponder handles the response to the ListCredentials request. The method always 887// closes the http.Response Body. 888func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, 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 = "2019-05-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 = "2019-05-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// ScheduleRun schedules a new run based on the request parameters and add it to the run queue. 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// runRequest - the parameters of a run that needs to scheduled. 1082func (client RegistriesClient) ScheduleRun(ctx context.Context, resourceGroupName string, registryName string, runRequest BasicRunRequest) (result RegistriesScheduleRunFuture, err error) { 1083 if tracing.IsEnabled() { 1084 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ScheduleRun") 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", "ScheduleRun", err.Error()) 1101 } 1102 1103 req, err := client.ScheduleRunPreparer(ctx, resourceGroupName, registryName, runRequest) 1104 if err != nil { 1105 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ScheduleRun", nil, "Failure preparing request") 1106 return 1107 } 1108 1109 result, err = client.ScheduleRunSender(req) 1110 if err != nil { 1111 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ScheduleRun", result.Response(), "Failure sending request") 1112 return 1113 } 1114 1115 return 1116} 1117 1118// ScheduleRunPreparer prepares the ScheduleRun request. 1119func (client RegistriesClient) ScheduleRunPreparer(ctx context.Context, resourceGroupName string, registryName string, runRequest BasicRunRequest) (*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 = "2019-04-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.AsPost(), 1134 autorest.WithBaseURL(client.BaseURI), 1135 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun", pathParameters), 1136 autorest.WithJSON(runRequest), 1137 autorest.WithQueryParameters(queryParameters)) 1138 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1139} 1140 1141// ScheduleRunSender sends the ScheduleRun request. The method will close the 1142// http.Response Body if it receives an error. 1143func (client RegistriesClient) ScheduleRunSender(req *http.Request) (future RegistriesScheduleRunFuture, 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// ScheduleRunResponder handles the response to the ScheduleRun request. The method always 1155// closes the http.Response Body. 1156func (client RegistriesClient) ScheduleRunResponder(resp *http.Response) (result Run, err error) { 1157 err = autorest.Respond( 1158 resp, 1159 client.ByInspecting(), 1160 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 1161 autorest.ByUnmarshallingJSON(&result), 1162 autorest.ByClosing()) 1163 result.Response = autorest.Response{Response: resp} 1164 return 1165} 1166 1167// Update updates a container registry with the specified parameters. 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// registryUpdateParameters - the parameters for updating a container registry. 1172func (client RegistriesClient) Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result RegistriesUpdateFuture, err error) { 1173 if tracing.IsEnabled() { 1174 ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Update") 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", "Update", err.Error()) 1191 } 1192 1193 req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, registryUpdateParameters) 1194 if err != nil { 1195 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") 1196 return 1197 } 1198 1199 result, err = client.UpdateSender(req) 1200 if err != nil { 1201 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", result.Response(), "Failure sending request") 1202 return 1203 } 1204 1205 return 1206} 1207 1208// UpdatePreparer prepares the Update request. 1209func (client RegistriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*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 = "2019-05-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.AsPatch(), 1224 autorest.WithBaseURL(client.BaseURI), 1225 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 1226 autorest.WithJSON(registryUpdateParameters), 1227 autorest.WithQueryParameters(queryParameters)) 1228 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 1229} 1230 1231// UpdateSender sends the Update request. The method will close the 1232// http.Response Body if it receives an error. 1233func (client RegistriesClient) UpdateSender(req *http.Request) (future RegistriesUpdateFuture, 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// UpdateResponder handles the response to the Update request. The method always 1245// closes the http.Response Body. 1246func (client RegistriesClient) UpdateResponder(resp *http.Response) (result Registry, err error) { 1247 err = autorest.Respond( 1248 resp, 1249 client.ByInspecting(), 1250 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 1251 autorest.ByUnmarshallingJSON(&result), 1252 autorest.ByClosing()) 1253 result.Response = autorest.Response{Response: resp} 1254 return 1255} 1256