Skip to content
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

Auto PR: Regenerating the Go SDK (122d2efa2a1c2b0d1b95fd3a0b577a9d27f88adb) #937

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,7 @@ payload := clusters.ClusterPatch{
}


read, err := client.Update(ctx, id, payload)
if err != nil {
if err := client.UpdateThenPoll(ctx, id, payload); err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ package clusters

import (
"context"
"fmt"
"net/http"

"github.com/hashicorp/go-azure-sdk/sdk/client"
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type UpdateOperationResponse struct {
Poller pollers.Poller
HttpResponse *http.Response
OData *odata.OData
Model *Cluster
Expand All @@ -22,6 +26,7 @@ func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterP
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusAccepted,
http.StatusOK,
},
HttpMethod: http.MethodPatch,
Expand All @@ -47,12 +52,24 @@ func (c ClustersClient) Update(ctx context.Context, id ClusterId, input ClusterP
return
}

var model Cluster
result.Model = &model

if err = resp.Unmarshal(result.Model); err != nil {
result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client)
if err != nil {
return
}

return
}

// UpdateThenPoll performs Update then polls until it's completed
func (c ClustersClient) UpdateThenPoll(ctx context.Context, id ClusterId, input ClusterPatch) error {
result, err := c.Update(ctx, id, input)
if err != nil {
return fmt.Errorf("performing Update: %+v", err)
}

if err := result.Poller.PollUntilDone(ctx); err != nil {
return fmt.Errorf("polling after Update: %+v", err)
}

return nil
}
Loading