Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto PR: Regenerating the Go SDK (add38d9bbbc542ddcb0fe2eae8e58f036dcf7445) #874

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 55 additions & 29 deletions resource-manager/streamanalytics/2020-03-01/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ package v2020_03_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/streamanalytics/2020-03-01/clusters"
"github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2020-03-01/functions"
"github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2020-03-01/inputs"
Expand All @@ -13,6 +14,8 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2020-03-01/streamingjobs"
"github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2020-03-01/subscriptions"
"github.com/hashicorp/go-azure-sdk/resource-manager/streamanalytics/2020-03-01/transformations"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

type Client struct {
Expand All @@ -26,40 +29,63 @@ type Client struct {
Transformations *transformations.TransformationsClient
}

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

clustersClient := clusters.NewClustersClientWithBaseURI(endpoint)
configureAuthFunc(&clustersClient.Client)

functionsClient := functions.NewFunctionsClientWithBaseURI(endpoint)
configureAuthFunc(&functionsClient.Client)
func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) {
clustersClient, err := clusters.NewClustersClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Clusters client: %+v", err)
}
configureFunc(clustersClient.Client)

inputsClient := inputs.NewInputsClientWithBaseURI(endpoint)
configureAuthFunc(&inputsClient.Client)
functionsClient, err := functions.NewFunctionsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Functions client: %+v", err)
}
configureFunc(functionsClient.Client)

outputsClient := outputs.NewOutputsClientWithBaseURI(endpoint)
configureAuthFunc(&outputsClient.Client)
inputsClient, err := inputs.NewInputsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Inputs client: %+v", err)
}
configureFunc(inputsClient.Client)

privateEndpointsClient := privateendpoints.NewPrivateEndpointsClientWithBaseURI(endpoint)
configureAuthFunc(&privateEndpointsClient.Client)
outputsClient, err := outputs.NewOutputsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Outputs client: %+v", err)
}
configureFunc(outputsClient.Client)

streamingJobsClient := streamingjobs.NewStreamingJobsClientWithBaseURI(endpoint)
configureAuthFunc(&streamingJobsClient.Client)
privateEndpointsClient, err := privateendpoints.NewPrivateEndpointsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building PrivateEndpoints client: %+v", err)
}
configureFunc(privateEndpointsClient.Client)

subscriptionsClient := subscriptions.NewSubscriptionsClientWithBaseURI(endpoint)
configureAuthFunc(&subscriptionsClient.Client)
streamingJobsClient, err := streamingjobs.NewStreamingJobsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building StreamingJobs client: %+v", err)
}
configureFunc(streamingJobsClient.Client)

transformationsClient := transformations.NewTransformationsClientWithBaseURI(endpoint)
configureAuthFunc(&transformationsClient.Client)
subscriptionsClient, err := subscriptions.NewSubscriptionsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Subscriptions client: %+v", err)
}
configureFunc(subscriptionsClient.Client)

return Client{
Clusters: &clustersClient,
Functions: &functionsClient,
Inputs: &inputsClient,
Outputs: &outputsClient,
PrivateEndpoints: &privateEndpointsClient,
StreamingJobs: &streamingJobsClient,
Subscriptions: &subscriptionsClient,
Transformations: &transformationsClient,
transformationsClient, err := transformations.NewTransformationsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Transformations client: %+v", err)
}
configureFunc(transformationsClient.Client)

return &Client{
Clusters: clustersClient,
Functions: functionsClient,
Inputs: inputsClient,
Outputs: outputsClient,
PrivateEndpoints: privateEndpointsClient,
StreamingJobs: streamingJobsClient,
Subscriptions: subscriptionsClient,
Transformations: transformationsClient,
}, nil
}
22 changes: 15 additions & 7 deletions resource-manager/streamanalytics/2020-03-01/clusters/client.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package clusters

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

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

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

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

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

func parseClusterProvisioningState(input string) (*ClusterProvisioningState, error) {
vals := map[string]ClusterProvisioningState{
"canceled": ClusterProvisioningStateCanceled,
Expand Down Expand Up @@ -51,6 +68,19 @@ func PossibleValuesForClusterSkuName() []string {
}
}

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

func parseClusterSkuName(input string) (*ClusterSkuName, error) {
vals := map[string]ClusterSkuName{
"default": ClusterSkuNameDefault,
Expand Down Expand Up @@ -94,6 +124,19 @@ func PossibleValuesForJobState() []string {
}
}

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

func parseJobState(input string) (*JobState, error) {
vals := map[string]JobState{
"created": JobStateCreated,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package clusters

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

type CreateOrUpdateOperationOptions struct {
IfMatch *string
IfNoneMatch *string
}

func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions {
return CreateOrUpdateOperationOptions{}
}

func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers {
out := client.Headers{}
if o.IfMatch != nil {
out.Append("If-Match", fmt.Sprintf("%v", *o.IfMatch))
}
if o.IfNoneMatch != nil {
out.Append("If-None-Match", fmt.Sprintf("%v", *o.IfNoneMatch))
}
return &out
}

func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query {
out := odata.Query{}
return &out
}

func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams {
out := client.QueryParams{}

return &out
}

// CreateOrUpdate ...
func (c ClustersClient) CreateOrUpdate(ctx context.Context, id ClusterId, input Cluster, options CreateOrUpdateOperationOptions) (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(),
OptionsObject: options,
}

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 ClustersClient) CreateOrUpdateThenPoll(ctx context.Context, id ClusterId, input Cluster, options CreateOrUpdateOperationOptions) error {
result, err := c.CreateOrUpdate(ctx, id, input, options)
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
}
Loading
Loading