1package migrate 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/tracing" 25 "net/http" 26) 27 28// SolutionsClient is the migrate your workloads to Azure. 29type SolutionsClient struct { 30 BaseClient 31} 32 33// NewSolutionsClient creates an instance of the SolutionsClient client. 34func NewSolutionsClient(subscriptionID string, acceptLanguage string) SolutionsClient { 35 return NewSolutionsClientWithBaseURI(DefaultBaseURI, subscriptionID, acceptLanguage) 36} 37 38// NewSolutionsClientWithBaseURI creates an instance of the SolutionsClient client. 39func NewSolutionsClientWithBaseURI(baseURI string, subscriptionID string, acceptLanguage string) SolutionsClient { 40 return SolutionsClient{NewWithBaseURI(baseURI, subscriptionID, acceptLanguage)} 41} 42 43// CleanupSolutionData sends the cleanup solution data request. 44// Parameters: 45// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 46// migrateProjectName - name of the Azure Migrate project. 47// solutionName - unique name of a migration solution within a migrate project. 48func (client SolutionsClient) CleanupSolutionData(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (result autorest.Response, err error) { 49 if tracing.IsEnabled() { 50 ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.CleanupSolutionData") 51 defer func() { 52 sc := -1 53 if result.Response != nil { 54 sc = result.Response.StatusCode 55 } 56 tracing.EndSpan(ctx, sc, err) 57 }() 58 } 59 req, err := client.CleanupSolutionDataPreparer(ctx, resourceGroupName, migrateProjectName, solutionName) 60 if err != nil { 61 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "CleanupSolutionData", nil, "Failure preparing request") 62 return 63 } 64 65 resp, err := client.CleanupSolutionDataSender(req) 66 if err != nil { 67 result.Response = resp 68 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "CleanupSolutionData", resp, "Failure sending request") 69 return 70 } 71 72 result, err = client.CleanupSolutionDataResponder(resp) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "CleanupSolutionData", resp, "Failure responding to request") 75 } 76 77 return 78} 79 80// CleanupSolutionDataPreparer prepares the CleanupSolutionData request. 81func (client SolutionsClient) CleanupSolutionDataPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (*http.Request, error) { 82 pathParameters := map[string]interface{}{ 83 "migrateProjectName": autorest.Encode("path", migrateProjectName), 84 "resourceGroupName": autorest.Encode("path", resourceGroupName), 85 "solutionName": autorest.Encode("path", solutionName), 86 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 87 } 88 89 const APIVersion = "2018-09-01-preview" 90 queryParameters := map[string]interface{}{ 91 "api-version": APIVersion, 92 } 93 94 preparer := autorest.CreatePreparer( 95 autorest.AsPost(), 96 autorest.WithBaseURL(client.BaseURI), 97 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/solutions/{solutionName}/cleanupData", pathParameters), 98 autorest.WithQueryParameters(queryParameters)) 99 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 100} 101 102// CleanupSolutionDataSender sends the CleanupSolutionData request. The method will close the 103// http.Response Body if it receives an error. 104func (client SolutionsClient) CleanupSolutionDataSender(req *http.Request) (*http.Response, error) { 105 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 106 return autorest.SendWithSender(client, req, sd...) 107} 108 109// CleanupSolutionDataResponder handles the response to the CleanupSolutionData request. The method always 110// closes the http.Response Body. 111func (client SolutionsClient) CleanupSolutionDataResponder(resp *http.Response) (result autorest.Response, err error) { 112 err = autorest.Respond( 113 resp, 114 client.ByInspecting(), 115 azure.WithErrorUnlessStatusCode(http.StatusOK), 116 autorest.ByClosing()) 117 result.Response = resp 118 return 119} 120 121// DeleteSolution delete the solution. Deleting non-existent project is a no-operation. 122// Parameters: 123// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 124// migrateProjectName - name of the Azure Migrate project. 125// solutionName - unique name of a migration solution within a migrate project. 126func (client SolutionsClient) DeleteSolution(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (result autorest.Response, err error) { 127 if tracing.IsEnabled() { 128 ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.DeleteSolution") 129 defer func() { 130 sc := -1 131 if result.Response != nil { 132 sc = result.Response.StatusCode 133 } 134 tracing.EndSpan(ctx, sc, err) 135 }() 136 } 137 req, err := client.DeleteSolutionPreparer(ctx, resourceGroupName, migrateProjectName, solutionName) 138 if err != nil { 139 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "DeleteSolution", nil, "Failure preparing request") 140 return 141 } 142 143 resp, err := client.DeleteSolutionSender(req) 144 if err != nil { 145 result.Response = resp 146 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "DeleteSolution", resp, "Failure sending request") 147 return 148 } 149 150 result, err = client.DeleteSolutionResponder(resp) 151 if err != nil { 152 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "DeleteSolution", resp, "Failure responding to request") 153 } 154 155 return 156} 157 158// DeleteSolutionPreparer prepares the DeleteSolution request. 159func (client SolutionsClient) DeleteSolutionPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (*http.Request, error) { 160 pathParameters := map[string]interface{}{ 161 "migrateProjectName": autorest.Encode("path", migrateProjectName), 162 "resourceGroupName": autorest.Encode("path", resourceGroupName), 163 "solutionName": autorest.Encode("path", solutionName), 164 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 165 } 166 167 const APIVersion = "2018-09-01-preview" 168 queryParameters := map[string]interface{}{ 169 "api-version": APIVersion, 170 } 171 172 preparer := autorest.CreatePreparer( 173 autorest.AsDelete(), 174 autorest.WithBaseURL(client.BaseURI), 175 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/solutions/{solutionName}", pathParameters), 176 autorest.WithQueryParameters(queryParameters)) 177 if len(client.AcceptLanguage) > 0 { 178 preparer = autorest.DecoratePreparer(preparer, 179 autorest.WithHeader("Accept-Language", autorest.String(client.AcceptLanguage))) 180 } 181 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 182} 183 184// DeleteSolutionSender sends the DeleteSolution request. The method will close the 185// http.Response Body if it receives an error. 186func (client SolutionsClient) DeleteSolutionSender(req *http.Request) (*http.Response, error) { 187 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 188 return autorest.SendWithSender(client, req, sd...) 189} 190 191// DeleteSolutionResponder handles the response to the DeleteSolution request. The method always 192// closes the http.Response Body. 193func (client SolutionsClient) DeleteSolutionResponder(resp *http.Response) (result autorest.Response, err error) { 194 err = autorest.Respond( 195 resp, 196 client.ByInspecting(), 197 azure.WithErrorUnlessStatusCode(http.StatusOK), 198 autorest.ByClosing()) 199 result.Response = resp 200 return 201} 202 203// EnumerateSolutions sends the enumerate solutions request. 204// Parameters: 205// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 206// migrateProjectName - name of the Azure Migrate project. 207func (client SolutionsClient) EnumerateSolutions(ctx context.Context, resourceGroupName string, migrateProjectName string) (result SolutionsCollection, err error) { 208 if tracing.IsEnabled() { 209 ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.EnumerateSolutions") 210 defer func() { 211 sc := -1 212 if result.Response.Response != nil { 213 sc = result.Response.Response.StatusCode 214 } 215 tracing.EndSpan(ctx, sc, err) 216 }() 217 } 218 req, err := client.EnumerateSolutionsPreparer(ctx, resourceGroupName, migrateProjectName) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "EnumerateSolutions", nil, "Failure preparing request") 221 return 222 } 223 224 resp, err := client.EnumerateSolutionsSender(req) 225 if err != nil { 226 result.Response = autorest.Response{Response: resp} 227 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "EnumerateSolutions", resp, "Failure sending request") 228 return 229 } 230 231 result, err = client.EnumerateSolutionsResponder(resp) 232 if err != nil { 233 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "EnumerateSolutions", resp, "Failure responding to request") 234 } 235 236 return 237} 238 239// EnumerateSolutionsPreparer prepares the EnumerateSolutions request. 240func (client SolutionsClient) EnumerateSolutionsPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string) (*http.Request, error) { 241 pathParameters := map[string]interface{}{ 242 "migrateProjectName": autorest.Encode("path", migrateProjectName), 243 "resourceGroupName": autorest.Encode("path", resourceGroupName), 244 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 245 } 246 247 const APIVersion = "2018-09-01-preview" 248 queryParameters := map[string]interface{}{ 249 "api-version": APIVersion, 250 } 251 252 preparer := autorest.CreatePreparer( 253 autorest.AsGet(), 254 autorest.WithBaseURL(client.BaseURI), 255 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/solutions", pathParameters), 256 autorest.WithQueryParameters(queryParameters)) 257 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 258} 259 260// EnumerateSolutionsSender sends the EnumerateSolutions request. The method will close the 261// http.Response Body if it receives an error. 262func (client SolutionsClient) EnumerateSolutionsSender(req *http.Request) (*http.Response, error) { 263 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 264 return autorest.SendWithSender(client, req, sd...) 265} 266 267// EnumerateSolutionsResponder handles the response to the EnumerateSolutions request. The method always 268// closes the http.Response Body. 269func (client SolutionsClient) EnumerateSolutionsResponder(resp *http.Response) (result SolutionsCollection, err error) { 270 err = autorest.Respond( 271 resp, 272 client.ByInspecting(), 273 azure.WithErrorUnlessStatusCode(http.StatusOK), 274 autorest.ByUnmarshallingJSON(&result), 275 autorest.ByClosing()) 276 result.Response = autorest.Response{Response: resp} 277 return 278} 279 280// GetConfig sends the get config request. 281// Parameters: 282// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 283// migrateProjectName - name of the Azure Migrate project. 284// solutionName - unique name of a migration solution within a migrate project. 285func (client SolutionsClient) GetConfig(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (result SolutionConfig, err error) { 286 if tracing.IsEnabled() { 287 ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.GetConfig") 288 defer func() { 289 sc := -1 290 if result.Response.Response != nil { 291 sc = result.Response.Response.StatusCode 292 } 293 tracing.EndSpan(ctx, sc, err) 294 }() 295 } 296 req, err := client.GetConfigPreparer(ctx, resourceGroupName, migrateProjectName, solutionName) 297 if err != nil { 298 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "GetConfig", nil, "Failure preparing request") 299 return 300 } 301 302 resp, err := client.GetConfigSender(req) 303 if err != nil { 304 result.Response = autorest.Response{Response: resp} 305 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "GetConfig", resp, "Failure sending request") 306 return 307 } 308 309 result, err = client.GetConfigResponder(resp) 310 if err != nil { 311 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "GetConfig", resp, "Failure responding to request") 312 } 313 314 return 315} 316 317// GetConfigPreparer prepares the GetConfig request. 318func (client SolutionsClient) GetConfigPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (*http.Request, error) { 319 pathParameters := map[string]interface{}{ 320 "migrateProjectName": autorest.Encode("path", migrateProjectName), 321 "resourceGroupName": autorest.Encode("path", resourceGroupName), 322 "solutionName": autorest.Encode("path", solutionName), 323 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 324 } 325 326 const APIVersion = "2018-09-01-preview" 327 queryParameters := map[string]interface{}{ 328 "api-version": APIVersion, 329 } 330 331 preparer := autorest.CreatePreparer( 332 autorest.AsPost(), 333 autorest.WithBaseURL(client.BaseURI), 334 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/solutions/{solutionName}/getConfig", pathParameters), 335 autorest.WithQueryParameters(queryParameters)) 336 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 337} 338 339// GetConfigSender sends the GetConfig request. The method will close the 340// http.Response Body if it receives an error. 341func (client SolutionsClient) GetConfigSender(req *http.Request) (*http.Response, error) { 342 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 343 return autorest.SendWithSender(client, req, sd...) 344} 345 346// GetConfigResponder handles the response to the GetConfig request. The method always 347// closes the http.Response Body. 348func (client SolutionsClient) GetConfigResponder(resp *http.Response) (result SolutionConfig, err error) { 349 err = autorest.Respond( 350 resp, 351 client.ByInspecting(), 352 azure.WithErrorUnlessStatusCode(http.StatusOK), 353 autorest.ByUnmarshallingJSON(&result), 354 autorest.ByClosing()) 355 result.Response = autorest.Response{Response: resp} 356 return 357} 358 359// GetSolution sends the get solution request. 360// Parameters: 361// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 362// migrateProjectName - name of the Azure Migrate project. 363// solutionName - unique name of a migration solution within a migrate project. 364func (client SolutionsClient) GetSolution(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (result Solution, err error) { 365 if tracing.IsEnabled() { 366 ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.GetSolution") 367 defer func() { 368 sc := -1 369 if result.Response.Response != nil { 370 sc = result.Response.Response.StatusCode 371 } 372 tracing.EndSpan(ctx, sc, err) 373 }() 374 } 375 req, err := client.GetSolutionPreparer(ctx, resourceGroupName, migrateProjectName, solutionName) 376 if err != nil { 377 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "GetSolution", nil, "Failure preparing request") 378 return 379 } 380 381 resp, err := client.GetSolutionSender(req) 382 if err != nil { 383 result.Response = autorest.Response{Response: resp} 384 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "GetSolution", resp, "Failure sending request") 385 return 386 } 387 388 result, err = client.GetSolutionResponder(resp) 389 if err != nil { 390 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "GetSolution", resp, "Failure responding to request") 391 } 392 393 return 394} 395 396// GetSolutionPreparer prepares the GetSolution request. 397func (client SolutionsClient) GetSolutionPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string) (*http.Request, error) { 398 pathParameters := map[string]interface{}{ 399 "migrateProjectName": autorest.Encode("path", migrateProjectName), 400 "resourceGroupName": autorest.Encode("path", resourceGroupName), 401 "solutionName": autorest.Encode("path", solutionName), 402 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 403 } 404 405 const APIVersion = "2018-09-01-preview" 406 queryParameters := map[string]interface{}{ 407 "api-version": APIVersion, 408 } 409 410 preparer := autorest.CreatePreparer( 411 autorest.AsGet(), 412 autorest.WithBaseURL(client.BaseURI), 413 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/solutions/{solutionName}", pathParameters), 414 autorest.WithQueryParameters(queryParameters)) 415 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 416} 417 418// GetSolutionSender sends the GetSolution request. The method will close the 419// http.Response Body if it receives an error. 420func (client SolutionsClient) GetSolutionSender(req *http.Request) (*http.Response, error) { 421 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 422 return autorest.SendWithSender(client, req, sd...) 423} 424 425// GetSolutionResponder handles the response to the GetSolution request. The method always 426// closes the http.Response Body. 427func (client SolutionsClient) GetSolutionResponder(resp *http.Response) (result Solution, 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// PatchSolution update a solution with specified name. Supports partial updates, for example only tags can be 439// provided. 440// Parameters: 441// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 442// migrateProjectName - name of the Azure Migrate project. 443// solutionName - unique name of a migration solution within a migrate project. 444// solutionInput - the input for the solution. 445func (client SolutionsClient) PatchSolution(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string, solutionInput Solution) (result Solution, err error) { 446 if tracing.IsEnabled() { 447 ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.PatchSolution") 448 defer func() { 449 sc := -1 450 if result.Response.Response != nil { 451 sc = result.Response.Response.StatusCode 452 } 453 tracing.EndSpan(ctx, sc, err) 454 }() 455 } 456 req, err := client.PatchSolutionPreparer(ctx, resourceGroupName, migrateProjectName, solutionName, solutionInput) 457 if err != nil { 458 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "PatchSolution", nil, "Failure preparing request") 459 return 460 } 461 462 resp, err := client.PatchSolutionSender(req) 463 if err != nil { 464 result.Response = autorest.Response{Response: resp} 465 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "PatchSolution", resp, "Failure sending request") 466 return 467 } 468 469 result, err = client.PatchSolutionResponder(resp) 470 if err != nil { 471 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "PatchSolution", resp, "Failure responding to request") 472 } 473 474 return 475} 476 477// PatchSolutionPreparer prepares the PatchSolution request. 478func (client SolutionsClient) PatchSolutionPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string, solutionInput Solution) (*http.Request, error) { 479 pathParameters := map[string]interface{}{ 480 "migrateProjectName": autorest.Encode("path", migrateProjectName), 481 "resourceGroupName": autorest.Encode("path", resourceGroupName), 482 "solutionName": autorest.Encode("path", solutionName), 483 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 484 } 485 486 const APIVersion = "2018-09-01-preview" 487 queryParameters := map[string]interface{}{ 488 "api-version": APIVersion, 489 } 490 491 solutionInput.ID = nil 492 solutionInput.Name = nil 493 solutionInput.Type = nil 494 preparer := autorest.CreatePreparer( 495 autorest.AsContentType("application/json; charset=utf-8"), 496 autorest.AsPatch(), 497 autorest.WithBaseURL(client.BaseURI), 498 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/solutions/{solutionName}", pathParameters), 499 autorest.WithJSON(solutionInput), 500 autorest.WithQueryParameters(queryParameters)) 501 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 502} 503 504// PatchSolutionSender sends the PatchSolution request. The method will close the 505// http.Response Body if it receives an error. 506func (client SolutionsClient) PatchSolutionSender(req *http.Request) (*http.Response, error) { 507 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 508 return autorest.SendWithSender(client, req, sd...) 509} 510 511// PatchSolutionResponder handles the response to the PatchSolution request. The method always 512// closes the http.Response Body. 513func (client SolutionsClient) PatchSolutionResponder(resp *http.Response) (result Solution, err error) { 514 err = autorest.Respond( 515 resp, 516 client.ByInspecting(), 517 azure.WithErrorUnlessStatusCode(http.StatusOK), 518 autorest.ByUnmarshallingJSON(&result), 519 autorest.ByClosing()) 520 result.Response = autorest.Response{Response: resp} 521 return 522} 523 524// PutSolution sends the put solution request. 525// Parameters: 526// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 527// migrateProjectName - name of the Azure Migrate project. 528// solutionName - unique name of a migration solution within a migrate project. 529// solutionInput - the input for the solution. 530func (client SolutionsClient) PutSolution(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string, solutionInput Solution) (result Solution, err error) { 531 if tracing.IsEnabled() { 532 ctx = tracing.StartSpan(ctx, fqdn+"/SolutionsClient.PutSolution") 533 defer func() { 534 sc := -1 535 if result.Response.Response != nil { 536 sc = result.Response.Response.StatusCode 537 } 538 tracing.EndSpan(ctx, sc, err) 539 }() 540 } 541 req, err := client.PutSolutionPreparer(ctx, resourceGroupName, migrateProjectName, solutionName, solutionInput) 542 if err != nil { 543 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "PutSolution", nil, "Failure preparing request") 544 return 545 } 546 547 resp, err := client.PutSolutionSender(req) 548 if err != nil { 549 result.Response = autorest.Response{Response: resp} 550 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "PutSolution", resp, "Failure sending request") 551 return 552 } 553 554 result, err = client.PutSolutionResponder(resp) 555 if err != nil { 556 err = autorest.NewErrorWithError(err, "migrate.SolutionsClient", "PutSolution", resp, "Failure responding to request") 557 } 558 559 return 560} 561 562// PutSolutionPreparer prepares the PutSolution request. 563func (client SolutionsClient) PutSolutionPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, solutionName string, solutionInput Solution) (*http.Request, error) { 564 pathParameters := map[string]interface{}{ 565 "migrateProjectName": autorest.Encode("path", migrateProjectName), 566 "resourceGroupName": autorest.Encode("path", resourceGroupName), 567 "solutionName": autorest.Encode("path", solutionName), 568 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 569 } 570 571 const APIVersion = "2018-09-01-preview" 572 queryParameters := map[string]interface{}{ 573 "api-version": APIVersion, 574 } 575 576 solutionInput.ID = nil 577 solutionInput.Name = nil 578 solutionInput.Type = nil 579 preparer := autorest.CreatePreparer( 580 autorest.AsContentType("application/json; charset=utf-8"), 581 autorest.AsPut(), 582 autorest.WithBaseURL(client.BaseURI), 583 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/solutions/{solutionName}", pathParameters), 584 autorest.WithJSON(solutionInput), 585 autorest.WithQueryParameters(queryParameters)) 586 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 587} 588 589// PutSolutionSender sends the PutSolution request. The method will close the 590// http.Response Body if it receives an error. 591func (client SolutionsClient) PutSolutionSender(req *http.Request) (*http.Response, error) { 592 sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) 593 return autorest.SendWithSender(client, req, sd...) 594} 595 596// PutSolutionResponder handles the response to the PutSolution request. The method always 597// closes the http.Response Body. 598func (client SolutionsClient) PutSolutionResponder(resp *http.Response) (result Solution, err error) { 599 err = autorest.Respond( 600 resp, 601 client.ByInspecting(), 602 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 603 autorest.ByUnmarshallingJSON(&result), 604 autorest.ByClosing()) 605 result.Response = autorest.Response{Response: resp} 606 return 607} 608