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