Skip to content

Commit

Permalink
Updating based on 560c0673
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed May 16, 2024
1 parent a6e535c commit 948cd6d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ const (
ExpressionV2TypeBinary ExpressionV2Type = "Binary"
ExpressionV2TypeConstant ExpressionV2Type = "Constant"
ExpressionV2TypeField ExpressionV2Type = "Field"
ExpressionV2TypeNAry ExpressionV2Type = "NAry"
ExpressionV2TypeUnary ExpressionV2Type = "Unary"
)

Expand All @@ -589,6 +590,7 @@ func PossibleValuesForExpressionV2Type() []string {
string(ExpressionV2TypeBinary),
string(ExpressionV2TypeConstant),
string(ExpressionV2TypeField),
string(ExpressionV2TypeNAry),
string(ExpressionV2TypeUnary),
}
}
Expand All @@ -611,6 +613,7 @@ func parseExpressionV2Type(input string) (*ExpressionV2Type, error) {
"binary": ExpressionV2TypeBinary,
"constant": ExpressionV2TypeConstant,
"field": ExpressionV2TypeField,
"nary": ExpressionV2TypeNAry,
"unary": ExpressionV2TypeUnary,
}
if v, ok := vals[strings.ToLower(input)]; ok {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package pipelines
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ExpressionV2 struct {
Operands *[]ExpressionV2 `json:"operands,omitempty"`
Operator *string `json:"operator,omitempty"`
Type *ExpressionV2Type `json:"type,omitempty"`
Value *string `json:"value,omitempty"`
Operands *[]ExpressionV2 `json:"operands,omitempty"`
Operators *[]string `json:"operators,omitempty"`
Type *ExpressionV2Type `json:"type,omitempty"`
Value *string `json:"value,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,9 @@ payload := networkvirtualappliances.NetworkVirtualApplianceInstanceIds{
}


read, err := client.Restart(ctx, id, payload)
if err != nil {
if err := client.RestartThenPoll(ctx, id, payload); err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
}
```


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,27 @@ import (
"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 RestartOperationResponse struct {
Poller pollers.Poller
HttpResponse *http.Response
OData *odata.OData
Model *NetworkVirtualApplianceInstanceIds
}

// Restart ...
func (c NetworkVirtualAppliancesClient) Restart(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceInstanceIds) (result RestartOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusAccepted,
http.StatusOK,
},
HttpMethod: http.MethodPost,
Expand All @@ -47,5 +52,24 @@ func (c NetworkVirtualAppliancesClient) Restart(ctx context.Context, id NetworkV
return
}

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

return
}

// RestartThenPoll performs Restart then polls until it's completed
func (c NetworkVirtualAppliancesClient) RestartThenPoll(ctx context.Context, id NetworkVirtualApplianceId, input NetworkVirtualApplianceInstanceIds) error {
result, err := c.Restart(ctx, id, input)
if err != nil {
return fmt.Errorf("performing Restart: %+v", err)
}

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

return nil
}

0 comments on commit 948cd6d

Please sign in to comment.