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