-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hc-github-team-tf-azure
committed
Jan 12, 2024
1 parent
465cf1a
commit a476e69
Showing
248 changed files
with
9,282 additions
and
12,341 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
resource-manager/datashare/2019-11-01/account/method_create.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
79 changes: 0 additions & 79 deletions
79
resource-manager/datashare/2019-11-01/account/method_create_autorest.go
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
resource-manager/datashare/2019-11-01/account/method_delete.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
78 changes: 0 additions & 78 deletions
78
resource-manager/datashare/2019-11-01/account/method_delete_autorest.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.