Skip to content

Commit

Permalink
Merge pull request hashicorp#629 from hashicorp/auto-pr/168a8a542
Browse files Browse the repository at this point in the history
Auto PR: Regenerating the Go SDK (d33f4be)
  • Loading branch information
stephybun authored Aug 23, 2023
2 parents ac1b51b + d33f4be commit fbf2e93
Show file tree
Hide file tree
Showing 151 changed files with 4,868 additions and 5,925 deletions.
57 changes: 37 additions & 20 deletions resource-manager/trafficmanager/2018-08-01/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ package v2018_08_01
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

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

"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/endpoints"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/geographichierarchies"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/heatmaps"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/profiles"
"github.com/hashicorp/go-azure-sdk/resource-manager/trafficmanager/2018-08-01/realusermetrics"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

type Client struct {
Expand All @@ -20,28 +23,42 @@ type Client struct {
RealUserMetrics *realusermetrics.RealUserMetricsClient
}

func NewClientWithBaseURI(endpoint string, configureAuthFunc func(c *autorest.Client)) Client {

endpointsClient := endpoints.NewEndpointsClientWithBaseURI(endpoint)
configureAuthFunc(&endpointsClient.Client)

geographicHierarchiesClient := geographichierarchies.NewGeographicHierarchiesClientWithBaseURI(endpoint)
configureAuthFunc(&geographicHierarchiesClient.Client)
func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) {
endpointsClient, err := endpoints.NewEndpointsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Endpoints client: %+v", err)
}
configureFunc(endpointsClient.Client)

heatMapsClient := heatmaps.NewHeatMapsClientWithBaseURI(endpoint)
configureAuthFunc(&heatMapsClient.Client)
geographicHierarchiesClient, err := geographichierarchies.NewGeographicHierarchiesClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building GeographicHierarchies client: %+v", err)
}
configureFunc(geographicHierarchiesClient.Client)

profilesClient := profiles.NewProfilesClientWithBaseURI(endpoint)
configureAuthFunc(&profilesClient.Client)
heatMapsClient, err := heatmaps.NewHeatMapsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building HeatMaps client: %+v", err)
}
configureFunc(heatMapsClient.Client)

realUserMetricsClient := realusermetrics.NewRealUserMetricsClientWithBaseURI(endpoint)
configureAuthFunc(&realUserMetricsClient.Client)
profilesClient, err := profiles.NewProfilesClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Profiles client: %+v", err)
}
configureFunc(profilesClient.Client)

return Client{
Endpoints: &endpointsClient,
GeographicHierarchies: &geographicHierarchiesClient,
HeatMaps: &heatMapsClient,
Profiles: &profilesClient,
RealUserMetrics: &realUserMetricsClient,
realUserMetricsClient, err := realusermetrics.NewRealUserMetricsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building RealUserMetrics client: %+v", err)
}
configureFunc(realUserMetricsClient.Client)

return &Client{
Endpoints: endpointsClient,
GeographicHierarchies: geographicHierarchiesClient,
HeatMaps: heatMapsClient,
Profiles: profilesClient,
RealUserMetrics: realUserMetricsClient,
}, nil
}
22 changes: 15 additions & 7 deletions resource-manager/trafficmanager/2018-08-01/endpoints/client.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package endpoints

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

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

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

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 @@ -27,6 +31,19 @@ func PossibleValuesForEndpointMonitorStatus() []string {
}
}

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

func parseEndpointMonitorStatus(input string) (*EndpointMonitorStatus, error) {
vals := map[string]EndpointMonitorStatus{
"checkingendpoint": EndpointMonitorStatusCheckingEndpoint,
Expand Down Expand Up @@ -59,6 +76,19 @@ func PossibleValuesForEndpointStatus() []string {
}
}

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

func parseEndpointStatus(input string) (*EndpointStatus, error) {
vals := map[string]EndpointStatus{
"disabled": EndpointStatusDisabled,
Expand Down Expand Up @@ -89,6 +119,19 @@ func PossibleValuesForEndpointType() []string {
}
}

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

func parseEndpointType(input string) (*EndpointType, error) {
vals := map[string]EndpointType{
"azureendpoints": EndpointTypeAzureEndpoints,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package endpoints

import (
"context"
"net/http"

"github.com/hashicorp/go-azure-sdk/sdk/client"
"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 {
HttpResponse *http.Response
OData *odata.OData
Model *Endpoint
}

// CreateOrUpdate ...
func (c EndpointsClient) CreateOrUpdate(ctx context.Context, id EndpointTypeId, input Endpoint) (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
}

if err = resp.Unmarshal(&result.Model); err != nil {
return
}

return
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package endpoints

import (
"context"
"net/http"

"github.com/hashicorp/go-azure-sdk/sdk/client"
"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 {
HttpResponse *http.Response
OData *odata.OData
Model *DeleteOperationResult
}

// Delete ...
func (c EndpointsClient) Delete(ctx context.Context, id EndpointTypeId) (result DeleteOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
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
}

if err = resp.Unmarshal(&result.Model); err != nil {
return
}

return
}
Loading

0 comments on commit fbf2e93

Please sign in to comment.