1package resources 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 "github.com/Azure/go-autorest/autorest" 22 "github.com/Azure/go-autorest/autorest/azure" 23 "github.com/Azure/go-autorest/autorest/validation" 24 "net/http" 25) 26 27// GroupsClient is the provides operations for working with resources and resource groups. 28type GroupsClient struct { 29 ManagementClient 30} 31 32// NewGroupsClient creates an instance of the GroupsClient client. 33func NewGroupsClient(subscriptionID string) GroupsClient { 34 return NewGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID) 35} 36 37// NewGroupsClientWithBaseURI creates an instance of the GroupsClient client. 38func NewGroupsClientWithBaseURI(baseURI string, subscriptionID string) GroupsClient { 39 return GroupsClient{NewWithBaseURI(baseURI, subscriptionID)} 40} 41 42// CheckExistence checks whether a resource group exists. 43// 44// resourceGroupName is the name of the resource group to check. The name is case insensitive. 45func (client GroupsClient) CheckExistence(resourceGroupName string) (result autorest.Response, err error) { 46 if err := validation.Validate([]validation.Validation{ 47 {TargetValue: resourceGroupName, 48 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 49 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 50 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 51 return result, validation.NewErrorWithValidationError(err, "resources.GroupsClient", "CheckExistence") 52 } 53 54 req, err := client.CheckExistencePreparer(resourceGroupName) 55 if err != nil { 56 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", nil, "Failure preparing request") 57 return 58 } 59 60 resp, err := client.CheckExistenceSender(req) 61 if err != nil { 62 result.Response = resp 63 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", resp, "Failure sending request") 64 return 65 } 66 67 result, err = client.CheckExistenceResponder(resp) 68 if err != nil { 69 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CheckExistence", resp, "Failure responding to request") 70 } 71 72 return 73} 74 75// CheckExistencePreparer prepares the CheckExistence request. 76func (client GroupsClient) CheckExistencePreparer(resourceGroupName string) (*http.Request, error) { 77 pathParameters := map[string]interface{}{ 78 "resourceGroupName": autorest.Encode("path", resourceGroupName), 79 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 80 } 81 82 const APIVersion = "2017-05-10" 83 queryParameters := map[string]interface{}{ 84 "api-version": APIVersion, 85 } 86 87 preparer := autorest.CreatePreparer( 88 autorest.AsHead(), 89 autorest.WithBaseURL(client.BaseURI), 90 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), 91 autorest.WithQueryParameters(queryParameters)) 92 return preparer.Prepare(&http.Request{}) 93} 94 95// CheckExistenceSender sends the CheckExistence request. The method will close the 96// http.Response Body if it receives an error. 97func (client GroupsClient) CheckExistenceSender(req *http.Request) (*http.Response, error) { 98 return autorest.SendWithSender(client, 99 req, 100 azure.DoRetryWithRegistration(client.Client)) 101} 102 103// CheckExistenceResponder handles the response to the CheckExistence request. The method always 104// closes the http.Response Body. 105func (client GroupsClient) CheckExistenceResponder(resp *http.Response) (result autorest.Response, err error) { 106 err = autorest.Respond( 107 resp, 108 client.ByInspecting(), 109 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent, http.StatusNotFound), 110 autorest.ByClosing()) 111 result.Response = resp 112 return 113} 114 115// CreateOrUpdate creates or updates a resource group. 116// 117// resourceGroupName is the name of the resource group to create or update. parameters is parameters supplied to the 118// create or update a resource group. 119func (client GroupsClient) CreateOrUpdate(resourceGroupName string, parameters Group) (result Group, err error) { 120 if err := validation.Validate([]validation.Validation{ 121 {TargetValue: resourceGroupName, 122 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 123 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 124 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}, 125 {TargetValue: parameters, 126 Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 127 return result, validation.NewErrorWithValidationError(err, "resources.GroupsClient", "CreateOrUpdate") 128 } 129 130 req, err := client.CreateOrUpdatePreparer(resourceGroupName, parameters) 131 if err != nil { 132 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", nil, "Failure preparing request") 133 return 134 } 135 136 resp, err := client.CreateOrUpdateSender(req) 137 if err != nil { 138 result.Response = autorest.Response{Response: resp} 139 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", resp, "Failure sending request") 140 return 141 } 142 143 result, err = client.CreateOrUpdateResponder(resp) 144 if err != nil { 145 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "CreateOrUpdate", resp, "Failure responding to request") 146 } 147 148 return 149} 150 151// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 152func (client GroupsClient) CreateOrUpdatePreparer(resourceGroupName string, parameters Group) (*http.Request, error) { 153 pathParameters := map[string]interface{}{ 154 "resourceGroupName": autorest.Encode("path", resourceGroupName), 155 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 156 } 157 158 const APIVersion = "2017-05-10" 159 queryParameters := map[string]interface{}{ 160 "api-version": APIVersion, 161 } 162 163 preparer := autorest.CreatePreparer( 164 autorest.AsJSON(), 165 autorest.AsPut(), 166 autorest.WithBaseURL(client.BaseURI), 167 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), 168 autorest.WithJSON(parameters), 169 autorest.WithQueryParameters(queryParameters)) 170 return preparer.Prepare(&http.Request{}) 171} 172 173// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 174// http.Response Body if it receives an error. 175func (client GroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 176 return autorest.SendWithSender(client, 177 req, 178 azure.DoRetryWithRegistration(client.Client)) 179} 180 181// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 182// closes the http.Response Body. 183func (client GroupsClient) CreateOrUpdateResponder(resp *http.Response) (result Group, err error) { 184 err = autorest.Respond( 185 resp, 186 client.ByInspecting(), 187 azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), 188 autorest.ByUnmarshallingJSON(&result), 189 autorest.ByClosing()) 190 result.Response = autorest.Response{Response: resp} 191 return 192} 193 194// Delete when you delete a resource group, all of its resources are also deleted. Deleting a resource group deletes 195// all of its template deployments and currently stored operations. This method may poll for completion. Polling can be 196// canceled by passing the cancel channel argument. The channel will be used to cancel polling and any outstanding HTTP 197// requests. 198// 199// resourceGroupName is the name of the resource group to delete. The name is case insensitive. 200func (client GroupsClient) Delete(resourceGroupName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) { 201 resultChan := make(chan autorest.Response, 1) 202 errChan := make(chan error, 1) 203 if err := validation.Validate([]validation.Validation{ 204 {TargetValue: resourceGroupName, 205 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 206 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 207 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 208 errChan <- validation.NewErrorWithValidationError(err, "resources.GroupsClient", "Delete") 209 close(errChan) 210 close(resultChan) 211 return resultChan, errChan 212 } 213 214 go func() { 215 var err error 216 var result autorest.Response 217 defer func() { 218 if err != nil { 219 errChan <- err 220 } 221 resultChan <- result 222 close(resultChan) 223 close(errChan) 224 }() 225 req, err := client.DeletePreparer(resourceGroupName, cancel) 226 if err != nil { 227 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", nil, "Failure preparing request") 228 return 229 } 230 231 resp, err := client.DeleteSender(req) 232 if err != nil { 233 result.Response = resp 234 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", resp, "Failure sending request") 235 return 236 } 237 238 result, err = client.DeleteResponder(resp) 239 if err != nil { 240 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Delete", resp, "Failure responding to request") 241 } 242 }() 243 return resultChan, errChan 244} 245 246// DeletePreparer prepares the Delete request. 247func (client GroupsClient) DeletePreparer(resourceGroupName string, cancel <-chan struct{}) (*http.Request, error) { 248 pathParameters := map[string]interface{}{ 249 "resourceGroupName": autorest.Encode("path", resourceGroupName), 250 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 251 } 252 253 const APIVersion = "2017-05-10" 254 queryParameters := map[string]interface{}{ 255 "api-version": APIVersion, 256 } 257 258 preparer := autorest.CreatePreparer( 259 autorest.AsDelete(), 260 autorest.WithBaseURL(client.BaseURI), 261 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), 262 autorest.WithQueryParameters(queryParameters)) 263 return preparer.Prepare(&http.Request{Cancel: cancel}) 264} 265 266// DeleteSender sends the Delete request. The method will close the 267// http.Response Body if it receives an error. 268func (client GroupsClient) DeleteSender(req *http.Request) (*http.Response, error) { 269 return autorest.SendWithSender(client, 270 req, 271 azure.DoRetryWithRegistration(client.Client), 272 azure.DoPollForAsynchronous(client.PollingDelay)) 273} 274 275// DeleteResponder handles the response to the Delete request. The method always 276// closes the http.Response Body. 277func (client GroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 278 err = autorest.Respond( 279 resp, 280 client.ByInspecting(), 281 azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), 282 autorest.ByClosing()) 283 result.Response = resp 284 return 285} 286 287// ExportTemplate captures the specified resource group as a template. 288// 289// resourceGroupName is the name of the resource group to export as a template. parameters is parameters for exporting 290// the template. 291func (client GroupsClient) ExportTemplate(resourceGroupName string, parameters ExportTemplateRequest) (result GroupExportResult, err error) { 292 if err := validation.Validate([]validation.Validation{ 293 {TargetValue: resourceGroupName, 294 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 295 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 296 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 297 return result, validation.NewErrorWithValidationError(err, "resources.GroupsClient", "ExportTemplate") 298 } 299 300 req, err := client.ExportTemplatePreparer(resourceGroupName, parameters) 301 if err != nil { 302 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", nil, "Failure preparing request") 303 return 304 } 305 306 resp, err := client.ExportTemplateSender(req) 307 if err != nil { 308 result.Response = autorest.Response{Response: resp} 309 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure sending request") 310 return 311 } 312 313 result, err = client.ExportTemplateResponder(resp) 314 if err != nil { 315 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "ExportTemplate", resp, "Failure responding to request") 316 } 317 318 return 319} 320 321// ExportTemplatePreparer prepares the ExportTemplate request. 322func (client GroupsClient) ExportTemplatePreparer(resourceGroupName string, parameters ExportTemplateRequest) (*http.Request, error) { 323 pathParameters := map[string]interface{}{ 324 "resourceGroupName": autorest.Encode("path", resourceGroupName), 325 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 326 } 327 328 const APIVersion = "2017-05-10" 329 queryParameters := map[string]interface{}{ 330 "api-version": APIVersion, 331 } 332 333 preparer := autorest.CreatePreparer( 334 autorest.AsJSON(), 335 autorest.AsPost(), 336 autorest.WithBaseURL(client.BaseURI), 337 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/exportTemplate", pathParameters), 338 autorest.WithJSON(parameters), 339 autorest.WithQueryParameters(queryParameters)) 340 return preparer.Prepare(&http.Request{}) 341} 342 343// ExportTemplateSender sends the ExportTemplate request. The method will close the 344// http.Response Body if it receives an error. 345func (client GroupsClient) ExportTemplateSender(req *http.Request) (*http.Response, error) { 346 return autorest.SendWithSender(client, 347 req, 348 azure.DoRetryWithRegistration(client.Client)) 349} 350 351// ExportTemplateResponder handles the response to the ExportTemplate request. The method always 352// closes the http.Response Body. 353func (client GroupsClient) ExportTemplateResponder(resp *http.Response) (result GroupExportResult, err error) { 354 err = autorest.Respond( 355 resp, 356 client.ByInspecting(), 357 azure.WithErrorUnlessStatusCode(http.StatusOK), 358 autorest.ByUnmarshallingJSON(&result), 359 autorest.ByClosing()) 360 result.Response = autorest.Response{Response: resp} 361 return 362} 363 364// Get gets a resource group. 365// 366// resourceGroupName is the name of the resource group to get. The name is case insensitive. 367func (client GroupsClient) Get(resourceGroupName string) (result Group, err error) { 368 if err := validation.Validate([]validation.Validation{ 369 {TargetValue: resourceGroupName, 370 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 371 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 372 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 373 return result, validation.NewErrorWithValidationError(err, "resources.GroupsClient", "Get") 374 } 375 376 req, err := client.GetPreparer(resourceGroupName) 377 if err != nil { 378 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", nil, "Failure preparing request") 379 return 380 } 381 382 resp, err := client.GetSender(req) 383 if err != nil { 384 result.Response = autorest.Response{Response: resp} 385 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", resp, "Failure sending request") 386 return 387 } 388 389 result, err = client.GetResponder(resp) 390 if err != nil { 391 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Get", resp, "Failure responding to request") 392 } 393 394 return 395} 396 397// GetPreparer prepares the Get request. 398func (client GroupsClient) GetPreparer(resourceGroupName string) (*http.Request, error) { 399 pathParameters := map[string]interface{}{ 400 "resourceGroupName": autorest.Encode("path", resourceGroupName), 401 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 402 } 403 404 const APIVersion = "2017-05-10" 405 queryParameters := map[string]interface{}{ 406 "api-version": APIVersion, 407 } 408 409 preparer := autorest.CreatePreparer( 410 autorest.AsGet(), 411 autorest.WithBaseURL(client.BaseURI), 412 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), 413 autorest.WithQueryParameters(queryParameters)) 414 return preparer.Prepare(&http.Request{}) 415} 416 417// GetSender sends the Get request. The method will close the 418// http.Response Body if it receives an error. 419func (client GroupsClient) GetSender(req *http.Request) (*http.Response, error) { 420 return autorest.SendWithSender(client, 421 req, 422 azure.DoRetryWithRegistration(client.Client)) 423} 424 425// GetResponder handles the response to the Get request. The method always 426// closes the http.Response Body. 427func (client GroupsClient) GetResponder(resp *http.Response) (result Group, err error) { 428 err = autorest.Respond( 429 resp, 430 client.ByInspecting(), 431 azure.WithErrorUnlessStatusCode(http.StatusOK), 432 autorest.ByUnmarshallingJSON(&result), 433 autorest.ByClosing()) 434 result.Response = autorest.Response{Response: resp} 435 return 436} 437 438// List gets all the resource groups for a subscription. 439// 440// filter is the filter to apply on the operation. top is the number of results to return. If null is passed, returns 441// all resource groups. 442func (client GroupsClient) List(filter string, top *int32) (result GroupListResult, err error) { 443 req, err := client.ListPreparer(filter, top) 444 if err != nil { 445 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", nil, "Failure preparing request") 446 return 447 } 448 449 resp, err := client.ListSender(req) 450 if err != nil { 451 result.Response = autorest.Response{Response: resp} 452 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure sending request") 453 return 454 } 455 456 result, err = client.ListResponder(resp) 457 if err != nil { 458 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure responding to request") 459 } 460 461 return 462} 463 464// ListPreparer prepares the List request. 465func (client GroupsClient) ListPreparer(filter string, top *int32) (*http.Request, error) { 466 pathParameters := map[string]interface{}{ 467 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 468 } 469 470 const APIVersion = "2017-05-10" 471 queryParameters := map[string]interface{}{ 472 "api-version": APIVersion, 473 } 474 if len(filter) > 0 { 475 queryParameters["$filter"] = autorest.Encode("query", filter) 476 } 477 if top != nil { 478 queryParameters["$top"] = autorest.Encode("query", *top) 479 } 480 481 preparer := autorest.CreatePreparer( 482 autorest.AsGet(), 483 autorest.WithBaseURL(client.BaseURI), 484 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups", pathParameters), 485 autorest.WithQueryParameters(queryParameters)) 486 return preparer.Prepare(&http.Request{}) 487} 488 489// ListSender sends the List request. The method will close the 490// http.Response Body if it receives an error. 491func (client GroupsClient) ListSender(req *http.Request) (*http.Response, error) { 492 return autorest.SendWithSender(client, 493 req, 494 azure.DoRetryWithRegistration(client.Client)) 495} 496 497// ListResponder handles the response to the List request. The method always 498// closes the http.Response Body. 499func (client GroupsClient) ListResponder(resp *http.Response) (result GroupListResult, err error) { 500 err = autorest.Respond( 501 resp, 502 client.ByInspecting(), 503 azure.WithErrorUnlessStatusCode(http.StatusOK), 504 autorest.ByUnmarshallingJSON(&result), 505 autorest.ByClosing()) 506 result.Response = autorest.Response{Response: resp} 507 return 508} 509 510// ListNextResults retrieves the next set of results, if any. 511func (client GroupsClient) ListNextResults(lastResults GroupListResult) (result GroupListResult, err error) { 512 req, err := lastResults.GroupListResultPreparer() 513 if err != nil { 514 return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "List", nil, "Failure preparing next results request") 515 } 516 if req == nil { 517 return 518 } 519 520 resp, err := client.ListSender(req) 521 if err != nil { 522 result.Response = autorest.Response{Response: resp} 523 return result, autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure sending next results request") 524 } 525 526 result, err = client.ListResponder(resp) 527 if err != nil { 528 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "List", resp, "Failure responding to next results request") 529 } 530 531 return 532} 533 534// ListComplete gets all elements from the list without paging. 535func (client GroupsClient) ListComplete(filter string, top *int32, cancel <-chan struct{}) (<-chan Group, <-chan error) { 536 resultChan := make(chan Group) 537 errChan := make(chan error, 1) 538 go func() { 539 defer func() { 540 close(resultChan) 541 close(errChan) 542 }() 543 list, err := client.List(filter, top) 544 if err != nil { 545 errChan <- err 546 return 547 } 548 if list.Value != nil { 549 for _, item := range *list.Value { 550 select { 551 case <-cancel: 552 return 553 case resultChan <- item: 554 // Intentionally left blank 555 } 556 } 557 } 558 for list.NextLink != nil { 559 list, err = client.ListNextResults(list) 560 if err != nil { 561 errChan <- err 562 return 563 } 564 if list.Value != nil { 565 for _, item := range *list.Value { 566 select { 567 case <-cancel: 568 return 569 case resultChan <- item: 570 // Intentionally left blank 571 } 572 } 573 } 574 } 575 }() 576 return resultChan, errChan 577} 578 579// Update resource groups can be updated through a simple PATCH operation to a group address. The format of the request 580// is the same as that for creating a resource group. If a field is unspecified, the current value is retained. 581// 582// resourceGroupName is the name of the resource group to update. The name is case insensitive. parameters is 583// parameters supplied to update a resource group. 584func (client GroupsClient) Update(resourceGroupName string, parameters GroupPatchable) (result Group, err error) { 585 if err := validation.Validate([]validation.Validation{ 586 {TargetValue: resourceGroupName, 587 Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, 588 {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}, 589 {Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil { 590 return result, validation.NewErrorWithValidationError(err, "resources.GroupsClient", "Update") 591 } 592 593 req, err := client.UpdatePreparer(resourceGroupName, parameters) 594 if err != nil { 595 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Update", nil, "Failure preparing request") 596 return 597 } 598 599 resp, err := client.UpdateSender(req) 600 if err != nil { 601 result.Response = autorest.Response{Response: resp} 602 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Update", resp, "Failure sending request") 603 return 604 } 605 606 result, err = client.UpdateResponder(resp) 607 if err != nil { 608 err = autorest.NewErrorWithError(err, "resources.GroupsClient", "Update", resp, "Failure responding to request") 609 } 610 611 return 612} 613 614// UpdatePreparer prepares the Update request. 615func (client GroupsClient) UpdatePreparer(resourceGroupName string, parameters GroupPatchable) (*http.Request, error) { 616 pathParameters := map[string]interface{}{ 617 "resourceGroupName": autorest.Encode("path", resourceGroupName), 618 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 619 } 620 621 const APIVersion = "2017-05-10" 622 queryParameters := map[string]interface{}{ 623 "api-version": APIVersion, 624 } 625 626 preparer := autorest.CreatePreparer( 627 autorest.AsJSON(), 628 autorest.AsPatch(), 629 autorest.WithBaseURL(client.BaseURI), 630 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}", pathParameters), 631 autorest.WithJSON(parameters), 632 autorest.WithQueryParameters(queryParameters)) 633 return preparer.Prepare(&http.Request{}) 634} 635 636// UpdateSender sends the Update request. The method will close the 637// http.Response Body if it receives an error. 638func (client GroupsClient) UpdateSender(req *http.Request) (*http.Response, error) { 639 return autorest.SendWithSender(client, 640 req, 641 azure.DoRetryWithRegistration(client.Client)) 642} 643 644// UpdateResponder handles the response to the Update request. The method always 645// closes the http.Response Body. 646func (client GroupsClient) UpdateResponder(resp *http.Response) (result Group, err error) { 647 err = autorest.Respond( 648 resp, 649 client.ByInspecting(), 650 azure.WithErrorUnlessStatusCode(http.StatusOK), 651 autorest.ByUnmarshallingJSON(&result), 652 autorest.ByClosing()) 653 result.Response = autorest.Response{Response: resp} 654 return 655} 656