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 "net/http" 26) 27 28// RegistriesClient is the client for the Registries methods of the Containerregistry service. 29type RegistriesClient struct { 30 BaseClient 31} 32 33// NewRegistriesClient creates an instance of the RegistriesClient client. 34func NewRegistriesClient(subscriptionID string) RegistriesClient { 35 return NewRegistriesClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewRegistriesClientWithBaseURI creates an instance of the RegistriesClient client. 39func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) RegistriesClient { 40 return RegistriesClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// CheckNameAvailability checks whether the container registry name is available for use. The name must contain only 44// alphanumeric characters, be globally unique, and between 5 and 50 characters in length. 45// Parameters: 46// registryNameCheckRequest - the object containing information for the availability request. 47func (client RegistriesClient) CheckNameAvailability(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) { 48 if err := validation.Validate([]validation.Validation{ 49 {TargetValue: registryNameCheckRequest, 50 Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, 51 Chain: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil}, 52 {Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil}, 53 {Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}, 54 }}, 55 {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 56 return result, validation.NewError("containerregistry.RegistriesClient", "CheckNameAvailability", err.Error()) 57 } 58 59 req, err := client.CheckNameAvailabilityPreparer(ctx, registryNameCheckRequest) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") 62 return 63 } 64 65 resp, err := client.CheckNameAvailabilitySender(req) 66 if err != nil { 67 result.Response = autorest.Response{Response: resp} 68 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") 69 return 70 } 71 72 result, err = client.CheckNameAvailabilityResponder(resp) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure responding to request") 75 } 76 77 return 78} 79 80// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. 81func (client RegistriesClient) CheckNameAvailabilityPreparer(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (*http.Request, error) { 82 pathParameters := map[string]interface{}{ 83 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 84 } 85 86 const APIVersion = "2017-03-01" 87 queryParameters := map[string]interface{}{ 88 "api-version": APIVersion, 89 } 90 91 preparer := autorest.CreatePreparer( 92 autorest.AsContentType("application/json; charset=utf-8"), 93 autorest.AsPost(), 94 autorest.WithBaseURL(client.BaseURI), 95 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability", pathParameters), 96 autorest.WithJSON(registryNameCheckRequest), 97 autorest.WithQueryParameters(queryParameters)) 98 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 99} 100 101// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the 102// http.Response Body if it receives an error. 103func (client RegistriesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { 104 return autorest.SendWithSender(client, req, 105 azure.DoRetryWithRegistration(client.Client)) 106} 107 108// CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always 109// closes the http.Response Body. 110func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Response) (result RegistryNameStatus, err error) { 111 err = autorest.Respond( 112 resp, 113 client.ByInspecting(), 114 azure.WithErrorUnlessStatusCode(http.StatusOK), 115 autorest.ByUnmarshallingJSON(&result), 116 autorest.ByClosing()) 117 result.Response = autorest.Response{Response: resp} 118 return 119} 120 121// Create creates a container registry with the specified parameters. 122// Parameters: 123// resourceGroupName - the name of the resource group to which the container registry belongs. 124// registryName - the name of the container registry. 125// registryCreateParameters - the parameters for creating a container registry. 126func (client RegistriesClient) Create(ctx context.Context, resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters) (result RegistriesCreateFuture, err error) { 127 if err := validation.Validate([]validation.Validation{ 128 {TargetValue: registryName, 129 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 130 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 131 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 132 {TargetValue: registryCreateParameters, 133 Constraints: []validation.Constraint{{Target: "registryCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, 134 {Target: "registryCreateParameters.Sku", Name: validation.Null, Rule: true, 135 Chain: []validation.Constraint{{Target: "registryCreateParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, 136 {Target: "registryCreateParameters.RegistryPropertiesCreateParameters", Name: validation.Null, Rule: false, 137 Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount", Name: validation.Null, Rule: true, 138 Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, 139 {Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, 140 }}, 141 }}}}}); err != nil { 142 return result, validation.NewError("containerregistry.RegistriesClient", "Create", err.Error()) 143 } 144 145 req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, registryCreateParameters) 146 if err != nil { 147 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure preparing request") 148 return 149 } 150 151 result, err = client.CreateSender(req) 152 if err != nil { 153 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", result.Response(), "Failure sending request") 154 return 155 } 156 157 return 158} 159 160// CreatePreparer prepares the Create request. 161func (client RegistriesClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters) (*http.Request, error) { 162 pathParameters := map[string]interface{}{ 163 "registryName": autorest.Encode("path", registryName), 164 "resourceGroupName": autorest.Encode("path", resourceGroupName), 165 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 166 } 167 168 const APIVersion = "2017-03-01" 169 queryParameters := map[string]interface{}{ 170 "api-version": APIVersion, 171 } 172 173 preparer := autorest.CreatePreparer( 174 autorest.AsContentType("application/json; charset=utf-8"), 175 autorest.AsPut(), 176 autorest.WithBaseURL(client.BaseURI), 177 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 178 autorest.WithJSON(registryCreateParameters), 179 autorest.WithQueryParameters(queryParameters)) 180 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 181} 182 183// CreateSender sends the Create request. The method will close the 184// http.Response Body if it receives an error. 185func (client RegistriesClient) CreateSender(req *http.Request) (future RegistriesCreateFuture, err error) { 186 var resp *http.Response 187 resp, err = autorest.SendWithSender(client, req, 188 azure.DoRetryWithRegistration(client.Client)) 189 if err != nil { 190 return 191 } 192 err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted)) 193 if err != nil { 194 return 195 } 196 future.Future, err = azure.NewFutureFromResponse(resp) 197 return 198} 199 200// CreateResponder handles the response to the Create request. The method always 201// closes the http.Response Body. 202func (client RegistriesClient) CreateResponder(resp *http.Response) (result Registry, err error) { 203 err = autorest.Respond( 204 resp, 205 client.ByInspecting(), 206 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 207 autorest.ByUnmarshallingJSON(&result), 208 autorest.ByClosing()) 209 result.Response = autorest.Response{Response: resp} 210 return 211} 212 213// Delete deletes a container registry. 214// Parameters: 215// resourceGroupName - the name of the resource group to which the container registry belongs. 216// registryName - the name of the container registry. 217func (client RegistriesClient) Delete(ctx context.Context, resourceGroupName string, registryName string) (result autorest.Response, err error) { 218 if err := validation.Validate([]validation.Validation{ 219 {TargetValue: registryName, 220 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 221 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 222 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 223 return result, validation.NewError("containerregistry.RegistriesClient", "Delete", err.Error()) 224 } 225 226 req, err := client.DeletePreparer(ctx, resourceGroupName, registryName) 227 if err != nil { 228 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") 229 return 230 } 231 232 resp, err := client.DeleteSender(req) 233 if err != nil { 234 result.Response = resp 235 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") 236 return 237 } 238 239 result, err = client.DeleteResponder(resp) 240 if err != nil { 241 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure responding to request") 242 } 243 244 return 245} 246 247// DeletePreparer prepares the Delete request. 248func (client RegistriesClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 249 pathParameters := map[string]interface{}{ 250 "registryName": autorest.Encode("path", registryName), 251 "resourceGroupName": autorest.Encode("path", resourceGroupName), 252 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 253 } 254 255 const APIVersion = "2017-03-01" 256 queryParameters := map[string]interface{}{ 257 "api-version": APIVersion, 258 } 259 260 preparer := autorest.CreatePreparer( 261 autorest.AsDelete(), 262 autorest.WithBaseURL(client.BaseURI), 263 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 264 autorest.WithQueryParameters(queryParameters)) 265 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 266} 267 268// DeleteSender sends the Delete request. The method will close the 269// http.Response Body if it receives an error. 270func (client RegistriesClient) DeleteSender(req *http.Request) (*http.Response, error) { 271 return autorest.SendWithSender(client, req, 272 azure.DoRetryWithRegistration(client.Client)) 273} 274 275// DeleteResponder handles the response to the Delete request. The method always 276// closes the http.Response Body. 277func (client RegistriesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 278 err = autorest.Respond( 279 resp, 280 client.ByInspecting(), 281 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 282 autorest.ByClosing()) 283 result.Response = resp 284 return 285} 286 287// Get gets the properties of the specified container registry. 288// Parameters: 289// resourceGroupName - the name of the resource group to which the container registry belongs. 290// registryName - the name of the container registry. 291func (client RegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string) (result Registry, err error) { 292 if err := validation.Validate([]validation.Validation{ 293 {TargetValue: registryName, 294 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 295 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 296 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 297 return result, validation.NewError("containerregistry.RegistriesClient", "Get", err.Error()) 298 } 299 300 req, err := client.GetPreparer(ctx, resourceGroupName, registryName) 301 if err != nil { 302 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil, "Failure preparing request") 303 return 304 } 305 306 resp, err := client.GetSender(req) 307 if err != nil { 308 result.Response = autorest.Response{Response: resp} 309 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request") 310 return 311 } 312 313 result, err = client.GetResponder(resp) 314 if err != nil { 315 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request") 316 } 317 318 return 319} 320 321// GetPreparer prepares the Get request. 322func (client RegistriesClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 323 pathParameters := map[string]interface{}{ 324 "registryName": autorest.Encode("path", registryName), 325 "resourceGroupName": autorest.Encode("path", resourceGroupName), 326 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 327 } 328 329 const APIVersion = "2017-03-01" 330 queryParameters := map[string]interface{}{ 331 "api-version": APIVersion, 332 } 333 334 preparer := autorest.CreatePreparer( 335 autorest.AsGet(), 336 autorest.WithBaseURL(client.BaseURI), 337 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 338 autorest.WithQueryParameters(queryParameters)) 339 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 340} 341 342// GetSender sends the Get request. The method will close the 343// http.Response Body if it receives an error. 344func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) { 345 return autorest.SendWithSender(client, req, 346 azure.DoRetryWithRegistration(client.Client)) 347} 348 349// GetResponder handles the response to the Get request. The method always 350// closes the http.Response Body. 351func (client RegistriesClient) GetResponder(resp *http.Response) (result Registry, err error) { 352 err = autorest.Respond( 353 resp, 354 client.ByInspecting(), 355 azure.WithErrorUnlessStatusCode(http.StatusOK), 356 autorest.ByUnmarshallingJSON(&result), 357 autorest.ByClosing()) 358 result.Response = autorest.Response{Response: resp} 359 return 360} 361 362// List lists all the container registries under the specified subscription. 363func (client RegistriesClient) List(ctx context.Context) (result RegistryListResultPage, err error) { 364 result.fn = client.listNextResults 365 req, err := client.ListPreparer(ctx) 366 if err != nil { 367 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") 368 return 369 } 370 371 resp, err := client.ListSender(req) 372 if err != nil { 373 result.rlr.Response = autorest.Response{Response: resp} 374 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") 375 return 376 } 377 378 result.rlr, err = client.ListResponder(resp) 379 if err != nil { 380 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request") 381 } 382 383 return 384} 385 386// ListPreparer prepares the List request. 387func (client RegistriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { 388 pathParameters := map[string]interface{}{ 389 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 390 } 391 392 const APIVersion = "2017-03-01" 393 queryParameters := map[string]interface{}{ 394 "api-version": APIVersion, 395 } 396 397 preparer := autorest.CreatePreparer( 398 autorest.AsGet(), 399 autorest.WithBaseURL(client.BaseURI), 400 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries", pathParameters), 401 autorest.WithQueryParameters(queryParameters)) 402 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 403} 404 405// ListSender sends the List request. The method will close the 406// http.Response Body if it receives an error. 407func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) { 408 return autorest.SendWithSender(client, req, 409 azure.DoRetryWithRegistration(client.Client)) 410} 411 412// ListResponder handles the response to the List request. The method always 413// closes the http.Response Body. 414func (client RegistriesClient) ListResponder(resp *http.Response) (result RegistryListResult, err error) { 415 err = autorest.Respond( 416 resp, 417 client.ByInspecting(), 418 azure.WithErrorUnlessStatusCode(http.StatusOK), 419 autorest.ByUnmarshallingJSON(&result), 420 autorest.ByClosing()) 421 result.Response = autorest.Response{Response: resp} 422 return 423} 424 425// listNextResults retrieves the next set of results, if any. 426func (client RegistriesClient) listNextResults(lastResults RegistryListResult) (result RegistryListResult, err error) { 427 req, err := lastResults.registryListResultPreparer() 428 if err != nil { 429 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", nil, "Failure preparing next results request") 430 } 431 if req == nil { 432 return 433 } 434 resp, err := client.ListSender(req) 435 if err != nil { 436 result.Response = autorest.Response{Response: resp} 437 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure sending next results request") 438 } 439 result, err = client.ListResponder(resp) 440 if err != nil { 441 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure responding to next results request") 442 } 443 return 444} 445 446// ListComplete enumerates all values, automatically crossing page boundaries as required. 447func (client RegistriesClient) ListComplete(ctx context.Context) (result RegistryListResultIterator, err error) { 448 result.page, err = client.List(ctx) 449 return 450} 451 452// ListByResourceGroup lists all the container registries under the specified resource group. 453// Parameters: 454// resourceGroupName - the name of the resource group to which the container registry belongs. 455func (client RegistriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result RegistryListResultPage, err error) { 456 result.fn = client.listByResourceGroupNextResults 457 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 458 if err != nil { 459 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") 460 return 461 } 462 463 resp, err := client.ListByResourceGroupSender(req) 464 if err != nil { 465 result.rlr.Response = autorest.Response{Response: resp} 466 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") 467 return 468 } 469 470 result.rlr, err = client.ListByResourceGroupResponder(resp) 471 if err != nil { 472 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request") 473 } 474 475 return 476} 477 478// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 479func (client RegistriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 480 pathParameters := map[string]interface{}{ 481 "resourceGroupName": autorest.Encode("path", resourceGroupName), 482 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 483 } 484 485 const APIVersion = "2017-03-01" 486 queryParameters := map[string]interface{}{ 487 "api-version": APIVersion, 488 } 489 490 preparer := autorest.CreatePreparer( 491 autorest.AsGet(), 492 autorest.WithBaseURL(client.BaseURI), 493 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", pathParameters), 494 autorest.WithQueryParameters(queryParameters)) 495 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 496} 497 498// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 499// http.Response Body if it receives an error. 500func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 501 return autorest.SendWithSender(client, req, 502 azure.DoRetryWithRegistration(client.Client)) 503} 504 505// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 506// closes the http.Response Body. 507func (client RegistriesClient) ListByResourceGroupResponder(resp *http.Response) (result RegistryListResult, err error) { 508 err = autorest.Respond( 509 resp, 510 client.ByInspecting(), 511 azure.WithErrorUnlessStatusCode(http.StatusOK), 512 autorest.ByUnmarshallingJSON(&result), 513 autorest.ByClosing()) 514 result.Response = autorest.Response{Response: resp} 515 return 516} 517 518// listByResourceGroupNextResults retrieves the next set of results, if any. 519func (client RegistriesClient) listByResourceGroupNextResults(lastResults RegistryListResult) (result RegistryListResult, err error) { 520 req, err := lastResults.registryListResultPreparer() 521 if err != nil { 522 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 523 } 524 if req == nil { 525 return 526 } 527 resp, err := client.ListByResourceGroupSender(req) 528 if err != nil { 529 result.Response = autorest.Response{Response: resp} 530 return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 531 } 532 result, err = client.ListByResourceGroupResponder(resp) 533 if err != nil { 534 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 535 } 536 return 537} 538 539// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 540func (client RegistriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result RegistryListResultIterator, err error) { 541 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 542 return 543} 544 545// ListCredentials lists the login credentials for the specified container registry. 546// Parameters: 547// resourceGroupName - the name of the resource group to which the container registry belongs. 548// registryName - the name of the container registry. 549func (client RegistriesClient) ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) { 550 if err := validation.Validate([]validation.Validation{ 551 {TargetValue: registryName, 552 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 553 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 554 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 555 return result, validation.NewError("containerregistry.RegistriesClient", "ListCredentials", err.Error()) 556 } 557 558 req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, registryName) 559 if err != nil { 560 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request") 561 return 562 } 563 564 resp, err := client.ListCredentialsSender(req) 565 if err != nil { 566 result.Response = autorest.Response{Response: resp} 567 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request") 568 return 569 } 570 571 result, err = client.ListCredentialsResponder(resp) 572 if err != nil { 573 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request") 574 } 575 576 return 577} 578 579// ListCredentialsPreparer prepares the ListCredentials request. 580func (client RegistriesClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { 581 pathParameters := map[string]interface{}{ 582 "registryName": autorest.Encode("path", registryName), 583 "resourceGroupName": autorest.Encode("path", resourceGroupName), 584 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 585 } 586 587 const APIVersion = "2017-03-01" 588 queryParameters := map[string]interface{}{ 589 "api-version": APIVersion, 590 } 591 592 preparer := autorest.CreatePreparer( 593 autorest.AsPost(), 594 autorest.WithBaseURL(client.BaseURI), 595 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters), 596 autorest.WithQueryParameters(queryParameters)) 597 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 598} 599 600// ListCredentialsSender sends the ListCredentials request. The method will close the 601// http.Response Body if it receives an error. 602func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { 603 return autorest.SendWithSender(client, req, 604 azure.DoRetryWithRegistration(client.Client)) 605} 606 607// ListCredentialsResponder handles the response to the ListCredentials request. The method always 608// closes the http.Response Body. 609func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { 610 err = autorest.Respond( 611 resp, 612 client.ByInspecting(), 613 azure.WithErrorUnlessStatusCode(http.StatusOK), 614 autorest.ByUnmarshallingJSON(&result), 615 autorest.ByClosing()) 616 result.Response = autorest.Response{Response: resp} 617 return 618} 619 620// RegenerateCredential regenerates one of the login credentials for the specified container registry. 621// Parameters: 622// resourceGroupName - the name of the resource group to which the container registry belongs. 623// registryName - the name of the container registry. 624// regenerateCredentialParameters - specifies name of the password which should be regenerated -- password or 625// password2. 626func (client RegistriesClient) RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) { 627 if err := validation.Validate([]validation.Validation{ 628 {TargetValue: registryName, 629 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 630 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 631 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 632 return result, validation.NewError("containerregistry.RegistriesClient", "RegenerateCredential", err.Error()) 633 } 634 635 req, err := client.RegenerateCredentialPreparer(ctx, resourceGroupName, registryName, regenerateCredentialParameters) 636 if err != nil { 637 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request") 638 return 639 } 640 641 resp, err := client.RegenerateCredentialSender(req) 642 if err != nil { 643 result.Response = autorest.Response{Response: resp} 644 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request") 645 return 646 } 647 648 result, err = client.RegenerateCredentialResponder(resp) 649 if err != nil { 650 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request") 651 } 652 653 return 654} 655 656// RegenerateCredentialPreparer prepares the RegenerateCredential request. 657func (client RegistriesClient) RegenerateCredentialPreparer(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*http.Request, error) { 658 pathParameters := map[string]interface{}{ 659 "registryName": autorest.Encode("path", registryName), 660 "resourceGroupName": autorest.Encode("path", resourceGroupName), 661 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 662 } 663 664 const APIVersion = "2017-03-01" 665 queryParameters := map[string]interface{}{ 666 "api-version": APIVersion, 667 } 668 669 preparer := autorest.CreatePreparer( 670 autorest.AsContentType("application/json; charset=utf-8"), 671 autorest.AsPost(), 672 autorest.WithBaseURL(client.BaseURI), 673 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", pathParameters), 674 autorest.WithJSON(regenerateCredentialParameters), 675 autorest.WithQueryParameters(queryParameters)) 676 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 677} 678 679// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the 680// http.Response Body if it receives an error. 681func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) { 682 return autorest.SendWithSender(client, req, 683 azure.DoRetryWithRegistration(client.Client)) 684} 685 686// RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always 687// closes the http.Response Body. 688func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { 689 err = autorest.Respond( 690 resp, 691 client.ByInspecting(), 692 azure.WithErrorUnlessStatusCode(http.StatusOK), 693 autorest.ByUnmarshallingJSON(&result), 694 autorest.ByClosing()) 695 result.Response = autorest.Response{Response: resp} 696 return 697} 698 699// Update updates a container registry with the specified parameters. 700// Parameters: 701// resourceGroupName - the name of the resource group to which the container registry belongs. 702// registryName - the name of the container registry. 703// registryUpdateParameters - the parameters for updating a container registry. 704func (client RegistriesClient) Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result Registry, err error) { 705 if err := validation.Validate([]validation.Validation{ 706 {TargetValue: registryName, 707 Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 708 {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, 709 {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 710 return result, validation.NewError("containerregistry.RegistriesClient", "Update", err.Error()) 711 } 712 713 req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, registryUpdateParameters) 714 if err != nil { 715 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") 716 return 717 } 718 719 resp, err := client.UpdateSender(req) 720 if err != nil { 721 result.Response = autorest.Response{Response: resp} 722 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") 723 return 724 } 725 726 result, err = client.UpdateResponder(resp) 727 if err != nil { 728 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure responding to request") 729 } 730 731 return 732} 733 734// UpdatePreparer prepares the Update request. 735func (client RegistriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*http.Request, error) { 736 pathParameters := map[string]interface{}{ 737 "registryName": autorest.Encode("path", registryName), 738 "resourceGroupName": autorest.Encode("path", resourceGroupName), 739 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 740 } 741 742 const APIVersion = "2017-03-01" 743 queryParameters := map[string]interface{}{ 744 "api-version": APIVersion, 745 } 746 747 preparer := autorest.CreatePreparer( 748 autorest.AsContentType("application/json; charset=utf-8"), 749 autorest.AsPatch(), 750 autorest.WithBaseURL(client.BaseURI), 751 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), 752 autorest.WithJSON(registryUpdateParameters), 753 autorest.WithQueryParameters(queryParameters)) 754 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 755} 756 757// UpdateSender sends the Update request. The method will close the 758// http.Response Body if it receives an error. 759func (client RegistriesClient) UpdateSender(req *http.Request) (*http.Response, error) { 760 return autorest.SendWithSender(client, req, 761 azure.DoRetryWithRegistration(client.Client)) 762} 763 764// UpdateResponder handles the response to the Update request. The method always 765// closes the http.Response Body. 766func (client RegistriesClient) UpdateResponder(resp *http.Response) (result Registry, err error) { 767 err = autorest.Respond( 768 resp, 769 client.ByInspecting(), 770 azure.WithErrorUnlessStatusCode(http.StatusOK), 771 autorest.ByUnmarshallingJSON(&result), 772 autorest.ByClosing()) 773 result.Response = autorest.Response{Response: resp} 774 return 775} 776