Skip to content

Commit

Permalink
Updating based on 3b3c7b35
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Feb 15, 2024
1 parent 0af028f commit 186194b
Show file tree
Hide file tree
Showing 45 changed files with 1,845 additions and 2,210 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package availabilitygrouplisteners

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

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

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

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 PossibleValuesForCommit() []string {
}
}

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

func parseCommit(input string) (*Commit, error) {
vals := map[string]Commit{
"asynchronous_commit": CommitAsynchronousCommit,
Expand Down Expand Up @@ -47,6 +64,19 @@ func PossibleValuesForFailover() []string {
}
}

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

func parseFailover(input string) (*Failover, error) {
vals := map[string]Failover{
"automatic": FailoverAutomatic,
Expand Down Expand Up @@ -77,6 +107,19 @@ func PossibleValuesForReadableSecondary() []string {
}
}

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

func parseReadableSecondary(input string) (*ReadableSecondary, error) {
vals := map[string]ReadableSecondary{
"all": ReadableSecondaryAll,
Expand Down Expand Up @@ -106,6 +149,19 @@ func PossibleValuesForRole() []string {
}
}

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

func parseRole(input string) (*Role, error) {
vals := map[string]Role{
"primary": RolePrimary,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package availabilitygrouplisteners

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 *AvailabilityGroupListener
}

// CreateOrUpdate ...
func (c AvailabilityGroupListenersClient) CreateOrUpdate(ctx context.Context, id AvailabilityGroupListenerId, input AvailabilityGroupListener) (result CreateOrUpdateOperationResponse, 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
}

// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed
func (c AvailabilityGroupListenersClient) CreateOrUpdateThenPoll(ctx context.Context, id AvailabilityGroupListenerId, input AvailabilityGroupListener) 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,71 @@
package availabilitygrouplisteners

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 AvailabilityGroupListenersClient) Delete(ctx context.Context, id AvailabilityGroupListenerId) (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 AvailabilityGroupListenersClient) DeleteThenPoll(ctx context.Context, id AvailabilityGroupListenerId) 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
}
Loading

0 comments on commit 186194b

Please sign in to comment.