1package experimentation 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// AccountsClient is the these APIs allow end users to operate on Azure Machine Learning Team Account resources. They 19// support CRUD operations for Azure Machine Learning Team Accounts. 20type AccountsClient struct { 21 BaseClient 22} 23 24// NewAccountsClient creates an instance of the AccountsClient client. 25func NewAccountsClient(subscriptionID string) AccountsClient { 26 return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) 27} 28 29// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client using a custom endpoint. Use this 30// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 31func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { 32 return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} 33} 34 35// CreateOrUpdate creates or updates a team account with the specified parameters. 36// Parameters: 37// resourceGroupName - the name of the resource group to which the machine learning team account belongs. 38// accountName - the name of the machine learning team account. 39// parameters - the parameters for creating or updating a machine learning team account. 40func (client AccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, accountName string, parameters Account) (result Account, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.CreateOrUpdate") 43 defer func() { 44 sc := -1 45 if result.Response.Response != nil { 46 sc = result.Response.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: accountName, 53 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 54 {Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil}, 55 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, 56 {TargetValue: parameters, 57 Constraints: []validation.Constraint{{Target: "parameters.AccountProperties", Name: validation.Null, Rule: false, 58 Chain: []validation.Constraint{{Target: "parameters.AccountProperties.VsoAccountID", Name: validation.Null, Rule: true, Chain: nil}, 59 {Target: "parameters.AccountProperties.KeyVaultID", Name: validation.Null, Rule: true, Chain: nil}, 60 {Target: "parameters.AccountProperties.StorageAccount", Name: validation.Null, Rule: true, 61 Chain: []validation.Constraint{{Target: "parameters.AccountProperties.StorageAccount.StorageAccountID", Name: validation.Null, Rule: true, Chain: nil}, 62 {Target: "parameters.AccountProperties.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, 63 }}, 64 }}}}}); err != nil { 65 return result, validation.NewError("experimentation.AccountsClient", "CreateOrUpdate", err.Error()) 66 } 67 68 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, accountName, parameters) 69 if err != nil { 70 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "CreateOrUpdate", nil, "Failure preparing request") 71 return 72 } 73 74 resp, err := client.CreateOrUpdateSender(req) 75 if err != nil { 76 result.Response = autorest.Response{Response: resp} 77 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "CreateOrUpdate", resp, "Failure sending request") 78 return 79 } 80 81 result, err = client.CreateOrUpdateResponder(resp) 82 if err != nil { 83 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "CreateOrUpdate", resp, "Failure responding to request") 84 return 85 } 86 87 return 88} 89 90// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 91func (client AccountsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters Account) (*http.Request, error) { 92 pathParameters := map[string]interface{}{ 93 "accountName": autorest.Encode("path", accountName), 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 96 } 97 98 const APIVersion = "2017-05-01-preview" 99 queryParameters := map[string]interface{}{ 100 "api-version": APIVersion, 101 } 102 103 preparer := autorest.CreatePreparer( 104 autorest.AsContentType("application/json; charset=utf-8"), 105 autorest.AsPut(), 106 autorest.WithBaseURL(client.BaseURI), 107 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}", pathParameters), 108 autorest.WithJSON(parameters), 109 autorest.WithQueryParameters(queryParameters)) 110 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 111} 112 113// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 114// http.Response Body if it receives an error. 115func (client AccountsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 116 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 117} 118 119// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 120// closes the http.Response Body. 121func (client AccountsClient) CreateOrUpdateResponder(resp *http.Response) (result Account, err error) { 122 err = autorest.Respond( 123 resp, 124 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 125 autorest.ByUnmarshallingJSON(&result), 126 autorest.ByClosing()) 127 result.Response = autorest.Response{Response: resp} 128 return 129} 130 131// Delete deletes a machine learning team account. 132// Parameters: 133// resourceGroupName - the name of the resource group to which the machine learning team account belongs. 134// accountName - the name of the machine learning team account. 135func (client AccountsClient) Delete(ctx context.Context, resourceGroupName string, accountName string) (result autorest.Response, err error) { 136 if tracing.IsEnabled() { 137 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Delete") 138 defer func() { 139 sc := -1 140 if result.Response != nil { 141 sc = result.Response.StatusCode 142 } 143 tracing.EndSpan(ctx, sc, err) 144 }() 145 } 146 if err := validation.Validate([]validation.Validation{ 147 {TargetValue: accountName, 148 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 149 {Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil}, 150 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 151 return result, validation.NewError("experimentation.AccountsClient", "Delete", err.Error()) 152 } 153 154 req, err := client.DeletePreparer(ctx, resourceGroupName, accountName) 155 if err != nil { 156 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Delete", nil, "Failure preparing request") 157 return 158 } 159 160 resp, err := client.DeleteSender(req) 161 if err != nil { 162 result.Response = resp 163 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Delete", resp, "Failure sending request") 164 return 165 } 166 167 result, err = client.DeleteResponder(resp) 168 if err != nil { 169 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Delete", resp, "Failure responding to request") 170 return 171 } 172 173 return 174} 175 176// DeletePreparer prepares the Delete request. 177func (client AccountsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 178 pathParameters := map[string]interface{}{ 179 "accountName": autorest.Encode("path", accountName), 180 "resourceGroupName": autorest.Encode("path", resourceGroupName), 181 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 182 } 183 184 const APIVersion = "2017-05-01-preview" 185 queryParameters := map[string]interface{}{ 186 "api-version": APIVersion, 187 } 188 189 preparer := autorest.CreatePreparer( 190 autorest.AsDelete(), 191 autorest.WithBaseURL(client.BaseURI), 192 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}", pathParameters), 193 autorest.WithQueryParameters(queryParameters)) 194 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 195} 196 197// DeleteSender sends the Delete request. The method will close the 198// http.Response Body if it receives an error. 199func (client AccountsClient) DeleteSender(req *http.Request) (*http.Response, error) { 200 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 201} 202 203// DeleteResponder handles the response to the Delete request. The method always 204// closes the http.Response Body. 205func (client AccountsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 206 err = autorest.Respond( 207 resp, 208 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 209 autorest.ByClosing()) 210 result.Response = resp 211 return 212} 213 214// Get gets the properties of the specified machine learning team account. 215// Parameters: 216// resourceGroupName - the name of the resource group to which the machine learning team account belongs. 217// accountName - the name of the machine learning team account. 218func (client AccountsClient) Get(ctx context.Context, resourceGroupName string, accountName string) (result Account, err error) { 219 if tracing.IsEnabled() { 220 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get") 221 defer func() { 222 sc := -1 223 if result.Response.Response != nil { 224 sc = result.Response.Response.StatusCode 225 } 226 tracing.EndSpan(ctx, sc, err) 227 }() 228 } 229 if err := validation.Validate([]validation.Validation{ 230 {TargetValue: accountName, 231 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 232 {Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil}, 233 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 234 return result, validation.NewError("experimentation.AccountsClient", "Get", err.Error()) 235 } 236 237 req, err := client.GetPreparer(ctx, resourceGroupName, accountName) 238 if err != nil { 239 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Get", nil, "Failure preparing request") 240 return 241 } 242 243 resp, err := client.GetSender(req) 244 if err != nil { 245 result.Response = autorest.Response{Response: resp} 246 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Get", resp, "Failure sending request") 247 return 248 } 249 250 result, err = client.GetResponder(resp) 251 if err != nil { 252 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Get", resp, "Failure responding to request") 253 return 254 } 255 256 return 257} 258 259// GetPreparer prepares the Get request. 260func (client AccountsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountName string) (*http.Request, error) { 261 pathParameters := map[string]interface{}{ 262 "accountName": autorest.Encode("path", accountName), 263 "resourceGroupName": autorest.Encode("path", resourceGroupName), 264 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 265 } 266 267 const APIVersion = "2017-05-01-preview" 268 queryParameters := map[string]interface{}{ 269 "api-version": APIVersion, 270 } 271 272 preparer := autorest.CreatePreparer( 273 autorest.AsGet(), 274 autorest.WithBaseURL(client.BaseURI), 275 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}", pathParameters), 276 autorest.WithQueryParameters(queryParameters)) 277 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 278} 279 280// GetSender sends the Get request. The method will close the 281// http.Response Body if it receives an error. 282func (client AccountsClient) GetSender(req *http.Request) (*http.Response, error) { 283 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 284} 285 286// GetResponder handles the response to the Get request. The method always 287// closes the http.Response Body. 288func (client AccountsClient) GetResponder(resp *http.Response) (result Account, err error) { 289 err = autorest.Respond( 290 resp, 291 azure.WithErrorUnlessStatusCode(http.StatusOK), 292 autorest.ByUnmarshallingJSON(&result), 293 autorest.ByClosing()) 294 result.Response = autorest.Response{Response: resp} 295 return 296} 297 298// List lists all the available machine learning team accounts under the specified subscription. 299func (client AccountsClient) List(ctx context.Context) (result AccountListResultPage, err error) { 300 if tracing.IsEnabled() { 301 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List") 302 defer func() { 303 sc := -1 304 if result.alr.Response.Response != nil { 305 sc = result.alr.Response.Response.StatusCode 306 } 307 tracing.EndSpan(ctx, sc, err) 308 }() 309 } 310 result.fn = client.listNextResults 311 req, err := client.ListPreparer(ctx) 312 if err != nil { 313 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "List", nil, "Failure preparing request") 314 return 315 } 316 317 resp, err := client.ListSender(req) 318 if err != nil { 319 result.alr.Response = autorest.Response{Response: resp} 320 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "List", resp, "Failure sending request") 321 return 322 } 323 324 result.alr, err = client.ListResponder(resp) 325 if err != nil { 326 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "List", resp, "Failure responding to request") 327 return 328 } 329 if result.alr.hasNextLink() && result.alr.IsEmpty() { 330 err = result.NextWithContext(ctx) 331 return 332 } 333 334 return 335} 336 337// ListPreparer prepares the List request. 338func (client AccountsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 339 pathParameters := map[string]interface{}{ 340 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 341 } 342 343 const APIVersion = "2017-05-01-preview" 344 queryParameters := map[string]interface{}{ 345 "api-version": APIVersion, 346 } 347 348 preparer := autorest.CreatePreparer( 349 autorest.AsGet(), 350 autorest.WithBaseURL(client.BaseURI), 351 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.MachineLearningExperimentation/accounts", pathParameters), 352 autorest.WithQueryParameters(queryParameters)) 353 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 354} 355 356// ListSender sends the List request. The method will close the 357// http.Response Body if it receives an error. 358func (client AccountsClient) ListSender(req *http.Request) (*http.Response, error) { 359 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 360} 361 362// ListResponder handles the response to the List request. The method always 363// closes the http.Response Body. 364func (client AccountsClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { 365 err = autorest.Respond( 366 resp, 367 azure.WithErrorUnlessStatusCode(http.StatusOK), 368 autorest.ByUnmarshallingJSON(&result), 369 autorest.ByClosing()) 370 result.Response = autorest.Response{Response: resp} 371 return 372} 373 374// listNextResults retrieves the next set of results, if any. 375func (client AccountsClient) listNextResults(ctx context.Context, lastResults AccountListResult) (result AccountListResult, err error) { 376 req, err := lastResults.accountListResultPreparer(ctx) 377 if err != nil { 378 return result, autorest.NewErrorWithError(err, "experimentation.AccountsClient", "listNextResults", nil, "Failure preparing next results request") 379 } 380 if req == nil { 381 return 382 } 383 resp, err := client.ListSender(req) 384 if err != nil { 385 result.Response = autorest.Response{Response: resp} 386 return result, autorest.NewErrorWithError(err, "experimentation.AccountsClient", "listNextResults", resp, "Failure sending next results request") 387 } 388 result, err = client.ListResponder(resp) 389 if err != nil { 390 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "listNextResults", resp, "Failure responding to next results request") 391 } 392 return 393} 394 395// ListComplete enumerates all values, automatically crossing page boundaries as required. 396func (client AccountsClient) ListComplete(ctx context.Context) (result AccountListResultIterator, err error) { 397 if tracing.IsEnabled() { 398 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List") 399 defer func() { 400 sc := -1 401 if result.Response().Response.Response != nil { 402 sc = result.page.Response().Response.Response.StatusCode 403 } 404 tracing.EndSpan(ctx, sc, err) 405 }() 406 } 407 result.page, err = client.List(ctx) 408 return 409} 410 411// ListByResourceGroup lists all the available machine learning team accounts under the specified resource group. 412// Parameters: 413// resourceGroupName - the name of the resource group to which the machine learning team account belongs. 414func (client AccountsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result AccountListResultPage, err error) { 415 if tracing.IsEnabled() { 416 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup") 417 defer func() { 418 sc := -1 419 if result.alr.Response.Response != nil { 420 sc = result.alr.Response.Response.StatusCode 421 } 422 tracing.EndSpan(ctx, sc, err) 423 }() 424 } 425 result.fn = client.listByResourceGroupNextResults 426 req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) 427 if err != nil { 428 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") 429 return 430 } 431 432 resp, err := client.ListByResourceGroupSender(req) 433 if err != nil { 434 result.alr.Response = autorest.Response{Response: resp} 435 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") 436 return 437 } 438 439 result.alr, err = client.ListByResourceGroupResponder(resp) 440 if err != nil { 441 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "ListByResourceGroup", resp, "Failure responding to request") 442 return 443 } 444 if result.alr.hasNextLink() && result.alr.IsEmpty() { 445 err = result.NextWithContext(ctx) 446 return 447 } 448 449 return 450} 451 452// ListByResourceGroupPreparer prepares the ListByResourceGroup request. 453func (client AccountsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { 454 pathParameters := map[string]interface{}{ 455 "resourceGroupName": autorest.Encode("path", resourceGroupName), 456 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 457 } 458 459 const APIVersion = "2017-05-01-preview" 460 queryParameters := map[string]interface{}{ 461 "api-version": APIVersion, 462 } 463 464 preparer := autorest.CreatePreparer( 465 autorest.AsGet(), 466 autorest.WithBaseURL(client.BaseURI), 467 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts", pathParameters), 468 autorest.WithQueryParameters(queryParameters)) 469 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 470} 471 472// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the 473// http.Response Body if it receives an error. 474func (client AccountsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { 475 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 476} 477 478// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always 479// closes the http.Response Body. 480func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (result AccountListResult, err error) { 481 err = autorest.Respond( 482 resp, 483 azure.WithErrorUnlessStatusCode(http.StatusOK), 484 autorest.ByUnmarshallingJSON(&result), 485 autorest.ByClosing()) 486 result.Response = autorest.Response{Response: resp} 487 return 488} 489 490// listByResourceGroupNextResults retrieves the next set of results, if any. 491func (client AccountsClient) listByResourceGroupNextResults(ctx context.Context, lastResults AccountListResult) (result AccountListResult, err error) { 492 req, err := lastResults.accountListResultPreparer(ctx) 493 if err != nil { 494 return result, autorest.NewErrorWithError(err, "experimentation.AccountsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") 495 } 496 if req == nil { 497 return 498 } 499 resp, err := client.ListByResourceGroupSender(req) 500 if err != nil { 501 result.Response = autorest.Response{Response: resp} 502 return result, autorest.NewErrorWithError(err, "experimentation.AccountsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") 503 } 504 result, err = client.ListByResourceGroupResponder(resp) 505 if err != nil { 506 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") 507 } 508 return 509} 510 511// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. 512func (client AccountsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result AccountListResultIterator, err error) { 513 if tracing.IsEnabled() { 514 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListByResourceGroup") 515 defer func() { 516 sc := -1 517 if result.Response().Response.Response != nil { 518 sc = result.page.Response().Response.Response.StatusCode 519 } 520 tracing.EndSpan(ctx, sc, err) 521 }() 522 } 523 result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) 524 return 525} 526 527// Update updates a machine learning team account with the specified parameters. 528// Parameters: 529// resourceGroupName - the name of the resource group to which the machine learning team account belongs. 530// accountName - the name of the machine learning team account. 531// parameters - the parameters for updating a machine learning team account. 532func (client AccountsClient) Update(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) { 533 if tracing.IsEnabled() { 534 ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") 535 defer func() { 536 sc := -1 537 if result.Response.Response != nil { 538 sc = result.Response.Response.StatusCode 539 } 540 tracing.EndSpan(ctx, sc, err) 541 }() 542 } 543 if err := validation.Validate([]validation.Validation{ 544 {TargetValue: accountName, 545 Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 546 {Target: "accountName", Name: validation.MinLength, Rule: 5, Chain: nil}, 547 {Target: "accountName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { 548 return result, validation.NewError("experimentation.AccountsClient", "Update", err.Error()) 549 } 550 551 req, err := client.UpdatePreparer(ctx, resourceGroupName, accountName, parameters) 552 if err != nil { 553 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Update", nil, "Failure preparing request") 554 return 555 } 556 557 resp, err := client.UpdateSender(req) 558 if err != nil { 559 result.Response = autorest.Response{Response: resp} 560 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Update", resp, "Failure sending request") 561 return 562 } 563 564 result, err = client.UpdateResponder(resp) 565 if err != nil { 566 err = autorest.NewErrorWithError(err, "experimentation.AccountsClient", "Update", resp, "Failure responding to request") 567 return 568 } 569 570 return 571} 572 573// UpdatePreparer prepares the Update request. 574func (client AccountsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, accountName string, parameters AccountUpdateParameters) (*http.Request, error) { 575 pathParameters := map[string]interface{}{ 576 "accountName": autorest.Encode("path", accountName), 577 "resourceGroupName": autorest.Encode("path", resourceGroupName), 578 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 579 } 580 581 const APIVersion = "2017-05-01-preview" 582 queryParameters := map[string]interface{}{ 583 "api-version": APIVersion, 584 } 585 586 preparer := autorest.CreatePreparer( 587 autorest.AsContentType("application/json; charset=utf-8"), 588 autorest.AsPatch(), 589 autorest.WithBaseURL(client.BaseURI), 590 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningExperimentation/accounts/{accountName}", pathParameters), 591 autorest.WithJSON(parameters), 592 autorest.WithQueryParameters(queryParameters)) 593 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 594} 595 596// UpdateSender sends the Update request. The method will close the 597// http.Response Body if it receives an error. 598func (client AccountsClient) UpdateSender(req *http.Request) (*http.Response, error) { 599 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 600} 601 602// UpdateResponder handles the response to the Update request. The method always 603// closes the http.Response Body. 604func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { 605 err = autorest.Respond( 606 resp, 607 azure.WithErrorUnlessStatusCode(http.StatusOK), 608 autorest.ByUnmarshallingJSON(&result), 609 autorest.ByClosing()) 610 result.Response = autorest.Response{Response: resp} 611 return 612} 613