1package siterecovery 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// ReplicationRecoveryPlansClient is the client for the ReplicationRecoveryPlans methods of the Siterecovery service. 19type ReplicationRecoveryPlansClient struct { 20 BaseClient 21} 22 23// NewReplicationRecoveryPlansClient creates an instance of the ReplicationRecoveryPlansClient client. 24func NewReplicationRecoveryPlansClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryPlansClient { 25 return NewReplicationRecoveryPlansClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) 26} 27 28// NewReplicationRecoveryPlansClientWithBaseURI creates an instance of the ReplicationRecoveryPlansClient client using 29// a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign 30// clouds, Azure stack). 31func NewReplicationRecoveryPlansClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationRecoveryPlansClient { 32 return ReplicationRecoveryPlansClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} 33} 34 35// Create the operation to create a recovery plan. 36// Parameters: 37// recoveryPlanName - recovery plan name. 38// input - recovery Plan creation input. 39func (client ReplicationRecoveryPlansClient) Create(ctx context.Context, recoveryPlanName string, input CreateRecoveryPlanInput) (result ReplicationRecoveryPlansCreateFuture, err error) { 40 if tracing.IsEnabled() { 41 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.Create") 42 defer func() { 43 sc := -1 44 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 45 sc = result.FutureAPI.Response().StatusCode 46 } 47 tracing.EndSpan(ctx, sc, err) 48 }() 49 } 50 if err := validation.Validate([]validation.Validation{ 51 {TargetValue: input, 52 Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, 53 Chain: []validation.Constraint{{Target: "input.Properties.PrimaryFabricID", Name: validation.Null, Rule: true, Chain: nil}, 54 {Target: "input.Properties.RecoveryFabricID", Name: validation.Null, Rule: true, Chain: nil}, 55 {Target: "input.Properties.Groups", Name: validation.Null, Rule: true, Chain: nil}, 56 }}}}}); err != nil { 57 return result, validation.NewError("siterecovery.ReplicationRecoveryPlansClient", "Create", err.Error()) 58 } 59 60 req, err := client.CreatePreparer(ctx, recoveryPlanName, input) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Create", nil, "Failure preparing request") 63 return 64 } 65 66 result, err = client.CreateSender(req) 67 if err != nil { 68 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Create", nil, "Failure sending request") 69 return 70 } 71 72 return 73} 74 75// CreatePreparer prepares the Create request. 76func (client ReplicationRecoveryPlansClient) CreatePreparer(ctx context.Context, recoveryPlanName string, input CreateRecoveryPlanInput) (*http.Request, error) { 77 pathParameters := map[string]interface{}{ 78 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 79 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 80 "resourceName": autorest.Encode("path", client.ResourceName), 81 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 82 } 83 84 const APIVersion = "2016-08-10" 85 queryParameters := map[string]interface{}{ 86 "api-version": APIVersion, 87 } 88 89 preparer := autorest.CreatePreparer( 90 autorest.AsContentType("application/json; charset=utf-8"), 91 autorest.AsPut(), 92 autorest.WithBaseURL(client.BaseURI), 93 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), 94 autorest.WithJSON(input), 95 autorest.WithQueryParameters(queryParameters)) 96 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 97} 98 99// CreateSender sends the Create request. The method will close the 100// http.Response Body if it receives an error. 101func (client ReplicationRecoveryPlansClient) CreateSender(req *http.Request) (future ReplicationRecoveryPlansCreateFuture, err error) { 102 var resp *http.Response 103 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 104 if err != nil { 105 return 106 } 107 var azf azure.Future 108 azf, err = azure.NewFutureFromResponse(resp) 109 future.FutureAPI = &azf 110 future.Result = future.result 111 return 112} 113 114// CreateResponder handles the response to the Create request. The method always 115// closes the http.Response Body. 116func (client ReplicationRecoveryPlansClient) CreateResponder(resp *http.Response) (result RecoveryPlan, err error) { 117 err = autorest.Respond( 118 resp, 119 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 120 autorest.ByUnmarshallingJSON(&result), 121 autorest.ByClosing()) 122 result.Response = autorest.Response{Response: resp} 123 return 124} 125 126// Delete delete a recovery plan. 127// Parameters: 128// recoveryPlanName - recovery plan name. 129func (client ReplicationRecoveryPlansClient) Delete(ctx context.Context, recoveryPlanName string) (result ReplicationRecoveryPlansDeleteFuture, err error) { 130 if tracing.IsEnabled() { 131 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.Delete") 132 defer func() { 133 sc := -1 134 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 135 sc = result.FutureAPI.Response().StatusCode 136 } 137 tracing.EndSpan(ctx, sc, err) 138 }() 139 } 140 req, err := client.DeletePreparer(ctx, recoveryPlanName) 141 if err != nil { 142 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Delete", nil, "Failure preparing request") 143 return 144 } 145 146 result, err = client.DeleteSender(req) 147 if err != nil { 148 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Delete", nil, "Failure sending request") 149 return 150 } 151 152 return 153} 154 155// DeletePreparer prepares the Delete request. 156func (client ReplicationRecoveryPlansClient) DeletePreparer(ctx context.Context, recoveryPlanName string) (*http.Request, error) { 157 pathParameters := map[string]interface{}{ 158 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 159 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 160 "resourceName": autorest.Encode("path", client.ResourceName), 161 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 162 } 163 164 const APIVersion = "2016-08-10" 165 queryParameters := map[string]interface{}{ 166 "api-version": APIVersion, 167 } 168 169 preparer := autorest.CreatePreparer( 170 autorest.AsDelete(), 171 autorest.WithBaseURL(client.BaseURI), 172 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), 173 autorest.WithQueryParameters(queryParameters)) 174 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 175} 176 177// DeleteSender sends the Delete request. The method will close the 178// http.Response Body if it receives an error. 179func (client ReplicationRecoveryPlansClient) DeleteSender(req *http.Request) (future ReplicationRecoveryPlansDeleteFuture, err error) { 180 var resp *http.Response 181 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 182 if err != nil { 183 return 184 } 185 var azf azure.Future 186 azf, err = azure.NewFutureFromResponse(resp) 187 future.FutureAPI = &azf 188 future.Result = future.result 189 return 190} 191 192// DeleteResponder handles the response to the Delete request. The method always 193// closes the http.Response Body. 194func (client ReplicationRecoveryPlansClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 195 err = autorest.Respond( 196 resp, 197 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 198 autorest.ByClosing()) 199 result.Response = resp 200 return 201} 202 203// FailoverCommit the operation to commit the fail over of a recovery plan. 204// Parameters: 205// recoveryPlanName - recovery plan name. 206func (client ReplicationRecoveryPlansClient) FailoverCommit(ctx context.Context, recoveryPlanName string) (result ReplicationRecoveryPlansFailoverCommitFuture, err error) { 207 if tracing.IsEnabled() { 208 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.FailoverCommit") 209 defer func() { 210 sc := -1 211 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 212 sc = result.FutureAPI.Response().StatusCode 213 } 214 tracing.EndSpan(ctx, sc, err) 215 }() 216 } 217 req, err := client.FailoverCommitPreparer(ctx, recoveryPlanName) 218 if err != nil { 219 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", nil, "Failure preparing request") 220 return 221 } 222 223 result, err = client.FailoverCommitSender(req) 224 if err != nil { 225 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "FailoverCommit", nil, "Failure sending request") 226 return 227 } 228 229 return 230} 231 232// FailoverCommitPreparer prepares the FailoverCommit request. 233func (client ReplicationRecoveryPlansClient) FailoverCommitPreparer(ctx context.Context, recoveryPlanName string) (*http.Request, error) { 234 pathParameters := map[string]interface{}{ 235 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 236 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 237 "resourceName": autorest.Encode("path", client.ResourceName), 238 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 239 } 240 241 const APIVersion = "2016-08-10" 242 queryParameters := map[string]interface{}{ 243 "api-version": APIVersion, 244 } 245 246 preparer := autorest.CreatePreparer( 247 autorest.AsPost(), 248 autorest.WithBaseURL(client.BaseURI), 249 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/failoverCommit", pathParameters), 250 autorest.WithQueryParameters(queryParameters)) 251 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 252} 253 254// FailoverCommitSender sends the FailoverCommit request. The method will close the 255// http.Response Body if it receives an error. 256func (client ReplicationRecoveryPlansClient) FailoverCommitSender(req *http.Request) (future ReplicationRecoveryPlansFailoverCommitFuture, err error) { 257 var resp *http.Response 258 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 259 if err != nil { 260 return 261 } 262 var azf azure.Future 263 azf, err = azure.NewFutureFromResponse(resp) 264 future.FutureAPI = &azf 265 future.Result = future.result 266 return 267} 268 269// FailoverCommitResponder handles the response to the FailoverCommit request. The method always 270// closes the http.Response Body. 271func (client ReplicationRecoveryPlansClient) FailoverCommitResponder(resp *http.Response) (result RecoveryPlan, err error) { 272 err = autorest.Respond( 273 resp, 274 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 275 autorest.ByUnmarshallingJSON(&result), 276 autorest.ByClosing()) 277 result.Response = autorest.Response{Response: resp} 278 return 279} 280 281// Get gets the details of the recovery plan. 282// Parameters: 283// recoveryPlanName - name of the recovery plan. 284func (client ReplicationRecoveryPlansClient) Get(ctx context.Context, recoveryPlanName string) (result RecoveryPlan, err error) { 285 if tracing.IsEnabled() { 286 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.Get") 287 defer func() { 288 sc := -1 289 if result.Response.Response != nil { 290 sc = result.Response.Response.StatusCode 291 } 292 tracing.EndSpan(ctx, sc, err) 293 }() 294 } 295 req, err := client.GetPreparer(ctx, recoveryPlanName) 296 if err != nil { 297 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Get", nil, "Failure preparing request") 298 return 299 } 300 301 resp, err := client.GetSender(req) 302 if err != nil { 303 result.Response = autorest.Response{Response: resp} 304 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Get", resp, "Failure sending request") 305 return 306 } 307 308 result, err = client.GetResponder(resp) 309 if err != nil { 310 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Get", resp, "Failure responding to request") 311 return 312 } 313 314 return 315} 316 317// GetPreparer prepares the Get request. 318func (client ReplicationRecoveryPlansClient) GetPreparer(ctx context.Context, recoveryPlanName string) (*http.Request, error) { 319 pathParameters := map[string]interface{}{ 320 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 321 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 322 "resourceName": autorest.Encode("path", client.ResourceName), 323 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 324 } 325 326 const APIVersion = "2016-08-10" 327 queryParameters := map[string]interface{}{ 328 "api-version": APIVersion, 329 } 330 331 preparer := autorest.CreatePreparer( 332 autorest.AsGet(), 333 autorest.WithBaseURL(client.BaseURI), 334 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), 335 autorest.WithQueryParameters(queryParameters)) 336 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 337} 338 339// GetSender sends the Get request. The method will close the 340// http.Response Body if it receives an error. 341func (client ReplicationRecoveryPlansClient) GetSender(req *http.Request) (*http.Response, error) { 342 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 343} 344 345// GetResponder handles the response to the Get request. The method always 346// closes the http.Response Body. 347func (client ReplicationRecoveryPlansClient) GetResponder(resp *http.Response) (result RecoveryPlan, err error) { 348 err = autorest.Respond( 349 resp, 350 azure.WithErrorUnlessStatusCode(http.StatusOK), 351 autorest.ByUnmarshallingJSON(&result), 352 autorest.ByClosing()) 353 result.Response = autorest.Response{Response: resp} 354 return 355} 356 357// List lists the recovery plans in the vault. 358func (client ReplicationRecoveryPlansClient) List(ctx context.Context) (result RecoveryPlanCollectionPage, err error) { 359 if tracing.IsEnabled() { 360 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.List") 361 defer func() { 362 sc := -1 363 if result.RPCVar.Response.Response != nil { 364 sc = result.RPCVar.Response.Response.StatusCode 365 } 366 tracing.EndSpan(ctx, sc, err) 367 }() 368 } 369 result.fn = client.listNextResults 370 req, err := client.ListPreparer(ctx) 371 if err != nil { 372 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "List", nil, "Failure preparing request") 373 return 374 } 375 376 resp, err := client.ListSender(req) 377 if err != nil { 378 result.RPCVar.Response = autorest.Response{Response: resp} 379 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure sending request") 380 return 381 } 382 383 result.RPCVar, err = client.ListResponder(resp) 384 if err != nil { 385 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "List", resp, "Failure responding to request") 386 return 387 } 388 if result.RPCVar.hasNextLink() && result.RPCVar.IsEmpty() { 389 err = result.NextWithContext(ctx) 390 return 391 } 392 393 return 394} 395 396// ListPreparer prepares the List request. 397func (client ReplicationRecoveryPlansClient) ListPreparer(ctx context.Context) (*http.Request, error) { 398 pathParameters := map[string]interface{}{ 399 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 400 "resourceName": autorest.Encode("path", client.ResourceName), 401 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 402 } 403 404 const APIVersion = "2016-08-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}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans", pathParameters), 413 autorest.WithQueryParameters(queryParameters)) 414 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 415} 416 417// ListSender sends the List request. The method will close the 418// http.Response Body if it receives an error. 419func (client ReplicationRecoveryPlansClient) ListSender(req *http.Request) (*http.Response, error) { 420 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 421} 422 423// ListResponder handles the response to the List request. The method always 424// closes the http.Response Body. 425func (client ReplicationRecoveryPlansClient) ListResponder(resp *http.Response) (result RecoveryPlanCollection, err error) { 426 err = autorest.Respond( 427 resp, 428 azure.WithErrorUnlessStatusCode(http.StatusOK), 429 autorest.ByUnmarshallingJSON(&result), 430 autorest.ByClosing()) 431 result.Response = autorest.Response{Response: resp} 432 return 433} 434 435// listNextResults retrieves the next set of results, if any. 436func (client ReplicationRecoveryPlansClient) listNextResults(ctx context.Context, lastResults RecoveryPlanCollection) (result RecoveryPlanCollection, err error) { 437 req, err := lastResults.recoveryPlanCollectionPreparer(ctx) 438 if err != nil { 439 return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "listNextResults", nil, "Failure preparing next results request") 440 } 441 if req == nil { 442 return 443 } 444 resp, err := client.ListSender(req) 445 if err != nil { 446 result.Response = autorest.Response{Response: resp} 447 return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "listNextResults", resp, "Failure sending next results request") 448 } 449 result, err = client.ListResponder(resp) 450 if err != nil { 451 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "listNextResults", resp, "Failure responding to next results request") 452 } 453 return 454} 455 456// ListComplete enumerates all values, automatically crossing page boundaries as required. 457func (client ReplicationRecoveryPlansClient) ListComplete(ctx context.Context) (result RecoveryPlanCollectionIterator, err error) { 458 if tracing.IsEnabled() { 459 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.List") 460 defer func() { 461 sc := -1 462 if result.Response().Response.Response != nil { 463 sc = result.page.Response().Response.Response.StatusCode 464 } 465 tracing.EndSpan(ctx, sc, err) 466 }() 467 } 468 result.page, err = client.List(ctx) 469 return 470} 471 472// PlannedFailover the operation to start the planned failover of a recovery plan. 473// Parameters: 474// recoveryPlanName - recovery plan name. 475// input - failover input. 476func (client ReplicationRecoveryPlansClient) PlannedFailover(ctx context.Context, recoveryPlanName string, input RecoveryPlanPlannedFailoverInput) (result ReplicationRecoveryPlansPlannedFailoverFuture, err error) { 477 if tracing.IsEnabled() { 478 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.PlannedFailover") 479 defer func() { 480 sc := -1 481 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 482 sc = result.FutureAPI.Response().StatusCode 483 } 484 tracing.EndSpan(ctx, sc, err) 485 }() 486 } 487 if err := validation.Validate([]validation.Validation{ 488 {TargetValue: input, 489 Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 490 return result, validation.NewError("siterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", err.Error()) 491 } 492 493 req, err := client.PlannedFailoverPreparer(ctx, recoveryPlanName, input) 494 if err != nil { 495 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", nil, "Failure preparing request") 496 return 497 } 498 499 result, err = client.PlannedFailoverSender(req) 500 if err != nil { 501 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "PlannedFailover", nil, "Failure sending request") 502 return 503 } 504 505 return 506} 507 508// PlannedFailoverPreparer prepares the PlannedFailover request. 509func (client ReplicationRecoveryPlansClient) PlannedFailoverPreparer(ctx context.Context, recoveryPlanName string, input RecoveryPlanPlannedFailoverInput) (*http.Request, error) { 510 pathParameters := map[string]interface{}{ 511 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 512 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 513 "resourceName": autorest.Encode("path", client.ResourceName), 514 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 515 } 516 517 const APIVersion = "2016-08-10" 518 queryParameters := map[string]interface{}{ 519 "api-version": APIVersion, 520 } 521 522 preparer := autorest.CreatePreparer( 523 autorest.AsContentType("application/json; charset=utf-8"), 524 autorest.AsPost(), 525 autorest.WithBaseURL(client.BaseURI), 526 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/plannedFailover", pathParameters), 527 autorest.WithJSON(input), 528 autorest.WithQueryParameters(queryParameters)) 529 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 530} 531 532// PlannedFailoverSender sends the PlannedFailover request. The method will close the 533// http.Response Body if it receives an error. 534func (client ReplicationRecoveryPlansClient) PlannedFailoverSender(req *http.Request) (future ReplicationRecoveryPlansPlannedFailoverFuture, err error) { 535 var resp *http.Response 536 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 537 if err != nil { 538 return 539 } 540 var azf azure.Future 541 azf, err = azure.NewFutureFromResponse(resp) 542 future.FutureAPI = &azf 543 future.Result = future.result 544 return 545} 546 547// PlannedFailoverResponder handles the response to the PlannedFailover request. The method always 548// closes the http.Response Body. 549func (client ReplicationRecoveryPlansClient) PlannedFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { 550 err = autorest.Respond( 551 resp, 552 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 553 autorest.ByUnmarshallingJSON(&result), 554 autorest.ByClosing()) 555 result.Response = autorest.Response{Response: resp} 556 return 557} 558 559// Reprotect the operation to reprotect(reverse replicate) a recovery plan. 560// Parameters: 561// recoveryPlanName - recovery plan name. 562func (client ReplicationRecoveryPlansClient) Reprotect(ctx context.Context, recoveryPlanName string) (result ReplicationRecoveryPlansReprotectFuture, err error) { 563 if tracing.IsEnabled() { 564 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.Reprotect") 565 defer func() { 566 sc := -1 567 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 568 sc = result.FutureAPI.Response().StatusCode 569 } 570 tracing.EndSpan(ctx, sc, err) 571 }() 572 } 573 req, err := client.ReprotectPreparer(ctx, recoveryPlanName) 574 if err != nil { 575 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Reprotect", nil, "Failure preparing request") 576 return 577 } 578 579 result, err = client.ReprotectSender(req) 580 if err != nil { 581 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Reprotect", nil, "Failure sending request") 582 return 583 } 584 585 return 586} 587 588// ReprotectPreparer prepares the Reprotect request. 589func (client ReplicationRecoveryPlansClient) ReprotectPreparer(ctx context.Context, recoveryPlanName string) (*http.Request, error) { 590 pathParameters := map[string]interface{}{ 591 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 592 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 593 "resourceName": autorest.Encode("path", client.ResourceName), 594 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 595 } 596 597 const APIVersion = "2016-08-10" 598 queryParameters := map[string]interface{}{ 599 "api-version": APIVersion, 600 } 601 602 preparer := autorest.CreatePreparer( 603 autorest.AsPost(), 604 autorest.WithBaseURL(client.BaseURI), 605 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/reProtect", pathParameters), 606 autorest.WithQueryParameters(queryParameters)) 607 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 608} 609 610// ReprotectSender sends the Reprotect request. The method will close the 611// http.Response Body if it receives an error. 612func (client ReplicationRecoveryPlansClient) ReprotectSender(req *http.Request) (future ReplicationRecoveryPlansReprotectFuture, err error) { 613 var resp *http.Response 614 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 615 if err != nil { 616 return 617 } 618 var azf azure.Future 619 azf, err = azure.NewFutureFromResponse(resp) 620 future.FutureAPI = &azf 621 future.Result = future.result 622 return 623} 624 625// ReprotectResponder handles the response to the Reprotect request. The method always 626// closes the http.Response Body. 627func (client ReplicationRecoveryPlansClient) ReprotectResponder(resp *http.Response) (result RecoveryPlan, err error) { 628 err = autorest.Respond( 629 resp, 630 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 631 autorest.ByUnmarshallingJSON(&result), 632 autorest.ByClosing()) 633 result.Response = autorest.Response{Response: resp} 634 return 635} 636 637// TestFailover the operation to start the test failover of a recovery plan. 638// Parameters: 639// recoveryPlanName - recovery plan name. 640// input - failover input. 641func (client ReplicationRecoveryPlansClient) TestFailover(ctx context.Context, recoveryPlanName string, input RecoveryPlanTestFailoverInput) (result ReplicationRecoveryPlansTestFailoverFuture, err error) { 642 if tracing.IsEnabled() { 643 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.TestFailover") 644 defer func() { 645 sc := -1 646 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 647 sc = result.FutureAPI.Response().StatusCode 648 } 649 tracing.EndSpan(ctx, sc, err) 650 }() 651 } 652 if err := validation.Validate([]validation.Validation{ 653 {TargetValue: input, 654 Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, 655 Chain: []validation.Constraint{{Target: "input.Properties.NetworkType", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { 656 return result, validation.NewError("siterecovery.ReplicationRecoveryPlansClient", "TestFailover", err.Error()) 657 } 658 659 req, err := client.TestFailoverPreparer(ctx, recoveryPlanName, input) 660 if err != nil { 661 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "TestFailover", nil, "Failure preparing request") 662 return 663 } 664 665 result, err = client.TestFailoverSender(req) 666 if err != nil { 667 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "TestFailover", nil, "Failure sending request") 668 return 669 } 670 671 return 672} 673 674// TestFailoverPreparer prepares the TestFailover request. 675func (client ReplicationRecoveryPlansClient) TestFailoverPreparer(ctx context.Context, recoveryPlanName string, input RecoveryPlanTestFailoverInput) (*http.Request, error) { 676 pathParameters := map[string]interface{}{ 677 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 678 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 679 "resourceName": autorest.Encode("path", client.ResourceName), 680 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 681 } 682 683 const APIVersion = "2016-08-10" 684 queryParameters := map[string]interface{}{ 685 "api-version": APIVersion, 686 } 687 688 preparer := autorest.CreatePreparer( 689 autorest.AsContentType("application/json; charset=utf-8"), 690 autorest.AsPost(), 691 autorest.WithBaseURL(client.BaseURI), 692 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/testFailover", pathParameters), 693 autorest.WithJSON(input), 694 autorest.WithQueryParameters(queryParameters)) 695 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 696} 697 698// TestFailoverSender sends the TestFailover request. The method will close the 699// http.Response Body if it receives an error. 700func (client ReplicationRecoveryPlansClient) TestFailoverSender(req *http.Request) (future ReplicationRecoveryPlansTestFailoverFuture, err error) { 701 var resp *http.Response 702 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 703 if err != nil { 704 return 705 } 706 var azf azure.Future 707 azf, err = azure.NewFutureFromResponse(resp) 708 future.FutureAPI = &azf 709 future.Result = future.result 710 return 711} 712 713// TestFailoverResponder handles the response to the TestFailover request. The method always 714// closes the http.Response Body. 715func (client ReplicationRecoveryPlansClient) TestFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { 716 err = autorest.Respond( 717 resp, 718 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 719 autorest.ByUnmarshallingJSON(&result), 720 autorest.ByClosing()) 721 result.Response = autorest.Response{Response: resp} 722 return 723} 724 725// TestFailoverCleanup the operation to cleanup test failover of a recovery plan. 726// Parameters: 727// recoveryPlanName - recovery plan name. 728// input - test failover cleanup input. 729func (client ReplicationRecoveryPlansClient) TestFailoverCleanup(ctx context.Context, recoveryPlanName string, input RecoveryPlanTestFailoverCleanupInput) (result ReplicationRecoveryPlansTestFailoverCleanupFuture, err error) { 730 if tracing.IsEnabled() { 731 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.TestFailoverCleanup") 732 defer func() { 733 sc := -1 734 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 735 sc = result.FutureAPI.Response().StatusCode 736 } 737 tracing.EndSpan(ctx, sc, err) 738 }() 739 } 740 if err := validation.Validate([]validation.Validation{ 741 {TargetValue: input, 742 Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 743 return result, validation.NewError("siterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", err.Error()) 744 } 745 746 req, err := client.TestFailoverCleanupPreparer(ctx, recoveryPlanName, input) 747 if err != nil { 748 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", nil, "Failure preparing request") 749 return 750 } 751 752 result, err = client.TestFailoverCleanupSender(req) 753 if err != nil { 754 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "TestFailoverCleanup", nil, "Failure sending request") 755 return 756 } 757 758 return 759} 760 761// TestFailoverCleanupPreparer prepares the TestFailoverCleanup request. 762func (client ReplicationRecoveryPlansClient) TestFailoverCleanupPreparer(ctx context.Context, recoveryPlanName string, input RecoveryPlanTestFailoverCleanupInput) (*http.Request, error) { 763 pathParameters := map[string]interface{}{ 764 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 765 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 766 "resourceName": autorest.Encode("path", client.ResourceName), 767 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 768 } 769 770 const APIVersion = "2016-08-10" 771 queryParameters := map[string]interface{}{ 772 "api-version": APIVersion, 773 } 774 775 preparer := autorest.CreatePreparer( 776 autorest.AsContentType("application/json; charset=utf-8"), 777 autorest.AsPost(), 778 autorest.WithBaseURL(client.BaseURI), 779 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/testFailoverCleanup", pathParameters), 780 autorest.WithJSON(input), 781 autorest.WithQueryParameters(queryParameters)) 782 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 783} 784 785// TestFailoverCleanupSender sends the TestFailoverCleanup request. The method will close the 786// http.Response Body if it receives an error. 787func (client ReplicationRecoveryPlansClient) TestFailoverCleanupSender(req *http.Request) (future ReplicationRecoveryPlansTestFailoverCleanupFuture, err error) { 788 var resp *http.Response 789 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 790 if err != nil { 791 return 792 } 793 var azf azure.Future 794 azf, err = azure.NewFutureFromResponse(resp) 795 future.FutureAPI = &azf 796 future.Result = future.result 797 return 798} 799 800// TestFailoverCleanupResponder handles the response to the TestFailoverCleanup request. The method always 801// closes the http.Response Body. 802func (client ReplicationRecoveryPlansClient) TestFailoverCleanupResponder(resp *http.Response) (result RecoveryPlan, err error) { 803 err = autorest.Respond( 804 resp, 805 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 806 autorest.ByUnmarshallingJSON(&result), 807 autorest.ByClosing()) 808 result.Response = autorest.Response{Response: resp} 809 return 810} 811 812// UnplannedFailover the operation to start the failover of a recovery plan. 813// Parameters: 814// recoveryPlanName - recovery plan name. 815// input - failover input. 816func (client ReplicationRecoveryPlansClient) UnplannedFailover(ctx context.Context, recoveryPlanName string, input RecoveryPlanUnplannedFailoverInput) (result ReplicationRecoveryPlansUnplannedFailoverFuture, err error) { 817 if tracing.IsEnabled() { 818 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.UnplannedFailover") 819 defer func() { 820 sc := -1 821 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 822 sc = result.FutureAPI.Response().StatusCode 823 } 824 tracing.EndSpan(ctx, sc, err) 825 }() 826 } 827 if err := validation.Validate([]validation.Validation{ 828 {TargetValue: input, 829 Constraints: []validation.Constraint{{Target: "input.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 830 return result, validation.NewError("siterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", err.Error()) 831 } 832 833 req, err := client.UnplannedFailoverPreparer(ctx, recoveryPlanName, input) 834 if err != nil { 835 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", nil, "Failure preparing request") 836 return 837 } 838 839 result, err = client.UnplannedFailoverSender(req) 840 if err != nil { 841 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "UnplannedFailover", nil, "Failure sending request") 842 return 843 } 844 845 return 846} 847 848// UnplannedFailoverPreparer prepares the UnplannedFailover request. 849func (client ReplicationRecoveryPlansClient) UnplannedFailoverPreparer(ctx context.Context, recoveryPlanName string, input RecoveryPlanUnplannedFailoverInput) (*http.Request, error) { 850 pathParameters := map[string]interface{}{ 851 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 852 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 853 "resourceName": autorest.Encode("path", client.ResourceName), 854 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 855 } 856 857 const APIVersion = "2016-08-10" 858 queryParameters := map[string]interface{}{ 859 "api-version": APIVersion, 860 } 861 862 preparer := autorest.CreatePreparer( 863 autorest.AsContentType("application/json; charset=utf-8"), 864 autorest.AsPost(), 865 autorest.WithBaseURL(client.BaseURI), 866 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}/unplannedFailover", pathParameters), 867 autorest.WithJSON(input), 868 autorest.WithQueryParameters(queryParameters)) 869 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 870} 871 872// UnplannedFailoverSender sends the UnplannedFailover request. The method will close the 873// http.Response Body if it receives an error. 874func (client ReplicationRecoveryPlansClient) UnplannedFailoverSender(req *http.Request) (future ReplicationRecoveryPlansUnplannedFailoverFuture, err error) { 875 var resp *http.Response 876 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 877 if err != nil { 878 return 879 } 880 var azf azure.Future 881 azf, err = azure.NewFutureFromResponse(resp) 882 future.FutureAPI = &azf 883 future.Result = future.result 884 return 885} 886 887// UnplannedFailoverResponder handles the response to the UnplannedFailover request. The method always 888// closes the http.Response Body. 889func (client ReplicationRecoveryPlansClient) UnplannedFailoverResponder(resp *http.Response) (result RecoveryPlan, err error) { 890 err = autorest.Respond( 891 resp, 892 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 893 autorest.ByUnmarshallingJSON(&result), 894 autorest.ByClosing()) 895 result.Response = autorest.Response{Response: resp} 896 return 897} 898 899// Update the operation to update a recovery plan. 900// Parameters: 901// recoveryPlanName - recovery plan name. 902// input - update recovery plan input 903func (client ReplicationRecoveryPlansClient) Update(ctx context.Context, recoveryPlanName string, input UpdateRecoveryPlanInput) (result ReplicationRecoveryPlansUpdateFuture, err error) { 904 if tracing.IsEnabled() { 905 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationRecoveryPlansClient.Update") 906 defer func() { 907 sc := -1 908 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 909 sc = result.FutureAPI.Response().StatusCode 910 } 911 tracing.EndSpan(ctx, sc, err) 912 }() 913 } 914 req, err := client.UpdatePreparer(ctx, recoveryPlanName, input) 915 if err != nil { 916 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Update", nil, "Failure preparing request") 917 return 918 } 919 920 result, err = client.UpdateSender(req) 921 if err != nil { 922 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationRecoveryPlansClient", "Update", nil, "Failure sending request") 923 return 924 } 925 926 return 927} 928 929// UpdatePreparer prepares the Update request. 930func (client ReplicationRecoveryPlansClient) UpdatePreparer(ctx context.Context, recoveryPlanName string, input UpdateRecoveryPlanInput) (*http.Request, error) { 931 pathParameters := map[string]interface{}{ 932 "recoveryPlanName": autorest.Encode("path", recoveryPlanName), 933 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 934 "resourceName": autorest.Encode("path", client.ResourceName), 935 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 936 } 937 938 const APIVersion = "2016-08-10" 939 queryParameters := map[string]interface{}{ 940 "api-version": APIVersion, 941 } 942 943 preparer := autorest.CreatePreparer( 944 autorest.AsContentType("application/json; charset=utf-8"), 945 autorest.AsPatch(), 946 autorest.WithBaseURL(client.BaseURI), 947 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationRecoveryPlans/{recoveryPlanName}", pathParameters), 948 autorest.WithJSON(input), 949 autorest.WithQueryParameters(queryParameters)) 950 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 951} 952 953// UpdateSender sends the Update request. The method will close the 954// http.Response Body if it receives an error. 955func (client ReplicationRecoveryPlansClient) UpdateSender(req *http.Request) (future ReplicationRecoveryPlansUpdateFuture, err error) { 956 var resp *http.Response 957 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 958 if err != nil { 959 return 960 } 961 var azf azure.Future 962 azf, err = azure.NewFutureFromResponse(resp) 963 future.FutureAPI = &azf 964 future.Result = future.result 965 return 966} 967 968// UpdateResponder handles the response to the Update request. The method always 969// closes the http.Response Body. 970func (client ReplicationRecoveryPlansClient) UpdateResponder(resp *http.Response) (result RecoveryPlan, err error) { 971 err = autorest.Respond( 972 resp, 973 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 974 autorest.ByUnmarshallingJSON(&result), 975 autorest.ByClosing()) 976 result.Response = autorest.Response{Response: resp} 977 return 978} 979