-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Resource: azurerm_site_recovery_hyperv_replicated_vm
#20838
Changes from 10 commits
20d2a9f
c0afd52
b25df03
ee9d7c4
84fdc6e
70270de
52ef38c
eb68423
b09c9a6
e4bbcde
cd0d960
87851fd
c96e43b
20b1837
3827736
64e8950
7d90678
e186fa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package azuresdkhacks | ||
|
||
import "github.com/Azure/go-autorest/autorest" | ||
|
||
// TODO 4.0: check if this is could be removed | ||
// workaround for https://github.com/Azure/azure-rest-api-specs/issues/22947 | ||
|
||
type ReplicationProtectedItemsClient struct { | ||
Client autorest.Client | ||
BaseUri string | ||
} | ||
|
||
func NewReplicationProtectedItemsClientWithBaseURI(endpoint string) ReplicationProtectedItemsClient { | ||
return ReplicationProtectedItemsClient{ | ||
Client: autorest.NewClientWithUserAgent(userAgent()), | ||
BaseUri: endpoint, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package azuresdkhacks | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/Azure/go-autorest/autorest" | ||
"github.com/Azure/go-autorest/autorest/azure" | ||
"github.com/hashicorp/go-azure-helpers/polling" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/recoveryservicessiterecovery/2022-10-01/replicationprotecteditems" | ||
) | ||
|
||
type DeleteOperationResponse struct { | ||
Poller polling.LongRunningPoller | ||
HttpResponse *http.Response | ||
} | ||
|
||
// Delete ... | ||
func (c ReplicationProtectedItemsClient) Delete(ctx context.Context, id replicationprotecteditems.ReplicationProtectedItemId, input DisableProtectionInput) (result DeleteOperationResponse, err error) { | ||
req, err := c.preparerForDelete(ctx, id, input) | ||
if err != nil { | ||
err = autorest.NewErrorWithError(err, "replicationprotecteditems.ReplicationProtectedItemsClient", "Delete", nil, "Failure preparing request") | ||
return | ||
} | ||
|
||
result, err = c.senderForDelete(ctx, req) | ||
if err != nil { | ||
err = autorest.NewErrorWithError(err, "replicationprotecteditems.ReplicationProtectedItemsClient", "Delete", result.HttpResponse, "Failure sending request") | ||
return | ||
} | ||
|
||
return | ||
} | ||
|
||
// DeleteThenPoll performs Delete then polls until it's completed | ||
func (c ReplicationProtectedItemsClient) DeleteThenPoll(ctx context.Context, id replicationprotecteditems.ReplicationProtectedItemId, input DisableProtectionInput) error { | ||
result, err := c.Delete(ctx, id, input) | ||
if err != nil { | ||
return fmt.Errorf("performing Delete: %+v", err) | ||
} | ||
|
||
if err := result.Poller.PollUntilDone(); err != nil { | ||
return fmt.Errorf("polling after Delete: %+v", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// preparerForDelete prepares the Delete request. | ||
func (c ReplicationProtectedItemsClient) preparerForDelete(ctx context.Context, id replicationprotecteditems.ReplicationProtectedItemId, input DisableProtectionInput) (*http.Request, error) { | ||
queryParameters := map[string]interface{}{ | ||
"api-version": defaultApiVersion, | ||
} | ||
|
||
preparer := autorest.CreatePreparer( | ||
autorest.AsContentType("application/json; charset=utf-8"), | ||
autorest.AsPost(), | ||
autorest.WithBaseURL(c.BaseUri), | ||
autorest.WithPath(fmt.Sprintf("%s/remove", id.ID())), | ||
autorest.WithJSON(input), | ||
autorest.WithQueryParameters(queryParameters)) | ||
return preparer.Prepare((&http.Request{}).WithContext(ctx)) | ||
} | ||
|
||
// senderForDelete sends the Delete request. The method will close the | ||
// http.Response Body if it receives an error. | ||
func (c ReplicationProtectedItemsClient) senderForDelete(ctx context.Context, req *http.Request) (future DeleteOperationResponse, err error) { | ||
var resp *http.Response | ||
resp, err = c.Client.Send(req, azure.DoRetryWithRegistration(c.Client)) | ||
if err != nil { | ||
return | ||
} | ||
|
||
future.Poller, err = polling.NewPollerFromResponse(ctx, resp, c.Client, req.Method) | ||
return | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package azuresdkhacks | ||
|
||
type DisableProtectionInput struct { | ||
Properties EmptyInput `json:"properties"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the model here, since
Should output:
But actually outputs:
As such this looks to be something we can workaround in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here you go: hashicorp/go-azure-sdk#387 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just want to confirm if we need to wait for the |
||
} | ||
|
||
type EmptyInput struct { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue on
hashicorp/go-azure-sdk
to track this? We can likely workaround this there