Skip to content

Commit

Permalink
Updating based on 6b757ee9
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Feb 22, 2024
1 parent f936156 commit f686e68
Show file tree
Hide file tree
Showing 70 changed files with 2,466 additions and 2,888 deletions.
22 changes: 15 additions & 7 deletions resource-manager/servicefabric/2021-06-01/application/client.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package application

import "github.com/Azure/go-autorest/autorest"
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

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

type ApplicationClient struct {
Client autorest.Client
baseUri string
Client *resourcemanager.Client
}

func NewApplicationClientWithBaseURI(endpoint string) ApplicationClient {
return ApplicationClient{
Client: autorest.NewClientWithUserAgent(userAgent()),
baseUri: endpoint,
func NewApplicationClientWithBaseURI(sdkApi sdkEnv.Api) (*ApplicationClient, error) {
client, err := resourcemanager.NewResourceManagerClient(sdkApi, "application", defaultApiVersion)
if err != nil {
return nil, fmt.Errorf("instantiating ApplicationClient: %+v", err)
}

return &ApplicationClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package application

import "strings"
import (
"encoding/json"
"fmt"
"strings"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
Expand All @@ -19,6 +23,19 @@ func PossibleValuesForArmUpgradeFailureAction() []string {
}
}

func (s *ArmUpgradeFailureAction) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseArmUpgradeFailureAction(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseArmUpgradeFailureAction(input string) (*ArmUpgradeFailureAction, error) {
vals := map[string]ArmUpgradeFailureAction{
"manual": ArmUpgradeFailureActionManual,
Expand Down Expand Up @@ -51,6 +68,19 @@ func PossibleValuesForRollingUpgradeMode() []string {
}
}

func (s *RollingUpgradeMode) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseRollingUpgradeMode(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseRollingUpgradeMode(input string) (*RollingUpgradeMode, error) {
vals := map[string]RollingUpgradeMode{
"invalid": RollingUpgradeModeInvalid,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package application

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 CreateOrUpdateOperationResponse struct {
Poller pollers.Poller
HttpResponse *http.Response
OData *odata.OData
Model *ApplicationResource
}

// CreateOrUpdate ...
func (c ApplicationClient) CreateOrUpdate(ctx context.Context, id ApplicationId, input ApplicationResource) (result CreateOrUpdateOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusAccepted,
},
HttpMethod: http.MethodPut,
Path: id.ID(),
}

req, err := c.Client.NewRequest(ctx, opts)
if err != nil {
return
}

if err = req.Marshal(input); err != nil {
return
}

var resp *client.Response
resp, err = req.Execute(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
}
if err != nil {
return
}

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

return
}

// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed
func (c ApplicationClient) CreateOrUpdateThenPoll(ctx context.Context, id ApplicationId, input ApplicationResource) error {
result, err := c.CreateOrUpdate(ctx, id, input)
if err != nil {
return fmt.Errorf("performing CreateOrUpdate: %+v", err)
}

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

return nil
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package application

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 DeleteOperationResponse struct {
Poller pollers.Poller
HttpResponse *http.Response
OData *odata.OData
}

// Delete ...
func (c ApplicationClient) Delete(ctx context.Context, id ApplicationId) (result DeleteOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusAccepted,
http.StatusNoContent,
},
HttpMethod: http.MethodDelete,
Path: id.ID(),
}

req, err := c.Client.NewRequest(ctx, opts)
if err != nil {
return
}

var resp *client.Response
resp, err = req.Execute(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
}
if err != nil {
return
}

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

return
}

// DeleteThenPoll performs Delete then polls until it's completed
func (c ApplicationClient) DeleteThenPoll(ctx context.Context, id ApplicationId) error {
result, err := c.Delete(ctx, id)
if err != nil {
return fmt.Errorf("performing Delete: %+v", err)
}

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

return nil
}

This file was deleted.

Loading

0 comments on commit f686e68

Please sign in to comment.