Skip to content

Commit

Permalink
Updating based on 039fd2043
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Jan 12, 2024
1 parent 465cf1a commit a476e69
Show file tree
Hide file tree
Showing 248 changed files with 9,282 additions and 12,341 deletions.
22 changes: 15 additions & 7 deletions resource-manager/datashare/2019-11-01/account/client.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package account

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 AccountClient struct {
Client autorest.Client
baseUri string
Client *resourcemanager.Client
}

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

return &AccountClient{
Client: client,
}, nil
}
32 changes: 31 additions & 1 deletion resource-manager/datashare/2019-11-01/account/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package account

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 @@ -25,6 +29,19 @@ func PossibleValuesForProvisioningState() []string {
}
}

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

func parseProvisioningState(input string) (*ProvisioningState, error) {
vals := map[string]ProvisioningState{
"creating": ProvisioningStateCreating,
Expand Down Expand Up @@ -64,6 +81,19 @@ func PossibleValuesForStatus() []string {
}
}

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

func parseStatus(input string) (*Status, error) {
vals := map[string]Status{
"accepted": StatusAccepted,
Expand Down
74 changes: 74 additions & 0 deletions resource-manager/datashare/2019-11-01/account/method_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package account

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

// Create ...
func (c AccountClient) Create(ctx context.Context, id AccountId, input Account) (result CreateOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusCreated,
http.StatusOK,
},
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
}

// CreateThenPoll performs Create then polls until it's completed
func (c AccountClient) CreateThenPoll(ctx context.Context, id AccountId, input Account) error {
result, err := c.Create(ctx, id, input)
if err != nil {
return fmt.Errorf("performing Create: %+v", err)
}

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

return nil
}

This file was deleted.

71 changes: 71 additions & 0 deletions resource-manager/datashare/2019-11-01/account/method_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package account

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 AccountClient) Delete(ctx context.Context, id AccountId) (result DeleteOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusAccepted,
http.StatusNoContent,
http.StatusOK,
},
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 AccountClient) DeleteThenPoll(ctx context.Context, id AccountId) 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 a476e69

Please sign in to comment.