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/tracing" 14 "net/http" 15) 16 17// ReplicationFabricsClient is the client for the ReplicationFabrics methods of the Siterecovery service. 18type ReplicationFabricsClient struct { 19 BaseClient 20} 21 22// NewReplicationFabricsClient creates an instance of the ReplicationFabricsClient client. 23func NewReplicationFabricsClient(subscriptionID string, resourceGroupName string, resourceName string) ReplicationFabricsClient { 24 return NewReplicationFabricsClientWithBaseURI(DefaultBaseURI, subscriptionID, resourceGroupName, resourceName) 25} 26 27// NewReplicationFabricsClientWithBaseURI creates an instance of the ReplicationFabricsClient client using a custom 28// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure 29// stack). 30func NewReplicationFabricsClientWithBaseURI(baseURI string, subscriptionID string, resourceGroupName string, resourceName string) ReplicationFabricsClient { 31 return ReplicationFabricsClient{NewWithBaseURI(baseURI, subscriptionID, resourceGroupName, resourceName)} 32} 33 34// CheckConsistency the operation to perform a consistency check on the fabric. 35// Parameters: 36// fabricName - fabric name. 37func (client ReplicationFabricsClient) CheckConsistency(ctx context.Context, fabricName string) (result ReplicationFabricsCheckConsistencyFuture, err error) { 38 if tracing.IsEnabled() { 39 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.CheckConsistency") 40 defer func() { 41 sc := -1 42 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 43 sc = result.FutureAPI.Response().StatusCode 44 } 45 tracing.EndSpan(ctx, sc, err) 46 }() 47 } 48 req, err := client.CheckConsistencyPreparer(ctx, fabricName) 49 if err != nil { 50 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "CheckConsistency", nil, "Failure preparing request") 51 return 52 } 53 54 result, err = client.CheckConsistencySender(req) 55 if err != nil { 56 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "CheckConsistency", nil, "Failure sending request") 57 return 58 } 59 60 return 61} 62 63// CheckConsistencyPreparer prepares the CheckConsistency request. 64func (client ReplicationFabricsClient) CheckConsistencyPreparer(ctx context.Context, fabricName string) (*http.Request, error) { 65 pathParameters := map[string]interface{}{ 66 "fabricName": autorest.Encode("path", fabricName), 67 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 68 "resourceName": autorest.Encode("path", client.ResourceName), 69 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 70 } 71 72 const APIVersion = "2016-08-10" 73 queryParameters := map[string]interface{}{ 74 "api-version": APIVersion, 75 } 76 77 preparer := autorest.CreatePreparer( 78 autorest.AsPost(), 79 autorest.WithBaseURL(client.BaseURI), 80 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/checkConsistency", pathParameters), 81 autorest.WithQueryParameters(queryParameters)) 82 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 83} 84 85// CheckConsistencySender sends the CheckConsistency request. The method will close the 86// http.Response Body if it receives an error. 87func (client ReplicationFabricsClient) CheckConsistencySender(req *http.Request) (future ReplicationFabricsCheckConsistencyFuture, err error) { 88 var resp *http.Response 89 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 90 if err != nil { 91 return 92 } 93 var azf azure.Future 94 azf, err = azure.NewFutureFromResponse(resp) 95 future.FutureAPI = &azf 96 future.Result = future.result 97 return 98} 99 100// CheckConsistencyResponder handles the response to the CheckConsistency request. The method always 101// closes the http.Response Body. 102func (client ReplicationFabricsClient) CheckConsistencyResponder(resp *http.Response) (result Fabric, err error) { 103 err = autorest.Respond( 104 resp, 105 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 106 autorest.ByUnmarshallingJSON(&result), 107 autorest.ByClosing()) 108 result.Response = autorest.Response{Response: resp} 109 return 110} 111 112// Create the operation to create an Azure Site Recovery fabric (for e.g. Hyper-V site) 113// Parameters: 114// fabricName - name of the ASR fabric. 115// input - fabric creation input. 116func (client ReplicationFabricsClient) Create(ctx context.Context, fabricName string, input FabricCreationInput) (result ReplicationFabricsCreateFuture, err error) { 117 if tracing.IsEnabled() { 118 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Create") 119 defer func() { 120 sc := -1 121 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 122 sc = result.FutureAPI.Response().StatusCode 123 } 124 tracing.EndSpan(ctx, sc, err) 125 }() 126 } 127 req, err := client.CreatePreparer(ctx, fabricName, input) 128 if err != nil { 129 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Create", nil, "Failure preparing request") 130 return 131 } 132 133 result, err = client.CreateSender(req) 134 if err != nil { 135 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Create", nil, "Failure sending request") 136 return 137 } 138 139 return 140} 141 142// CreatePreparer prepares the Create request. 143func (client ReplicationFabricsClient) CreatePreparer(ctx context.Context, fabricName string, input FabricCreationInput) (*http.Request, error) { 144 pathParameters := map[string]interface{}{ 145 "fabricName": autorest.Encode("path", fabricName), 146 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 147 "resourceName": autorest.Encode("path", client.ResourceName), 148 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 149 } 150 151 const APIVersion = "2016-08-10" 152 queryParameters := map[string]interface{}{ 153 "api-version": APIVersion, 154 } 155 156 preparer := autorest.CreatePreparer( 157 autorest.AsContentType("application/json; charset=utf-8"), 158 autorest.AsPut(), 159 autorest.WithBaseURL(client.BaseURI), 160 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters), 161 autorest.WithJSON(input), 162 autorest.WithQueryParameters(queryParameters)) 163 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 164} 165 166// CreateSender sends the Create request. The method will close the 167// http.Response Body if it receives an error. 168func (client ReplicationFabricsClient) CreateSender(req *http.Request) (future ReplicationFabricsCreateFuture, err error) { 169 var resp *http.Response 170 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 171 if err != nil { 172 return 173 } 174 var azf azure.Future 175 azf, err = azure.NewFutureFromResponse(resp) 176 future.FutureAPI = &azf 177 future.Result = future.result 178 return 179} 180 181// CreateResponder handles the response to the Create request. The method always 182// closes the http.Response Body. 183func (client ReplicationFabricsClient) CreateResponder(resp *http.Response) (result Fabric, err error) { 184 err = autorest.Respond( 185 resp, 186 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 187 autorest.ByUnmarshallingJSON(&result), 188 autorest.ByClosing()) 189 result.Response = autorest.Response{Response: resp} 190 return 191} 192 193// Delete the operation to delete or remove an Azure Site Recovery fabric. 194// Parameters: 195// fabricName - ASR fabric to delete 196func (client ReplicationFabricsClient) Delete(ctx context.Context, fabricName string) (result ReplicationFabricsDeleteFuture, err error) { 197 if tracing.IsEnabled() { 198 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Delete") 199 defer func() { 200 sc := -1 201 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 202 sc = result.FutureAPI.Response().StatusCode 203 } 204 tracing.EndSpan(ctx, sc, err) 205 }() 206 } 207 req, err := client.DeletePreparer(ctx, fabricName) 208 if err != nil { 209 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Delete", nil, "Failure preparing request") 210 return 211 } 212 213 result, err = client.DeleteSender(req) 214 if err != nil { 215 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Delete", nil, "Failure sending request") 216 return 217 } 218 219 return 220} 221 222// DeletePreparer prepares the Delete request. 223func (client ReplicationFabricsClient) DeletePreparer(ctx context.Context, fabricName string) (*http.Request, error) { 224 pathParameters := map[string]interface{}{ 225 "fabricName": autorest.Encode("path", fabricName), 226 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 227 "resourceName": autorest.Encode("path", client.ResourceName), 228 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 229 } 230 231 const APIVersion = "2016-08-10" 232 queryParameters := map[string]interface{}{ 233 "api-version": APIVersion, 234 } 235 236 preparer := autorest.CreatePreparer( 237 autorest.AsPost(), 238 autorest.WithBaseURL(client.BaseURI), 239 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/remove", pathParameters), 240 autorest.WithQueryParameters(queryParameters)) 241 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 242} 243 244// DeleteSender sends the Delete request. The method will close the 245// http.Response Body if it receives an error. 246func (client ReplicationFabricsClient) DeleteSender(req *http.Request) (future ReplicationFabricsDeleteFuture, err error) { 247 var resp *http.Response 248 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 249 if err != nil { 250 return 251 } 252 var azf azure.Future 253 azf, err = azure.NewFutureFromResponse(resp) 254 future.FutureAPI = &azf 255 future.Result = future.result 256 return 257} 258 259// DeleteResponder handles the response to the Delete request. The method always 260// closes the http.Response Body. 261func (client ReplicationFabricsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 262 err = autorest.Respond( 263 resp, 264 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 265 autorest.ByClosing()) 266 result.Response = resp 267 return 268} 269 270// Get gets the details of an Azure Site Recovery fabric. 271// Parameters: 272// fabricName - fabric name. 273func (client ReplicationFabricsClient) Get(ctx context.Context, fabricName string) (result Fabric, err error) { 274 if tracing.IsEnabled() { 275 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Get") 276 defer func() { 277 sc := -1 278 if result.Response.Response != nil { 279 sc = result.Response.Response.StatusCode 280 } 281 tracing.EndSpan(ctx, sc, err) 282 }() 283 } 284 req, err := client.GetPreparer(ctx, fabricName) 285 if err != nil { 286 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Get", nil, "Failure preparing request") 287 return 288 } 289 290 resp, err := client.GetSender(req) 291 if err != nil { 292 result.Response = autorest.Response{Response: resp} 293 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Get", resp, "Failure sending request") 294 return 295 } 296 297 result, err = client.GetResponder(resp) 298 if err != nil { 299 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Get", resp, "Failure responding to request") 300 return 301 } 302 303 return 304} 305 306// GetPreparer prepares the Get request. 307func (client ReplicationFabricsClient) GetPreparer(ctx context.Context, fabricName string) (*http.Request, error) { 308 pathParameters := map[string]interface{}{ 309 "fabricName": autorest.Encode("path", fabricName), 310 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 311 "resourceName": autorest.Encode("path", client.ResourceName), 312 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 313 } 314 315 const APIVersion = "2016-08-10" 316 queryParameters := map[string]interface{}{ 317 "api-version": APIVersion, 318 } 319 320 preparer := autorest.CreatePreparer( 321 autorest.AsGet(), 322 autorest.WithBaseURL(client.BaseURI), 323 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters), 324 autorest.WithQueryParameters(queryParameters)) 325 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 326} 327 328// GetSender sends the Get request. The method will close the 329// http.Response Body if it receives an error. 330func (client ReplicationFabricsClient) GetSender(req *http.Request) (*http.Response, error) { 331 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 332} 333 334// GetResponder handles the response to the Get request. The method always 335// closes the http.Response Body. 336func (client ReplicationFabricsClient) GetResponder(resp *http.Response) (result Fabric, err error) { 337 err = autorest.Respond( 338 resp, 339 azure.WithErrorUnlessStatusCode(http.StatusOK), 340 autorest.ByUnmarshallingJSON(&result), 341 autorest.ByClosing()) 342 result.Response = autorest.Response{Response: resp} 343 return 344} 345 346// List gets a list of the Azure Site Recovery fabrics in the vault. 347func (client ReplicationFabricsClient) List(ctx context.Context) (result FabricCollectionPage, err error) { 348 if tracing.IsEnabled() { 349 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.List") 350 defer func() { 351 sc := -1 352 if result.fc.Response.Response != nil { 353 sc = result.fc.Response.Response.StatusCode 354 } 355 tracing.EndSpan(ctx, sc, err) 356 }() 357 } 358 result.fn = client.listNextResults 359 req, err := client.ListPreparer(ctx) 360 if err != nil { 361 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "List", nil, "Failure preparing request") 362 return 363 } 364 365 resp, err := client.ListSender(req) 366 if err != nil { 367 result.fc.Response = autorest.Response{Response: resp} 368 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "List", resp, "Failure sending request") 369 return 370 } 371 372 result.fc, err = client.ListResponder(resp) 373 if err != nil { 374 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "List", resp, "Failure responding to request") 375 return 376 } 377 if result.fc.hasNextLink() && result.fc.IsEmpty() { 378 err = result.NextWithContext(ctx) 379 return 380 } 381 382 return 383} 384 385// ListPreparer prepares the List request. 386func (client ReplicationFabricsClient) ListPreparer(ctx context.Context) (*http.Request, error) { 387 pathParameters := map[string]interface{}{ 388 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 389 "resourceName": autorest.Encode("path", client.ResourceName), 390 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 391 } 392 393 const APIVersion = "2016-08-10" 394 queryParameters := map[string]interface{}{ 395 "api-version": APIVersion, 396 } 397 398 preparer := autorest.CreatePreparer( 399 autorest.AsGet(), 400 autorest.WithBaseURL(client.BaseURI), 401 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics", pathParameters), 402 autorest.WithQueryParameters(queryParameters)) 403 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 404} 405 406// ListSender sends the List request. The method will close the 407// http.Response Body if it receives an error. 408func (client ReplicationFabricsClient) ListSender(req *http.Request) (*http.Response, error) { 409 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 410} 411 412// ListResponder handles the response to the List request. The method always 413// closes the http.Response Body. 414func (client ReplicationFabricsClient) ListResponder(resp *http.Response) (result FabricCollection, err error) { 415 err = autorest.Respond( 416 resp, 417 azure.WithErrorUnlessStatusCode(http.StatusOK), 418 autorest.ByUnmarshallingJSON(&result), 419 autorest.ByClosing()) 420 result.Response = autorest.Response{Response: resp} 421 return 422} 423 424// listNextResults retrieves the next set of results, if any. 425func (client ReplicationFabricsClient) listNextResults(ctx context.Context, lastResults FabricCollection) (result FabricCollection, err error) { 426 req, err := lastResults.fabricCollectionPreparer(ctx) 427 if err != nil { 428 return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "listNextResults", nil, "Failure preparing next results request") 429 } 430 if req == nil { 431 return 432 } 433 resp, err := client.ListSender(req) 434 if err != nil { 435 result.Response = autorest.Response{Response: resp} 436 return result, autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "listNextResults", resp, "Failure sending next results request") 437 } 438 result, err = client.ListResponder(resp) 439 if err != nil { 440 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "listNextResults", resp, "Failure responding to next results request") 441 } 442 return 443} 444 445// ListComplete enumerates all values, automatically crossing page boundaries as required. 446func (client ReplicationFabricsClient) ListComplete(ctx context.Context) (result FabricCollectionIterator, err error) { 447 if tracing.IsEnabled() { 448 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.List") 449 defer func() { 450 sc := -1 451 if result.Response().Response.Response != nil { 452 sc = result.page.Response().Response.Response.StatusCode 453 } 454 tracing.EndSpan(ctx, sc, err) 455 }() 456 } 457 result.page, err = client.List(ctx) 458 return 459} 460 461// MigrateToAad the operation to migrate an Azure Site Recovery fabric to AAD. 462// Parameters: 463// fabricName - ASR fabric to migrate. 464func (client ReplicationFabricsClient) MigrateToAad(ctx context.Context, fabricName string) (result ReplicationFabricsMigrateToAadFuture, err error) { 465 if tracing.IsEnabled() { 466 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.MigrateToAad") 467 defer func() { 468 sc := -1 469 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 470 sc = result.FutureAPI.Response().StatusCode 471 } 472 tracing.EndSpan(ctx, sc, err) 473 }() 474 } 475 req, err := client.MigrateToAadPreparer(ctx, fabricName) 476 if err != nil { 477 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "MigrateToAad", nil, "Failure preparing request") 478 return 479 } 480 481 result, err = client.MigrateToAadSender(req) 482 if err != nil { 483 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "MigrateToAad", nil, "Failure sending request") 484 return 485 } 486 487 return 488} 489 490// MigrateToAadPreparer prepares the MigrateToAad request. 491func (client ReplicationFabricsClient) MigrateToAadPreparer(ctx context.Context, fabricName string) (*http.Request, error) { 492 pathParameters := map[string]interface{}{ 493 "fabricName": autorest.Encode("path", fabricName), 494 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 495 "resourceName": autorest.Encode("path", client.ResourceName), 496 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 497 } 498 499 const APIVersion = "2016-08-10" 500 queryParameters := map[string]interface{}{ 501 "api-version": APIVersion, 502 } 503 504 preparer := autorest.CreatePreparer( 505 autorest.AsPost(), 506 autorest.WithBaseURL(client.BaseURI), 507 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/migratetoaad", pathParameters), 508 autorest.WithQueryParameters(queryParameters)) 509 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 510} 511 512// MigrateToAadSender sends the MigrateToAad request. The method will close the 513// http.Response Body if it receives an error. 514func (client ReplicationFabricsClient) MigrateToAadSender(req *http.Request) (future ReplicationFabricsMigrateToAadFuture, err error) { 515 var resp *http.Response 516 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 517 if err != nil { 518 return 519 } 520 var azf azure.Future 521 azf, err = azure.NewFutureFromResponse(resp) 522 future.FutureAPI = &azf 523 future.Result = future.result 524 return 525} 526 527// MigrateToAadResponder handles the response to the MigrateToAad request. The method always 528// closes the http.Response Body. 529func (client ReplicationFabricsClient) MigrateToAadResponder(resp *http.Response) (result autorest.Response, err error) { 530 err = autorest.Respond( 531 resp, 532 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 533 autorest.ByClosing()) 534 result.Response = resp 535 return 536} 537 538// Purge the operation to purge(force delete) an Azure Site Recovery fabric. 539// Parameters: 540// fabricName - ASR fabric to purge. 541func (client ReplicationFabricsClient) Purge(ctx context.Context, fabricName string) (result ReplicationFabricsPurgeFuture, err error) { 542 if tracing.IsEnabled() { 543 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.Purge") 544 defer func() { 545 sc := -1 546 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 547 sc = result.FutureAPI.Response().StatusCode 548 } 549 tracing.EndSpan(ctx, sc, err) 550 }() 551 } 552 req, err := client.PurgePreparer(ctx, fabricName) 553 if err != nil { 554 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Purge", nil, "Failure preparing request") 555 return 556 } 557 558 result, err = client.PurgeSender(req) 559 if err != nil { 560 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "Purge", nil, "Failure sending request") 561 return 562 } 563 564 return 565} 566 567// PurgePreparer prepares the Purge request. 568func (client ReplicationFabricsClient) PurgePreparer(ctx context.Context, fabricName string) (*http.Request, error) { 569 pathParameters := map[string]interface{}{ 570 "fabricName": autorest.Encode("path", fabricName), 571 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 572 "resourceName": autorest.Encode("path", client.ResourceName), 573 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 574 } 575 576 const APIVersion = "2016-08-10" 577 queryParameters := map[string]interface{}{ 578 "api-version": APIVersion, 579 } 580 581 preparer := autorest.CreatePreparer( 582 autorest.AsDelete(), 583 autorest.WithBaseURL(client.BaseURI), 584 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}", pathParameters), 585 autorest.WithQueryParameters(queryParameters)) 586 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 587} 588 589// PurgeSender sends the Purge request. The method will close the 590// http.Response Body if it receives an error. 591func (client ReplicationFabricsClient) PurgeSender(req *http.Request) (future ReplicationFabricsPurgeFuture, err error) { 592 var resp *http.Response 593 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 594 if err != nil { 595 return 596 } 597 var azf azure.Future 598 azf, err = azure.NewFutureFromResponse(resp) 599 future.FutureAPI = &azf 600 future.Result = future.result 601 return 602} 603 604// PurgeResponder handles the response to the Purge request. The method always 605// closes the http.Response Body. 606func (client ReplicationFabricsClient) PurgeResponder(resp *http.Response) (result autorest.Response, err error) { 607 err = autorest.Respond( 608 resp, 609 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), 610 autorest.ByClosing()) 611 result.Response = resp 612 return 613} 614 615// ReassociateGateway the operation to move replications from a process server to another process server. 616// Parameters: 617// fabricName - the name of the fabric containing the process server. 618// failoverProcessServerRequest - the input to the failover process server operation. 619func (client ReplicationFabricsClient) ReassociateGateway(ctx context.Context, fabricName string, failoverProcessServerRequest FailoverProcessServerRequest) (result ReplicationFabricsReassociateGatewayFuture, err error) { 620 if tracing.IsEnabled() { 621 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.ReassociateGateway") 622 defer func() { 623 sc := -1 624 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 625 sc = result.FutureAPI.Response().StatusCode 626 } 627 tracing.EndSpan(ctx, sc, err) 628 }() 629 } 630 req, err := client.ReassociateGatewayPreparer(ctx, fabricName, failoverProcessServerRequest) 631 if err != nil { 632 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "ReassociateGateway", nil, "Failure preparing request") 633 return 634 } 635 636 result, err = client.ReassociateGatewaySender(req) 637 if err != nil { 638 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "ReassociateGateway", nil, "Failure sending request") 639 return 640 } 641 642 return 643} 644 645// ReassociateGatewayPreparer prepares the ReassociateGateway request. 646func (client ReplicationFabricsClient) ReassociateGatewayPreparer(ctx context.Context, fabricName string, failoverProcessServerRequest FailoverProcessServerRequest) (*http.Request, error) { 647 pathParameters := map[string]interface{}{ 648 "fabricName": autorest.Encode("path", fabricName), 649 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 650 "resourceName": autorest.Encode("path", client.ResourceName), 651 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 652 } 653 654 const APIVersion = "2016-08-10" 655 queryParameters := map[string]interface{}{ 656 "api-version": APIVersion, 657 } 658 659 preparer := autorest.CreatePreparer( 660 autorest.AsContentType("application/json; charset=utf-8"), 661 autorest.AsPost(), 662 autorest.WithBaseURL(client.BaseURI), 663 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/reassociateGateway", pathParameters), 664 autorest.WithJSON(failoverProcessServerRequest), 665 autorest.WithQueryParameters(queryParameters)) 666 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 667} 668 669// ReassociateGatewaySender sends the ReassociateGateway request. The method will close the 670// http.Response Body if it receives an error. 671func (client ReplicationFabricsClient) ReassociateGatewaySender(req *http.Request) (future ReplicationFabricsReassociateGatewayFuture, err error) { 672 var resp *http.Response 673 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 674 if err != nil { 675 return 676 } 677 var azf azure.Future 678 azf, err = azure.NewFutureFromResponse(resp) 679 future.FutureAPI = &azf 680 future.Result = future.result 681 return 682} 683 684// ReassociateGatewayResponder handles the response to the ReassociateGateway request. The method always 685// closes the http.Response Body. 686func (client ReplicationFabricsClient) ReassociateGatewayResponder(resp *http.Response) (result Fabric, err error) { 687 err = autorest.Respond( 688 resp, 689 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 690 autorest.ByUnmarshallingJSON(&result), 691 autorest.ByClosing()) 692 result.Response = autorest.Response{Response: resp} 693 return 694} 695 696// RenewCertificate renews the connection certificate for the ASR replication fabric. 697// Parameters: 698// fabricName - fabric name to renew certs for. 699// renewCertificate - renew certificate input. 700func (client ReplicationFabricsClient) RenewCertificate(ctx context.Context, fabricName string, renewCertificate RenewCertificateInput) (result ReplicationFabricsRenewCertificateFuture, err error) { 701 if tracing.IsEnabled() { 702 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationFabricsClient.RenewCertificate") 703 defer func() { 704 sc := -1 705 if result.FutureAPI != nil && result.FutureAPI.Response() != nil { 706 sc = result.FutureAPI.Response().StatusCode 707 } 708 tracing.EndSpan(ctx, sc, err) 709 }() 710 } 711 req, err := client.RenewCertificatePreparer(ctx, fabricName, renewCertificate) 712 if err != nil { 713 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "RenewCertificate", nil, "Failure preparing request") 714 return 715 } 716 717 result, err = client.RenewCertificateSender(req) 718 if err != nil { 719 err = autorest.NewErrorWithError(err, "siterecovery.ReplicationFabricsClient", "RenewCertificate", nil, "Failure sending request") 720 return 721 } 722 723 return 724} 725 726// RenewCertificatePreparer prepares the RenewCertificate request. 727func (client ReplicationFabricsClient) RenewCertificatePreparer(ctx context.Context, fabricName string, renewCertificate RenewCertificateInput) (*http.Request, error) { 728 pathParameters := map[string]interface{}{ 729 "fabricName": autorest.Encode("path", fabricName), 730 "resourceGroupName": autorest.Encode("path", client.ResourceGroupName), 731 "resourceName": autorest.Encode("path", client.ResourceName), 732 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 733 } 734 735 const APIVersion = "2016-08-10" 736 queryParameters := map[string]interface{}{ 737 "api-version": APIVersion, 738 } 739 740 preparer := autorest.CreatePreparer( 741 autorest.AsContentType("application/json; charset=utf-8"), 742 autorest.AsPost(), 743 autorest.WithBaseURL(client.BaseURI), 744 autorest.WithPathParameters("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RecoveryServices/vaults/{resourceName}/replicationFabrics/{fabricName}/renewCertificate", pathParameters), 745 autorest.WithJSON(renewCertificate), 746 autorest.WithQueryParameters(queryParameters)) 747 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 748} 749 750// RenewCertificateSender sends the RenewCertificate request. The method will close the 751// http.Response Body if it receives an error. 752func (client ReplicationFabricsClient) RenewCertificateSender(req *http.Request) (future ReplicationFabricsRenewCertificateFuture, err error) { 753 var resp *http.Response 754 resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) 755 if err != nil { 756 return 757 } 758 var azf azure.Future 759 azf, err = azure.NewFutureFromResponse(resp) 760 future.FutureAPI = &azf 761 future.Result = future.result 762 return 763} 764 765// RenewCertificateResponder handles the response to the RenewCertificate request. The method always 766// closes the http.Response Body. 767func (client ReplicationFabricsClient) RenewCertificateResponder(resp *http.Response) (result Fabric, err error) { 768 err = autorest.Respond( 769 resp, 770 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), 771 autorest.ByUnmarshallingJSON(&result), 772 autorest.ByClosing()) 773 result.Response = autorest.Response{Response: resp} 774 return 775} 776