1package migrate 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/tracing" 14 "net/http" 15) 16 17// ProjectsClient is the migrate your workloads to Azure. 18type ProjectsClient struct { 19 BaseClient 20} 21 22// NewProjectsClient creates an instance of the ProjectsClient client. 23func NewProjectsClient(subscriptionID string, acceptLanguage string) ProjectsClient { 24 return NewProjectsClientWithBaseURI(DefaultBaseURI, subscriptionID, acceptLanguage) 25} 26 27// NewProjectsClientWithBaseURI creates an instance of the ProjectsClient client using a custom endpoint. Use this 28// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 29func NewProjectsClientWithBaseURI(baseURI string, subscriptionID string, acceptLanguage string) ProjectsClient { 30 return ProjectsClient{NewWithBaseURI(baseURI, subscriptionID, acceptLanguage)} 31} 32 33// DeleteMigrateProject delete the migrate project. Deleting non-existent project is a no-operation. 34// Parameters: 35// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 36// migrateProjectName - name of the Azure Migrate project. 37func (client ProjectsClient) DeleteMigrateProject(ctx context.Context, resourceGroupName string, migrateProjectName string) (result autorest.Response, err error) { 38 if tracing.IsEnabled() { 39 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.DeleteMigrateProject") 40 defer func() { 41 sc := -1 42 if result.Response != nil { 43 sc = result.Response.StatusCode 44 } 45 tracing.EndSpan(ctx, sc, err) 46 }() 47 } 48 req, err := client.DeleteMigrateProjectPreparer(ctx, resourceGroupName, migrateProjectName) 49 if err != nil { 50 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "DeleteMigrateProject", nil, "Failure preparing request") 51 return 52 } 53 54 resp, err := client.DeleteMigrateProjectSender(req) 55 if err != nil { 56 result.Response = resp 57 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "DeleteMigrateProject", resp, "Failure sending request") 58 return 59 } 60 61 result, err = client.DeleteMigrateProjectResponder(resp) 62 if err != nil { 63 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "DeleteMigrateProject", resp, "Failure responding to request") 64 return 65 } 66 67 return 68} 69 70// DeleteMigrateProjectPreparer prepares the DeleteMigrateProject request. 71func (client ProjectsClient) DeleteMigrateProjectPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string) (*http.Request, error) { 72 pathParameters := map[string]interface{}{ 73 "migrateProjectName": autorest.Encode("path", migrateProjectName), 74 "resourceGroupName": autorest.Encode("path", resourceGroupName), 75 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 76 } 77 78 const APIVersion = "2018-09-01-preview" 79 queryParameters := map[string]interface{}{ 80 "api-version": APIVersion, 81 } 82 83 preparer := autorest.CreatePreparer( 84 autorest.AsDelete(), 85 autorest.WithBaseURL(client.BaseURI), 86 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}", pathParameters), 87 autorest.WithQueryParameters(queryParameters)) 88 if len(client.AcceptLanguage) > 0 { 89 preparer = autorest.DecoratePreparer(preparer, 90 autorest.WithHeader("Accept-Language", autorest.String(client.AcceptLanguage))) 91 } 92 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 93} 94 95// DeleteMigrateProjectSender sends the DeleteMigrateProject request. The method will close the 96// http.Response Body if it receives an error. 97func (client ProjectsClient) DeleteMigrateProjectSender(req *http.Request) (*http.Response, error) { 98 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 99} 100 101// DeleteMigrateProjectResponder handles the response to the DeleteMigrateProject request. The method always 102// closes the http.Response Body. 103func (client ProjectsClient) DeleteMigrateProjectResponder(resp *http.Response) (result autorest.Response, err error) { 104 err = autorest.Respond( 105 resp, 106 azure.WithErrorUnlessStatusCode(http.StatusOK), 107 autorest.ByClosing()) 108 result.Response = resp 109 return 110} 111 112// GetMigrateProject sends the get migrate project request. 113// Parameters: 114// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 115// migrateProjectName - name of the Azure Migrate project. 116func (client ProjectsClient) GetMigrateProject(ctx context.Context, resourceGroupName string, migrateProjectName string) (result Project, err error) { 117 if tracing.IsEnabled() { 118 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.GetMigrateProject") 119 defer func() { 120 sc := -1 121 if result.Response.Response != nil { 122 sc = result.Response.Response.StatusCode 123 } 124 tracing.EndSpan(ctx, sc, err) 125 }() 126 } 127 req, err := client.GetMigrateProjectPreparer(ctx, resourceGroupName, migrateProjectName) 128 if err != nil { 129 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "GetMigrateProject", nil, "Failure preparing request") 130 return 131 } 132 133 resp, err := client.GetMigrateProjectSender(req) 134 if err != nil { 135 result.Response = autorest.Response{Response: resp} 136 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "GetMigrateProject", resp, "Failure sending request") 137 return 138 } 139 140 result, err = client.GetMigrateProjectResponder(resp) 141 if err != nil { 142 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "GetMigrateProject", resp, "Failure responding to request") 143 return 144 } 145 146 return 147} 148 149// GetMigrateProjectPreparer prepares the GetMigrateProject request. 150func (client ProjectsClient) GetMigrateProjectPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string) (*http.Request, error) { 151 pathParameters := map[string]interface{}{ 152 "migrateProjectName": autorest.Encode("path", migrateProjectName), 153 "resourceGroupName": autorest.Encode("path", resourceGroupName), 154 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 155 } 156 157 const APIVersion = "2018-09-01-preview" 158 queryParameters := map[string]interface{}{ 159 "api-version": APIVersion, 160 } 161 162 preparer := autorest.CreatePreparer( 163 autorest.AsGet(), 164 autorest.WithBaseURL(client.BaseURI), 165 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}", pathParameters), 166 autorest.WithQueryParameters(queryParameters)) 167 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 168} 169 170// GetMigrateProjectSender sends the GetMigrateProject request. The method will close the 171// http.Response Body if it receives an error. 172func (client ProjectsClient) GetMigrateProjectSender(req *http.Request) (*http.Response, error) { 173 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 174} 175 176// GetMigrateProjectResponder handles the response to the GetMigrateProject request. The method always 177// closes the http.Response Body. 178func (client ProjectsClient) GetMigrateProjectResponder(resp *http.Response) (result Project, err error) { 179 err = autorest.Respond( 180 resp, 181 azure.WithErrorUnlessStatusCode(http.StatusOK), 182 autorest.ByUnmarshallingJSON(&result), 183 autorest.ByClosing()) 184 result.Response = autorest.Response{Response: resp} 185 return 186} 187 188// PatchMigrateProject update a migrate project with specified name. Supports partial updates, for example only tags 189// can be provided. 190// Parameters: 191// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 192// migrateProjectName - name of the Azure Migrate project. 193// body - body with migrate project details. 194func (client ProjectsClient) PatchMigrateProject(ctx context.Context, resourceGroupName string, migrateProjectName string, body Project) (result Project, err error) { 195 if tracing.IsEnabled() { 196 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.PatchMigrateProject") 197 defer func() { 198 sc := -1 199 if result.Response.Response != nil { 200 sc = result.Response.Response.StatusCode 201 } 202 tracing.EndSpan(ctx, sc, err) 203 }() 204 } 205 req, err := client.PatchMigrateProjectPreparer(ctx, resourceGroupName, migrateProjectName, body) 206 if err != nil { 207 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "PatchMigrateProject", nil, "Failure preparing request") 208 return 209 } 210 211 resp, err := client.PatchMigrateProjectSender(req) 212 if err != nil { 213 result.Response = autorest.Response{Response: resp} 214 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "PatchMigrateProject", resp, "Failure sending request") 215 return 216 } 217 218 result, err = client.PatchMigrateProjectResponder(resp) 219 if err != nil { 220 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "PatchMigrateProject", resp, "Failure responding to request") 221 return 222 } 223 224 return 225} 226 227// PatchMigrateProjectPreparer prepares the PatchMigrateProject request. 228func (client ProjectsClient) PatchMigrateProjectPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, body Project) (*http.Request, error) { 229 pathParameters := map[string]interface{}{ 230 "migrateProjectName": autorest.Encode("path", migrateProjectName), 231 "resourceGroupName": autorest.Encode("path", resourceGroupName), 232 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 233 } 234 235 const APIVersion = "2018-09-01-preview" 236 queryParameters := map[string]interface{}{ 237 "api-version": APIVersion, 238 } 239 240 body.ID = nil 241 body.Name = nil 242 body.Type = nil 243 preparer := autorest.CreatePreparer( 244 autorest.AsContentType("application/json; charset=utf-8"), 245 autorest.AsPatch(), 246 autorest.WithBaseURL(client.BaseURI), 247 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}", pathParameters), 248 autorest.WithJSON(body), 249 autorest.WithQueryParameters(queryParameters)) 250 if len(client.AcceptLanguage) > 0 { 251 preparer = autorest.DecoratePreparer(preparer, 252 autorest.WithHeader("Accept-Language", autorest.String(client.AcceptLanguage))) 253 } 254 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 255} 256 257// PatchMigrateProjectSender sends the PatchMigrateProject request. The method will close the 258// http.Response Body if it receives an error. 259func (client ProjectsClient) PatchMigrateProjectSender(req *http.Request) (*http.Response, error) { 260 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 261} 262 263// PatchMigrateProjectResponder handles the response to the PatchMigrateProject request. The method always 264// closes the http.Response Body. 265func (client ProjectsClient) PatchMigrateProjectResponder(resp *http.Response) (result Project, err error) { 266 err = autorest.Respond( 267 resp, 268 azure.WithErrorUnlessStatusCode(http.StatusOK), 269 autorest.ByUnmarshallingJSON(&result), 270 autorest.ByClosing()) 271 result.Response = autorest.Response{Response: resp} 272 return 273} 274 275// PutMigrateProject sends the put migrate project request. 276// Parameters: 277// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 278// migrateProjectName - name of the Azure Migrate project. 279// body - body with migrate project details. 280func (client ProjectsClient) PutMigrateProject(ctx context.Context, resourceGroupName string, migrateProjectName string, body Project) (result Project, err error) { 281 if tracing.IsEnabled() { 282 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.PutMigrateProject") 283 defer func() { 284 sc := -1 285 if result.Response.Response != nil { 286 sc = result.Response.Response.StatusCode 287 } 288 tracing.EndSpan(ctx, sc, err) 289 }() 290 } 291 req, err := client.PutMigrateProjectPreparer(ctx, resourceGroupName, migrateProjectName, body) 292 if err != nil { 293 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "PutMigrateProject", nil, "Failure preparing request") 294 return 295 } 296 297 resp, err := client.PutMigrateProjectSender(req) 298 if err != nil { 299 result.Response = autorest.Response{Response: resp} 300 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "PutMigrateProject", resp, "Failure sending request") 301 return 302 } 303 304 result, err = client.PutMigrateProjectResponder(resp) 305 if err != nil { 306 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "PutMigrateProject", resp, "Failure responding to request") 307 return 308 } 309 310 return 311} 312 313// PutMigrateProjectPreparer prepares the PutMigrateProject request. 314func (client ProjectsClient) PutMigrateProjectPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, body Project) (*http.Request, error) { 315 pathParameters := map[string]interface{}{ 316 "migrateProjectName": autorest.Encode("path", migrateProjectName), 317 "resourceGroupName": autorest.Encode("path", resourceGroupName), 318 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 319 } 320 321 const APIVersion = "2018-09-01-preview" 322 queryParameters := map[string]interface{}{ 323 "api-version": APIVersion, 324 } 325 326 body.ID = nil 327 body.Name = nil 328 body.Type = nil 329 preparer := autorest.CreatePreparer( 330 autorest.AsContentType("application/json; charset=utf-8"), 331 autorest.AsPut(), 332 autorest.WithBaseURL(client.BaseURI), 333 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}", pathParameters), 334 autorest.WithJSON(body), 335 autorest.WithQueryParameters(queryParameters)) 336 if len(client.AcceptLanguage) > 0 { 337 preparer = autorest.DecoratePreparer(preparer, 338 autorest.WithHeader("Accept-Language", autorest.String(client.AcceptLanguage))) 339 } 340 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 341} 342 343// PutMigrateProjectSender sends the PutMigrateProject request. The method will close the 344// http.Response Body if it receives an error. 345func (client ProjectsClient) PutMigrateProjectSender(req *http.Request) (*http.Response, error) { 346 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 347} 348 349// PutMigrateProjectResponder handles the response to the PutMigrateProject request. The method always 350// closes the http.Response Body. 351func (client ProjectsClient) PutMigrateProjectResponder(resp *http.Response) (result Project, err error) { 352 err = autorest.Respond( 353 resp, 354 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 355 autorest.ByUnmarshallingJSON(&result), 356 autorest.ByClosing()) 357 result.Response = autorest.Response{Response: resp} 358 return 359} 360 361// RefreshMigrateProjectSummary sends the refresh migrate project summary request. 362// Parameters: 363// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 364// migrateProjectName - name of the Azure Migrate project. 365// input - the goal input which needs to be refreshed. 366func (client ProjectsClient) RefreshMigrateProjectSummary(ctx context.Context, resourceGroupName string, migrateProjectName string, input RefreshSummaryInput) (result RefreshSummaryResult, err error) { 367 if tracing.IsEnabled() { 368 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.RefreshMigrateProjectSummary") 369 defer func() { 370 sc := -1 371 if result.Response.Response != nil { 372 sc = result.Response.Response.StatusCode 373 } 374 tracing.EndSpan(ctx, sc, err) 375 }() 376 } 377 req, err := client.RefreshMigrateProjectSummaryPreparer(ctx, resourceGroupName, migrateProjectName, input) 378 if err != nil { 379 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "RefreshMigrateProjectSummary", nil, "Failure preparing request") 380 return 381 } 382 383 resp, err := client.RefreshMigrateProjectSummarySender(req) 384 if err != nil { 385 result.Response = autorest.Response{Response: resp} 386 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "RefreshMigrateProjectSummary", resp, "Failure sending request") 387 return 388 } 389 390 result, err = client.RefreshMigrateProjectSummaryResponder(resp) 391 if err != nil { 392 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "RefreshMigrateProjectSummary", resp, "Failure responding to request") 393 return 394 } 395 396 return 397} 398 399// RefreshMigrateProjectSummaryPreparer prepares the RefreshMigrateProjectSummary request. 400func (client ProjectsClient) RefreshMigrateProjectSummaryPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, input RefreshSummaryInput) (*http.Request, error) { 401 pathParameters := map[string]interface{}{ 402 "migrateProjectName": autorest.Encode("path", migrateProjectName), 403 "resourceGroupName": autorest.Encode("path", resourceGroupName), 404 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 405 } 406 407 const APIVersion = "2018-09-01-preview" 408 queryParameters := map[string]interface{}{ 409 "api-version": APIVersion, 410 } 411 412 preparer := autorest.CreatePreparer( 413 autorest.AsContentType("application/json; charset=utf-8"), 414 autorest.AsPost(), 415 autorest.WithBaseURL(client.BaseURI), 416 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/refreshSummary", pathParameters), 417 autorest.WithJSON(input), 418 autorest.WithQueryParameters(queryParameters)) 419 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 420} 421 422// RefreshMigrateProjectSummarySender sends the RefreshMigrateProjectSummary request. The method will close the 423// http.Response Body if it receives an error. 424func (client ProjectsClient) RefreshMigrateProjectSummarySender(req *http.Request) (*http.Response, error) { 425 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 426} 427 428// RefreshMigrateProjectSummaryResponder handles the response to the RefreshMigrateProjectSummary request. The method always 429// closes the http.Response Body. 430func (client ProjectsClient) RefreshMigrateProjectSummaryResponder(resp *http.Response) (result RefreshSummaryResult, err error) { 431 err = autorest.Respond( 432 resp, 433 azure.WithErrorUnlessStatusCode(http.StatusOK), 434 autorest.ByUnmarshallingJSON(&result), 435 autorest.ByClosing()) 436 result.Response = autorest.Response{Response: resp} 437 return 438} 439 440// RegisterTool sends the register tool request. 441// Parameters: 442// resourceGroupName - name of the Azure Resource Group that migrate project is part of. 443// migrateProjectName - name of the Azure Migrate project. 444// input - input containing the name of the tool to be registered. 445func (client ProjectsClient) RegisterTool(ctx context.Context, resourceGroupName string, migrateProjectName string, input RegisterToolInput) (result RegistrationResult, err error) { 446 if tracing.IsEnabled() { 447 ctx = tracing.StartSpan(ctx, fqdn+"/ProjectsClient.RegisterTool") 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.RegisterToolPreparer(ctx, resourceGroupName, migrateProjectName, input) 457 if err != nil { 458 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "RegisterTool", nil, "Failure preparing request") 459 return 460 } 461 462 resp, err := client.RegisterToolSender(req) 463 if err != nil { 464 result.Response = autorest.Response{Response: resp} 465 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "RegisterTool", resp, "Failure sending request") 466 return 467 } 468 469 result, err = client.RegisterToolResponder(resp) 470 if err != nil { 471 err = autorest.NewErrorWithError(err, "migrate.ProjectsClient", "RegisterTool", resp, "Failure responding to request") 472 return 473 } 474 475 return 476} 477 478// RegisterToolPreparer prepares the RegisterTool request. 479func (client ProjectsClient) RegisterToolPreparer(ctx context.Context, resourceGroupName string, migrateProjectName string, input RegisterToolInput) (*http.Request, error) { 480 pathParameters := map[string]interface{}{ 481 "migrateProjectName": autorest.Encode("path", migrateProjectName), 482 "resourceGroupName": autorest.Encode("path", resourceGroupName), 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 preparer := autorest.CreatePreparer( 492 autorest.AsContentType("application/json; charset=utf-8"), 493 autorest.AsPost(), 494 autorest.WithBaseURL(client.BaseURI), 495 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Migrate/migrateProjects/{migrateProjectName}/registerTool", pathParameters), 496 autorest.WithJSON(input), 497 autorest.WithQueryParameters(queryParameters)) 498 if len(client.AcceptLanguage) > 0 { 499 preparer = autorest.DecoratePreparer(preparer, 500 autorest.WithHeader("Accept-Language", autorest.String(client.AcceptLanguage))) 501 } 502 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 503} 504 505// RegisterToolSender sends the RegisterTool request. The method will close the 506// http.Response Body if it receives an error. 507func (client ProjectsClient) RegisterToolSender(req *http.Request) (*http.Response, error) { 508 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 509} 510 511// RegisterToolResponder handles the response to the RegisterTool request. The method always 512// closes the http.Response Body. 513func (client ProjectsClient) RegisterToolResponder(resp *http.Response) (result RegistrationResult, err error) { 514 err = autorest.Respond( 515 resp, 516 azure.WithErrorUnlessStatusCode(http.StatusOK), 517 autorest.ByUnmarshallingJSON(&result), 518 autorest.ByClosing()) 519 result.Response = autorest.Response{Response: resp} 520 return 521} 522