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 (03011cd215c0c6ec556116c811e537b011ee5ca6) #580

Closed
wants to merge 1 commit into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 15 additions & 7 deletions resource-manager/apimanagement/2021-08-01/api/client.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package api

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

"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
"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 ApiClient struct {
Client autorest.Client
baseUri string
Client *resourcemanager.Client
}

func NewApiClientWithBaseURI(endpoint string) ApiClient {
return ApiClient{
Client: autorest.NewClientWithUserAgent(userAgent()),
baseUri: endpoint,
func NewApiClientWithBaseURI(api environments.Api) (*ApiClient, error) {
client, err := resourcemanager.NewResourceManagerClient(api, "api", defaultApiVersion)
if err != nil {
return nil, fmt.Errorf("instantiating ApiClient: %+v", err)
}

return &ApiClient{
Client: client,
}, nil
}
84 changes: 83 additions & 1 deletion resource-manager/apimanagement/2021-08-01/api/constants.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package api

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

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

func parseApiType(input string) (*ApiType, error) {
vals := map[string]ApiType{
"graphql": ApiTypeGraphql,
Expand Down Expand Up @@ -53,6 +70,19 @@ func PossibleValuesForBearerTokenSendingMethods() []string {
}
}

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

func parseBearerTokenSendingMethods(input string) (*BearerTokenSendingMethods, error) {
vals := map[string]BearerTokenSendingMethods{
"authorizationheader": BearerTokenSendingMethodsAuthorizationHeader,
Expand Down Expand Up @@ -99,6 +129,19 @@ func PossibleValuesForContentFormat() []string {
}
}

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

func parseContentFormat(input string) (*ContentFormat, error) {
vals := map[string]ContentFormat{
"graphql-link": ContentFormatGraphqlNegativelink,
Expand Down Expand Up @@ -140,6 +183,19 @@ func PossibleValuesForProtocol() []string {
}
}

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

func parseProtocol(input string) (*Protocol, error) {
vals := map[string]Protocol{
"http": ProtocolHTTP,
Expand Down Expand Up @@ -174,6 +230,19 @@ func PossibleValuesForSoapApiType() []string {
}
}

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

func parseSoapApiType(input string) (*SoapApiType, error) {
vals := map[string]SoapApiType{
"graphql": SoapApiTypeGraphql,
Expand Down Expand Up @@ -206,6 +275,19 @@ func PossibleValuesForVersioningScheme() []string {
}
}

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

func parseVersioningScheme(input string) (*VersioningScheme, error) {
vals := map[string]VersioningScheme{
"header": VersioningSchemeHeader,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package api

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
}

type CreateOrUpdateOperationOptions struct {
IfMatch *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))
}
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 ApiClient) CreateOrUpdate(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, options CreateOrUpdateOperationOptions) (result CreateOrUpdateOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusAccepted,
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 ApiClient) CreateOrUpdateThenPoll(ctx context.Context, id ApiId, input ApiCreateOrUpdateParameter, 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
}

This file was deleted.

Loading
Loading