-
Notifications
You must be signed in to change notification settings - Fork 52
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
Feb 22, 2024
1 parent
f936156
commit f686e68
Showing
70 changed files
with
2,466 additions
and
2,888 deletions.
There are no files selected for viewing
22 changes: 15 additions & 7 deletions
22
resource-manager/servicefabric/2021-06-01/application/client.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 |
---|---|---|
@@ -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 | ||
} |
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/servicefabric/2021-06-01/application/method_createorupdate.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 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 | ||
} |
80 changes: 0 additions & 80 deletions
80
resource-manager/servicefabric/2021-06-01/application/method_createorupdate_autorest.go
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
resource-manager/servicefabric/2021-06-01/application/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,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 | ||
} |
78 changes: 0 additions & 78 deletions
78
resource-manager/servicefabric/2021-06-01/application/method_delete_autorest.go
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.